BGE PhysicsConstraints.exportBulletFile improvement: also export the object names to .bullet files.
This commit is contained in:
parent
67c7fa46db
commit
6c972d634e
@ -524,4 +524,15 @@ bool KX_BulletPhysicsController::Update(double time)
|
||||
// return false;
|
||||
}
|
||||
|
||||
|
||||
const char* KX_BulletPhysicsController::getName()
|
||||
{
|
||||
if (m_pObject)
|
||||
{
|
||||
KX_GameObject* gameobj = (KX_GameObject*) m_pObject->GetSGClientObject();
|
||||
return gameobj->GetName();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // USE_BULLET
|
||||
|
@ -80,6 +80,8 @@ public:
|
||||
virtual bool Update(double time);
|
||||
void* GetUserData() { return m_userdata;}
|
||||
|
||||
virtual const char* getName();
|
||||
|
||||
void
|
||||
SetOption(
|
||||
int option,
|
||||
|
@ -577,6 +577,10 @@ protected:
|
||||
return m_parentCtrl;
|
||||
}
|
||||
|
||||
virtual const char* getName()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
public:
|
||||
|
@ -2797,8 +2797,26 @@ float CcdPhysicsEnvironment::getAppliedImpulse(int constraintid)
|
||||
void CcdPhysicsEnvironment::exportFile(const char* filename)
|
||||
{
|
||||
btDefaultSerializer* serializer = new btDefaultSerializer();
|
||||
m_dynamicsWorld->serialize(serializer);
|
||||
|
||||
|
||||
for (int i=0;i<m_dynamicsWorld->getNumCollisionObjects();i++)
|
||||
{
|
||||
|
||||
btCollisionObject* colObj = m_dynamicsWorld->getCollisionObjectArray()[i];
|
||||
|
||||
CcdPhysicsController* controller = static_cast<CcdPhysicsController*>(colObj->getUserPointer());
|
||||
if (controller)
|
||||
{
|
||||
const char* name = controller->getName();
|
||||
if (name)
|
||||
{
|
||||
serializer->registerNameForPointer(colObj,name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_dynamicsWorld->serialize(serializer);
|
||||
|
||||
FILE* file = fopen(filename,"wb");
|
||||
if (file)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user