Repository navigation
VehicleCollisionTesterCastSphere question #2144
|
Documentation says that the inObjectLayer paramter is "Object layer to test collision with", which might be a little ambiguous. Is it saying that the wheels will adopt the the layer "to test collisions with" against a target in another layer (since the wheels have no layer of their own) or is it saying the wheels will use this layer "to test collisions with" targets in that layer? Everything I read says that it's the latter, but my code fails if I set it to Layers::NON_MOVING, which is what the ground is set to. My ground is set to NON_MOVING, and my tank bodies are set to MOVING. I find that I have to set inObjectLayer to MOVING to get the wheels to collide with the ground. I have verified that the static mesh that i want the wheels to collide with are in NON_MOVING layer. I am setting up VehicleCollisionTesterCastSphere as part of my vehicle being able to traverse any slope of mesh (dyson sphere), and it works really well, but i want to resolve this issue so i can finish documenting what i did and why i did it. Any insight is appreciated. |
Replies: 2 comments 1 reply
|
The doc line is ambiguous but the parameter name is the tell: it's Look at how it's used internally, e.g. const DefaultBroadPhaseLayerFilter default_broadphase_layer_filter = inPhysicsSystem.GetDefaultBroadPhaseLayerFilter(mObjectLayer);
const DefaultObjectLayerFilter default_object_layer_filter = inPhysicsSystem.GetDefaultLayerFilter(mObjectLayer);VehicleCollisionTester.cpp#L127-L131
virtual bool ShouldCollide(ObjectLayer inLayer) const override
{
return mObjectLayerPairFilter.ShouldCollide(mLayer, inLayer);
}This is the exact same call pattern This is also exactly what every official sample does, e.g. mVehicleConstraint->SetVehicleCollisionTester(new VehicleCollisionTesterRay(Layers::MOVING));TankTest.cpp#L114, same in So your fix (using MOVING) is correct and is the intended usage, not a workaround. The doc comment "Object layer to test collision with" would be clearer as "Object layer the vehicle/wheel is considered to be on for this collision test". |
|
thank you both. sorry i thought i was marking as answer, but actually removed it as answer, put it back. |
The doc line is ambiguous but the parameter name is the tell: it's
inObjectLayer, the layer the wheel itself is treated as being on for the query, not the layer you want to hit.Look at how it's used internally, e.g.
VehicleCollisionTesterCastSphere::Collide:VehicleCollisionTester.cpp#L127-L131
GetDefaultLayerFilterjust wraps yourObjectLayerPairFilterwith that layer as the "own" side of the pair test: