mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 08:34:40 +00:00
Merge pull request #1743 from John3/fixDB_PSeditorTimmy
replace fix #1736 for add physicShape datablock from the editor
This commit is contained in:
commit
fcfe2d621a
1 changed files with 21 additions and 17 deletions
|
|
@ -31,6 +31,7 @@
|
||||||
#include "T3D/physics/physicsBody.h"
|
#include "T3D/physics/physicsBody.h"
|
||||||
#include "T3D/physics/physicsWorld.h"
|
#include "T3D/physics/physicsWorld.h"
|
||||||
#include "T3D/physics/physicsCollision.h"
|
#include "T3D/physics/physicsCollision.h"
|
||||||
|
#include "T3D/gameBase/gameConnection.h"
|
||||||
#include "collision/concretePolyList.h"
|
#include "collision/concretePolyList.h"
|
||||||
#include "ts/tsShapeInstance.h"
|
#include "ts/tsShapeInstance.h"
|
||||||
#include "scene/sceneRenderState.h"
|
#include "scene/sceneRenderState.h"
|
||||||
|
|
@ -280,27 +281,24 @@ bool PhysicsShapeData::preload( bool server, String &errorBuffer )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( shapeName && shapeName[0] != '\0' && !bool(shape) )
|
bool shapeError = false;
|
||||||
|
|
||||||
|
if (shapeName && shapeName[0])
|
||||||
{
|
{
|
||||||
// Load the shape.
|
// Resolve shapename
|
||||||
shape = ResourceManager::get().load(shapeName);
|
shape = ResourceManager::get().load(shapeName);
|
||||||
if( bool(shape) == false )
|
if (bool(shape) == false)
|
||||||
{
|
{
|
||||||
errorBuffer = String::ToString("PhysicsShapeData::load: Couldn't load shape \"%s\"", shapeName);
|
errorBuffer = String::ToString("PhysicsShapeData: Couldn't load shape \"%s\"", shapeName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
if (!server && !shape->preloadMaterialList(shape.getPath()) && NetConnection::filesWereDownloaded())
|
||||||
{
|
shapeError = true;
|
||||||
TSShapeInstance* pDummy = new TSShapeInstance(shape, !server);
|
|
||||||
delete pDummy;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Prepare the shared physics collision shape.
|
// Prepare the shared physics collision shape.
|
||||||
if ( !colShape )
|
if ( !colShape && shape )
|
||||||
{
|
{
|
||||||
colShape = shape->buildColShape( false, Point3F::One );
|
colShape = shape->buildColShape( false, Point3F::One );
|
||||||
|
|
||||||
|
|
@ -308,8 +306,14 @@ bool PhysicsShapeData::preload( bool server, String &errorBuffer )
|
||||||
// we need to fail... can't have a shape without collision.
|
// we need to fail... can't have a shape without collision.
|
||||||
if ( !colShape )
|
if ( !colShape )
|
||||||
{
|
{
|
||||||
errorBuffer = String::ToString( "PhysicsShapeData::preload - No collision found for shape '%s'.", shapeName );
|
//no collision so we create a simple box collision shape from the shapes bounds and alert the user
|
||||||
return false;
|
Con::warnf( "PhysicsShapeData::preload - No collision found for shape '%s', auto-creating one", shapeName );
|
||||||
|
Point3F halfWidth = shape->bounds.getExtents() * 0.5f;
|
||||||
|
colShape = PHYSICSMGR->createCollision();
|
||||||
|
MatrixF centerXfm(true);
|
||||||
|
centerXfm.setPosition(shape->bounds.getCenter());
|
||||||
|
colShape->addBox(halfWidth, centerXfm);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -381,7 +385,7 @@ bool PhysicsShapeData::preload( bool server, String &errorBuffer )
|
||||||
MatrixF::Identity );
|
MatrixF::Identity );
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return true;
|
return !shapeError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -699,7 +703,7 @@ bool PhysicsShape::_createShape()
|
||||||
mAmbientSeq = -1;
|
mAmbientSeq = -1;
|
||||||
|
|
||||||
PhysicsShapeData *db = getDataBlock();
|
PhysicsShapeData *db = getDataBlock();
|
||||||
if ( !db )
|
if ( !db || !db->shape)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Set the world box.
|
// Set the world box.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue