[quote=“TheComet”]I’m trying to draw CollisionShapes because things aren’t doing what they’re supposed to in my physics but I can’t figure out how to do that.
I thought it would have been as simple as:
PhysicsWorld* world = scene_->GetComponent<PhysicsWorld>();
world->DrawDebugGeometry(scene_->CreateComponent<DebugRenderer>());
I also tried that in conjunction with:
I’m not getting anywhere because there’s no mention of it in the documentation. At least not in a way I can understand.[/quote]
The easiest way is you create a debug renderer and draw necessary data in E_POSTRENDERUPDATE. This will ensure your debug data will be drawed on top of other graphical elements in the scene.
Just subscribe to this event and draw your debug data there :
[code]void MyApp::Start()
{
scene->CreateComponent();
SubscribeToEvent(E_POSTRENDERUPDATE, URHO3D_HANDLER(MyApp, drawDebug));
}
void MyApp::drawDebug(Urho3D::StringHash eventType, Urho3D::VariantMap& eventData)
{
DebugRenderer * dbgRenderer = scene->GetComponent();
if (dbgRenderer)
{
// Draw navmesh data
DynamicNavigationMesh * navMesh = scene->GetComponent();
navMesh->DrawDebugGeometry(dbgRenderer,false);
// Draw Physics data :
PhysicsWorld * phyWorld = scene->GetComponent<PhysicsWorld>();
phyWorld->DrawDebugGeometry(dbgRenderer,false);
// etc
}
}[/code]
It is recommended to nullcheck your components (PhysicsWorld , DynamicMesh etc) before you draw them