Equipment collision issue in TabletopKit

Hey! I'm facing an issue with Equipment collision when adding and moving TabletopKit equipment with different pose rotations.

Let me share a very simple TabletopKit setup as an example:

Table

struct Table: Tabletop {
    var shape: TabletopShape = .rectangular(width: 1, height: 1, thickness: 0.01)
    var id: EquipmentIdentifier = .tableID
}

Board

struct Board: Equipment {
    let id: EquipmentIdentifier = .boardID

    var initialState: BaseEquipmentState {
        .init(
            parentID: .tableID,
            seatControl: .restricted([]),
            pose: .init(position: .init(), rotation: .zero),
            boundingBox: .init(center: .zero, size: .init(1.0, 0, 1.0))
        )
    }
}

Equipment

struct Object: EntityEquipment {
    var id: ID
    var size: SIMD2<Float>
    var position: SIMD2<Double>
    var rotation: Float
    var entity: Entity
    var initialState: BaseEquipmentState
    
    init(id: Int, size: SIMD2<Float>, position: SIMD2<Double>, rotation: Float) {      
        self.id = EquipmentIdentifier(id)
        self.size = size
        self.position = position
        self.rotation = rotation
        self.entity = objectEntity
        
        self.initialState = .init(
            parentID: .boardID,
            seatControl: .any,
            pose: .init(
                position: .init(x: position.x, z: position.y),
                rotation: .degrees(Double(rotation))
            ),
            entity: entity
        )
    }
}

Setup

class GameSetup {
    var setup: TableSetup

    init(root: Entity) {
        setup = TableSetup(tabletop: Table())
        setup.add(equipment: Board())
        setup.add(seat: PlayerSeat())
        
        let object1 = Object(
            id: 2,
            size: .init(x: 0.1, y: 0.1),
            position: .init(x: 0.1, y: -0.1),
            rotation: 0
        )
        let object2 = Object(
            id: 3,
            size: .init(x: 0.2, y: 0.1),
            position: .init(x: -0.1, y: -0.1),
            rotation: 90
        )
        
        setup.add(equipment: object1)
        setup.add(equipment: object2)
    }
}

The issue

When I add two equipment entities with different rotation poses, the collisions between them behave oddly. If one is 90º and the other 0º, for example, the former will intersect with the latter as if its bounding box was not rotated as you can see below:

But if both equipment have the example rotation (e.g. 0 or 90º), though, then there's no collision issue at all, which seems to indicate their bounding box were correctly rotated:

‎‎

I'd really appreciate some help understanding if this is a bug or if I'm just missing something.

Thanks in advance!

This is the first I've heard of TabletopKit. So I may be clueless. But assuming it's a specialization of RealityKit, shouldn't those bounding boxes be different colors than white? That would signify static properties. Where I would suspect you want a kinematic and dynamic? The object you are moving would be kinematic and the one you want to react to it would be dynamic.

Hello @LucasBarcellos , thanks for the detailed writeup. Unfortunately, I don't think we can identify what is going on based on the code you've shared here. Is there more to your project? For example, I'm not able to compile your Object script, since it referencing an objectEntity that you've defined elsewhere. I was able to write down your GameInteraction from the video, but I think we're still missing pieces on our end.

I highly recommend submitting a bug report via Feedback Assistant. We can get more of our eyes on this and figure out if what you are seeing is a bug.

Thank you!

Hi, thanks a lot for the reply!

Sorry for the confusion about the objectEntity part. Here's a link to the complete sample project: https://github.com/lucasbarcellos/TabletopKit-Sample

I've already submitted a bug report (FB16426443), but I'd appreciate it if you could help me understand if this is a bug or if I'm missing something.

What I observed is that collisions work as expected if two Equipment instances are the same size and relative rotation but don't seem to work consistently when they have different sizes and rotations.

Steps to reproduce

  • Place a square (1x1) Equipment on the board with no rotation.
  • Place a rectangular (2x1) Equipment on the board with 90º rotation.
  • Move rectangular Equipment over the square one and observe the collision.

Expected result: collision between Equipment with different sizes and rotation to work correctly.

Result: collision doesn't work consistently when Equipment instances have different rotations and sizes.

Thanks again!

Equipment collision issue in TabletopKit
 
 
Q