michael.zhang Posted August 13, 2011 Share Posted August 13, 2011 Hello, What is the recommended way for defining an arbitrarily shaped region to trigger a callback? WorldTrigger seems to only support a rectangular prism. Can WorldTrigger be extended to have a method: setShape(Shape shape) Or, should I just use a Body? Michael Link to comment
ulf.schroeter Posted August 13, 2011 Share Posted August 13, 2011 WorldTrigger seems to only support a rectangular prism. Can WorldTrigger be extended to have a method: WorldTrigger only supports box region at the moment. If you have source code, you could extend WorldTrigger::inside() testing to support more complex trigger shapes. Physical trigger supports different base shapes. void PhysicalTrigger::setShapeType(int type) Description Sets the shape of the physical trigger. Arguments int type - Shape of the physical trigger: 0 = Sphere 1 = Capsule 2 = Cylinder 3 = Box Not sure if it would work, but another idea might be to use ObjectMesh with invisible surfaces and BodyRigid. Setup convex collison shape via BodyRigid::createShapes and trigger code via Body::setContactCallback(). Most probably shape mass should to be set to 0 to suppress physical effects on collision. Link to comment
michael.zhang Posted August 15, 2011 Author Share Posted August 15, 2011 Thanks Ulf, Ideally if they could extend the WorldTrigger interface, I dont have source, would be best. In the mean time, I am worried that using a BodyRigid would incur physics costs. Since I am developing for mobile, physics seems to be a huge performance killer. I'm not sure if that performance hit comes from physical simulation (velocity, etc.) or collision detection. Unfortunately, the mobile binaries are not available yet... and I cannot test on the mobile. Maybe unigine can give me an answer? So the question is, how can I use BodyRigid for collision purposes without incurring physics costs? Also, can we have PhysicalTrigger extended to support arbitrary shapes? Link to comment
michael.zhang Posted August 24, 2011 Author Share Posted August 24, 2011 Any chance I could get a confirmation of this feature implemented by next SDK release? Link to comment
manguste Posted August 30, 2011 Share Posted August 30, 2011 WorldTrigger works based on BSP tree, that is the reason it's shape is limited to a box. It is not planned to add support of convex shapes for PhysicalTrigger in the nearest future as well. You can use BodyRigid plus an arbitrary shape to check contacts, as Ulf suggested. You will get almost no performance penalty for body simulation even on mobiles (with NEON support it's a piece of cake). So actually it would not make much difference whether to use a body or the physical trigger. Link to comment
michael.zhang Posted August 30, 2011 Author Share Posted August 30, 2011 Aha! OKay, that's what I needed confirmation of :) No performance concerns. Thank you. Link to comment
Recommended Posts