BGE: new sensor object to generalize Near and Radar sensor, static-static collision capbility.
A new type of "Sensor" physics object is available in the GE for advanced collision management. It's called Sensor for its similarities with the physics objects that underlie the Near and Radar sensors. Like the Near and Radar object it is: - static and ghost - invisible by default - always active to ensure correct collision detection - capable of detecting both static and dynamic objects - ignoring collision with their parent - capable of broadphase filtering based on: * Actor option: the collisioning object must have the Actor flag set to be detected * property/material: as specified in the collision sensors attached to it Broadphase filtering is important for performance reason: the collision points will be computed only for the objects that pass the broahphase filter. - automatically removed from the simulation when no collision sensor is active on it Unlike the Near and Radar object it can: - take any shape, including triangle mesh - be made visible for debugging (just use the Visible actuator) - have multiple collision sensors using it Other than that, the sensor objects are ordinary objects. You can move them freely or parent them. When parented to a dynamic object, they can provide advanced collision control to this object. The type of collision capability depends on the shape: - box, sphere, cylinder, cone, convex hull provide volume detection. - triangle mesh provides surface detection but you can give some volume to the suface by increasing the margin in the Advanced Settings panel. The margin applies on both sides of the surface. Performance tip: - Sensor objects perform better than Near and Radar: they do less synchronizations because of the Scenegraph optimizations and they can have multiple collision sensors on them (with different property filtering for example). - Always prefer simple shape (box, sphere) to complex shape whenever possible. - Always use broadphase filtering (avoid collision sensor with empty propery/material) - Use collision sensor only when you need them. When no collision sensor is active on the sensor object, it is removed from the simulation and consume no CPU. Known limitations: - When running Blender in debug mode, you will see one warning line of the console: "warning btCollisionDispatcher::needsCollision: static-static collision!" In release mode this message is not printed. - Collision margin has no effect on sphere, cone and cylinder shape. Other performance improvements: - Remove unnecessary interpolation for Near and Radar objects and by extension sensor objects. - Use direct matrix copy instead of quaternion to synchronize orientation. Other bug fix: - Fix Near/Radar position error on newly activated objects. This was causing several detection problems in YoFrankie - Fix margin not passed correctly to gImpact shape. - Disable force/velocity actions on static objects
This commit is contained in:
@@ -332,7 +332,7 @@ void KX_GameObject::ProcessReplica()
|
||||
|
||||
}
|
||||
|
||||
static void setGraphicController_recursive(SG_Node* node, bool v)
|
||||
static void setGraphicController_recursive(SG_Node* node)
|
||||
{
|
||||
NodeList& children = node->GetSGChildren();
|
||||
|
||||
@@ -341,24 +341,24 @@ static void setGraphicController_recursive(SG_Node* node, bool v)
|
||||
SG_Node* childnode = (*childit);
|
||||
KX_GameObject *clientgameobj = static_cast<KX_GameObject*>( (*childit)->GetSGClientObject());
|
||||
if (clientgameobj != NULL) // This is a GameObject
|
||||
clientgameobj->ActivateGraphicController(v, false);
|
||||
clientgameobj->ActivateGraphicController(false);
|
||||
|
||||
// if the childobj is NULL then this may be an inverse parent link
|
||||
// so a non recursive search should still look down this node.
|
||||
setGraphicController_recursive(childnode, v);
|
||||
setGraphicController_recursive(childnode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KX_GameObject::ActivateGraphicController(bool active, bool recurse)
|
||||
void KX_GameObject::ActivateGraphicController(bool recurse)
|
||||
{
|
||||
if (m_pGraphicController)
|
||||
{
|
||||
m_pGraphicController->Activate(active);
|
||||
m_pGraphicController->Activate(m_bVisible);
|
||||
}
|
||||
if (recurse)
|
||||
{
|
||||
setGraphicController_recursive(GetSGNode(), active);
|
||||
setGraphicController_recursive(GetSGNode());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,6 +538,20 @@ void KX_GameObject::UpdateTransformFunc(SG_IObject* node, void* gameobj, void* s
|
||||
((KX_GameObject*)gameobj)->UpdateTransform();
|
||||
}
|
||||
|
||||
void KX_GameObject::SynchronizeTransform()
|
||||
{
|
||||
// only used for sensor object, do full synchronization as bullet doesn't do it
|
||||
if (m_pPhysicsController1)
|
||||
m_pPhysicsController1->SetTransform();
|
||||
if (m_pGraphicController)
|
||||
m_pGraphicController->SetGraphicTransform();
|
||||
}
|
||||
|
||||
void KX_GameObject::SynchronizeTransformFunc(SG_IObject* node, void* gameobj, void* scene)
|
||||
{
|
||||
((KX_GameObject*)gameobj)->SynchronizeTransform();
|
||||
}
|
||||
|
||||
|
||||
void KX_GameObject::SetDebugColor(unsigned int bgra)
|
||||
{
|
||||
|
Reference in New Issue
Block a user