ArticulatedPhysicsEntity::~ArticulatedPhysicsEntity()
{
	SimplePhysicsEntity* entity;
	unsigned entityId;
	unsigned rigidBodyIndex, entityIndex;
	std::map<unsigned, unsigned>::iterator it;

	Physics* physics = (Physics*)SystemCore::getModuleByName("Physics");

	if (physics && articulatedBody->isAddedToSimulation())
		physics->removePhysicsObject(this);

	// Clear rigidBody-Pointer in SimplePhysicsEntity
	for (it = rigidBodyMapping.begin(); it != rigidBodyMapping.end(); ++it)
	{
		rigidBodyIndex = (*it).first;
		entityIndex = (*it).second;
		entityId = this->environmentBasedId + entityIndex;
		entity = (SimplePhysicsEntity*)WorldDatabase::getEntityWithEnvironmentId(entityId);
		if (entity)
			entity->rigidBody = NULL;
	} // for

	delete articulatedBody;
} // ~ArticulatedPhysicsEntity
Esempio n. 2
0
CursorSpringConnector::~CursorSpringConnector()
{
	Physics* physicsModule;
	physicsModule = (Physics*)SystemCore::getModuleByName("Physics");
	if (physicsModule) {
		physicsModule->removePhysicsObject(this);
		physicsModule->removeSimulationStepListener(this);
		physicsModule->removeSystemThreadListener(this);
	} // if
} // ~CursorSpringConnector