lo-th / phy

Physics for three. Game engine
https://lo-th.github.io/phy/
MIT License
521 stars 44 forks source link

(physx worker bug) - Contacts involving a vehicle are not detected #30

Open nebular opened 6 months ago

nebular commented 6 months ago

(physx) Adding a contact between a vehicle and a body is never triggered.

However, the worker does detect the contact - it only doesn't find the name of the object so it doesnt call the callback.

Screenshot 2024-05-14 at 20 58 16 In the supplied screenshot - when the worker receives the "addVehicle" - it just lacks:

case "vehicle":
     C.set(A.vehicleActor.ptr, A.name);

then later on, Q is found correctly as the vehicle and the callback reaches phy.

Screenshot 2024-05-14 at 21 01 29

nebular commented 6 months ago

Also, if I add a Ray with a vehicle as Parent - there is the same problem but worse: The Worker will die because A.getGlobalPose is undefined (rather being A.vehicleActor.getGlobalPose).

0], this.end = A.end || [0, 0, 1], this.precision = A.precision || 1, this.group = void 0 !== A.group || 16, this.mask = void 0 !== A.mask || 2;}

    getPoint() {
        if (this.parent) {
            const A = Q.byName(this.parent);
            if (A) {
                const I = A.getGlobalPose(),
                    g = I.p.toArray(),
                    C = I.q.toArray();
                return [p.applyTransformArray(this.begin, g, C), p.applyTransformArray(this.end, g, C)];
            }
        }
        return [this.begin, this.end];
    }
}

a simple fix:

                const I = A.type === "vehicle" ? A.vehicleActor.getGlobalPose() : A.getGlobalPose,
lo-th commented 6 months ago

Hi yes vehicle have specific rigidbody in physx i have to try is about collision filter