VOID DebugDraw::DrawBound( const Bound& bound, D3DCOLOR Color ) { switch( bound.GetType() ) { case Bound::Sphere_Bound: DrawSphere( bound.GetSphere(), Color ); return; case Bound::Frustum_Bound: DrawFrustum( bound.GetFrustum(), Color ); return; case Bound::AABB_Bound: DrawAabb( bound.GetAabb(), Color ); return; case Bound::OBB_Bound: DrawObb( bound.GetObb(), Color ); return; } }
void CcdPhysicsEnvironment::UpdateAabbs(float timeStep) { std::vector<CcdPhysicsController*>::iterator i; BroadphaseInterface* scene = GetBroadphase(); // // update aabbs, only for moving objects (!) // for (i=m_controllers.begin(); !(i==m_controllers.end()); i++) { CcdPhysicsController* ctrl = (*i); RigidBody* body = ctrl->GetRigidBody(); SimdPoint3 minAabb,maxAabb; CollisionShape* shapeinterface = ctrl->GetCollisionShape(); shapeinterface->CalculateTemporalAabb(body->getCenterOfMassTransform(), body->getLinearVelocity(), //body->getAngularVelocity(), SimdVector3(0.f,0.f,0.f),//no angular effect for now //body->getAngularVelocity(), timeStep,minAabb,maxAabb); SimdVector3 manifoldExtraExtents(gContactBreakingTreshold,gContactBreakingTreshold,gContactBreakingTreshold); minAabb -= manifoldExtraExtents; maxAabb += manifoldExtraExtents; BroadphaseProxy* bp = body->m_broadphaseHandle; if (bp) { SimdVector3 color (1,1,0); if (m_debugDrawer) { //draw aabb switch (body->GetActivationState()) { case ISLAND_SLEEPING: { color.setValue(1,1,1); break; } case WANTS_DEACTIVATION: { color.setValue(0,0,1); break; } case ACTIVE_TAG: { break; } case DISABLE_DEACTIVATION: { color.setValue(1,0,1); }; }; if (m_debugDrawer->GetDebugMode() & IDebugDraw::DBG_DrawAabb) { DrawAabb(m_debugDrawer,minAabb,maxAabb,color); } } if ( (maxAabb-minAabb).length2() < 1e12f) { scene->SetAabb(bp,minAabb,maxAabb); } else { //something went wrong, investigate //removeCcdPhysicsController(ctrl); body->SetActivationState(DISABLE_SIMULATION); static bool reportMe = true; if (reportMe) { reportMe = false; printf("Overflow in AABB, object removed from simulation \n"); printf("If you can reproduce this, please email [email protected]\n"); printf("Please include above information, your Platform, version of OS.\n"); printf("Thanks.\n"); } } } } }
void Model::Render(const matrix4x4f &trans, const RenderData *rd) { //update color parameters (materials are shared by model instances) if (m_curPattern) { for (MaterialContainer::const_iterator it = m_materials.begin(); it != m_materials.end(); ++it) { if ((*it).second->GetDescriptor().usePatterns) { (*it).second->texture5 = m_colorMap.GetTexture(); (*it).second->texture4 = m_curPattern; } } } //update decals (materials and geometries are shared) for (unsigned int i=0; i < MAX_DECAL_MATERIALS; i++) if (m_decalMaterials[i]) m_decalMaterials[i]->texture0 = m_curDecals[i]; //Override renderdata if this model is called from ModelNode RenderData params = (rd != 0) ? (*rd) : m_renderData; m_renderer->SetTransform(trans); //using the entire model bounding radius for all nodes at the moment. //BR could also be a property of Node. params.boundingRadius = GetDrawClipRadius(); //render in two passes, if this is the top-level model if (m_debugFlags & DEBUG_WIREFRAME) m_renderer->SetWireFrameMode(true); if (params.nodemask & MASK_IGNORE) { m_root->Render(trans, ¶ms); } else { params.nodemask = NODE_SOLID; m_root->Render(trans, ¶ms); params.nodemask = NODE_TRANSPARENT; m_root->Render(trans, ¶ms); } if (!m_debugFlags) return; if (m_debugFlags & DEBUG_WIREFRAME) m_renderer->SetWireFrameMode(false); if (m_debugFlags & DEBUG_BBOX) { m_renderer->SetTransform(trans); DrawAabb(); } if (m_debugFlags & DEBUG_COLLMESH) { m_renderer->SetTransform(trans); DrawCollisionMesh(); } if (m_debugFlags & DEBUG_TAGS) { m_renderer->SetTransform(trans); DrawAxisIndicators(m_tagPoints); } if (m_debugFlags & DEBUG_DOCKING) { m_renderer->SetTransform(trans); DrawAxisIndicators(m_dockingPoints); } }