Merge remote-tracking branch 'origin/style-cleanup' into development

Conflicts:
	Engine/source/T3D/tsStatic.cpp
	Engine/source/console/compiledEval.cpp
	Engine/source/ts/tsMesh.cpp
	Engine/source/ts/tsShape.cpp
This commit is contained in:
Daniel Buckmaster 2015-03-01 22:30:22 +11:00
commit 33fcc59543
62 changed files with 3380 additions and 3381 deletions

View file

@ -573,7 +573,7 @@ bool Debris::onAdd()
// Setup our bounding box
if( mDataBlock->shape )
{
mObjBox = mDataBlock->shape->bounds;
mObjBox = mDataBlock->shape->mBounds;
}
else
{

View file

@ -213,7 +213,7 @@ void RenderShapeExample::createShape()
}
// Update the bounding box
mObjBox = mShape->bounds;
mObjBox = mShape->mBounds;
resetWorldBox();
setRenderTransform(mObjToWorld);

View file

@ -1252,7 +1252,7 @@ bool Explosion::explode()
mEndingMS = U32(mExplosionInstance->getScaledDuration(mExplosionThread) * 1000.0f);
mObjScale.convolve(mDataBlock->explosionScale);
mObjBox = mDataBlock->explosionShape->bounds;
mObjBox = mDataBlock->explosionShape->mBounds;
resetWorldBox();
}

View file

@ -1142,7 +1142,7 @@ GroundCoverCell* GroundCover::_generateCell( const Point2I& index,
const F32 typeMaxElevation = mMaxElevation[type];
const F32 typeMinElevation = mMinElevation[type];
const bool typeIsShape = mShapeInstances[ type ] != NULL;
const Box3F typeShapeBounds = typeIsShape ? mShapeInstances[ type ]->getShape()->bounds : Box3F();
const Box3F typeShapeBounds = typeIsShape ? mShapeInstances[ type ]->getShape()->mBounds : Box3F();
const F32 typeWindScale = mWindScale[type];
StringTableEntry typeLayer = mLayer[type];
const bool typeInvertLayer = mInvertLayer[type];

View file

@ -268,8 +268,8 @@ void GuiMaterialPreview::setObjectModel(const char* modelName)
AssertFatal(mModel, avar("GuiMaterialPreview: Failed to load model %s. Please check your model name and load a valid model.", modelName));
// Initialize camera values:
mOrbitPos = mModel->getShape()->center;
mMinOrbitDist = mModel->getShape()->radius;
mOrbitPos = mModel->getShape()->mCenter;
mMinOrbitDist = mModel->getShape()->mRadius;
lastRenderTime = Platform::getVirtualMilliseconds();
}
@ -434,7 +434,7 @@ void GuiMaterialPreview::resetViewport()
mCameraRot.set( mDegToRad(30.0f), 0, mDegToRad(-30.0f) );
mCameraPos.set(0.0f, 1.75f, 1.25f);
mOrbitDist = 5.0f;
mOrbitPos = mModel->getShape()->center;
mOrbitPos = mModel->getShape()->mCenter;
// Reset the viewport's lighting.
GuiMaterialPreview::mFakeSun->setColor( ColorF( 1.0f, 1.0f, 1.0f ) );

View file

@ -366,8 +366,8 @@ void GuiObjectView::setObjectModel( const String& modelName )
// Initialize camera values.
mOrbitPos = mModel->getShape()->center;
mMinOrbitDist = mModel->getShape()->radius;
mOrbitPos = mModel->getShape()->mCenter;
mMinOrbitDist = mModel->getShape()->mRadius;
// Initialize animation.
@ -645,7 +645,7 @@ void GuiObjectView::_initAnimation()
if( mAnimationSeq != -1 )
{
if( mAnimationSeq >= mModel->getShape()->sequences.size() )
if( mAnimationSeq >= mModel->getShape()->mSequences.size() )
{
Con::errorf( "GuiObjectView::_initAnimation - Sequence '%i' out of range for model '%s'",
mAnimationSeq,
@ -694,7 +694,7 @@ void GuiObjectView::_initMount()
// Make sure mount node is valid.
if( mMountNode != -1 && mMountNode >= mModel->getShape()->nodes.size() )
if( mMountNode != -1 && mMountNode >= mModel->getShape()->mNodes.size() )
{
Con::errorf( "GuiObjectView::_initMount - Mount node index '%i' out of range for '%s'",
mMountNode,

View file

@ -358,7 +358,7 @@ bool PhysicsDebris::onAdd()
}
// Setup our bounding box
mObjBox = mDataBlock->shape->bounds;
mObjBox = mDataBlock->shape->mBounds;
resetWorldBox();
// Add it to the client scene.
@ -696,20 +696,20 @@ void PhysicsDebris::_findNodes( U32 colNode, Vector<U32> &nodeIds )
// 2. Collision node is a child of its visible mesh node
TSShape *shape = mDataBlock->shape;
S32 itr = shape->nodes[colNode].parentIndex;
itr = shape->nodes[itr].firstChild;
S32 itr = shape->mNodes[colNode].parentIndex;
itr = shape->mNodes[itr].firstChild;
while ( itr != -1 )
{
if ( itr != colNode )
nodeIds.push_back(itr);
itr = shape->nodes[itr].nextSibling;
itr = shape->mNodes[itr].nextSibling;
}
// If we didn't find any siblings of the collision node we assume
// it is case #2 and the collision nodes direct parent is the visible mesh.
if ( nodeIds.size() == 0 && shape->nodes[colNode].parentIndex != -1 )
nodeIds.push_back( shape->nodes[colNode].parentIndex );
if ( nodeIds.size() == 0 && shape->mNodes[colNode].parentIndex != -1 )
nodeIds.push_back( shape->mNodes[colNode].parentIndex );
}
extern bool gEditingMission;

View file

@ -698,7 +698,7 @@ bool PhysicsShape::_createShape()
return false;
// Set the world box.
mObjBox = db->shape->bounds;
mObjBox = db->shape->mBounds;
resetWorldBox();
// If this is the server and its a client only simulation

View file

@ -489,12 +489,12 @@ bool PlayerData::preload(bool server, String &errorStr)
if (dp->sequence != -1)
getGroundInfo(si,thread,dp);
}
for (S32 b = 0; b < mShape->sequences.size(); b++)
for (S32 b = 0; b < mShape->mSequences.size(); b++)
{
if (!isTableSequence(b))
{
dp->sequence = b;
dp->name = mShape->getName(mShape->sequences[b].nameIndex);
dp->name = mShape->getName(mShape->mSequences[b].nameIndex);
dp->velocityScale = false;
getGroundInfo(si,thread,dp++);
}
@ -614,7 +614,7 @@ void PlayerData::getGroundInfo(TSShapeInstance* si, TSThread* thread,ActionAnima
dp->dir.set(0.0f, 0.0f, 0.0f);
// Death animations MUST define ground transforms, so add dummy ones if required
if (si->getShape()->sequences[dp->sequence].numGroundFrames == 0)
if (si->getShape()->mSequences[dp->sequence].numGroundFrames == 0)
si->getShape()->setSequenceGroundSpeed(dp->name, Point3F(0, 0, 0), Point3F(0, 0, 0));
}
else

View file

@ -771,7 +771,7 @@ bool Projectile::onAdd()
// Setup our bounding box
if (bool(mDataBlock->projectileShape) == true)
mObjBox = mDataBlock->projectileShape->bounds;
mObjBox = mDataBlock->projectileShape->mBounds;
else
mObjBox = Box3F(Point3F(0, 0, 0), Point3F(0, 0, 0));

View file

@ -323,9 +323,9 @@ bool ShapeBaseData::preload(bool server, String &errorStr)
// Resolve details and camera node indexes.
static const String sCollisionStr( "collision-" );
for (i = 0; i < mShape->details.size(); i++)
for (i = 0; i < mShape->mDetails.size(); i++)
{
const String &name = mShape->names[mShape->details[i].nameIndex];
const String &name = mShape->mNames[mShape->mDetails[i].nameIndex];
if (name.compare( sCollisionStr, sCollisionStr.length(), String::NoCase ) == 0)
{
@ -335,15 +335,15 @@ bool ShapeBaseData::preload(bool server, String &errorStr)
mShape->computeBounds(collisionDetails.last(), collisionBounds.last());
mShape->getAccelerator(collisionDetails.last());
if (!mShape->bounds.isContained(collisionBounds.last()))
if (!mShape->mBounds.isContained(collisionBounds.last()))
{
Con::warnf("Warning: shape %s collision detail %d (Collision-%d) bounds exceed that of shape.", shapeName, collisionDetails.size() - 1, collisionDetails.last());
collisionBounds.last() = mShape->bounds;
collisionBounds.last() = mShape->mBounds;
}
else if (collisionBounds.last().isValidBox() == false)
{
Con::errorf("Error: shape %s-collision detail %d (Collision-%d) bounds box invalid!", shapeName, collisionDetails.size() - 1, collisionDetails.last());
collisionBounds.last() = mShape->bounds;
collisionBounds.last() = mShape->mBounds;
}
// The way LOS works is that it will check to see if there is a LOS detail that matches
@ -364,9 +364,9 @@ bool ShapeBaseData::preload(bool server, String &errorStr)
// Snag any "unmatched" LOS details
static const String sLOSStr( "LOS-" );
for (i = 0; i < mShape->details.size(); i++)
for (i = 0; i < mShape->mDetails.size(); i++)
{
const String &name = mShape->names[mShape->details[i].nameIndex];
const String &name = mShape->mNames[mShape->mDetails[i].nameIndex];
if (name.compare( sLOSStr, sLOSStr.length(), String::NoCase ) == 0)
{
@ -410,7 +410,7 @@ bool ShapeBaseData::preload(bool server, String &errorStr)
damageSequence = mShape->findSequence("Damage");
//
F32 w = mShape->bounds.len_y() / 2;
F32 w = mShape->mBounds.len_y() / 2;
if (cameraMaxDist < w)
cameraMaxDist = w;
}
@ -606,7 +606,7 @@ DefineEngineMethod( ShapeBaseData, checkDeployPos, bool, ( TransformF txfm ),,
MatrixF mat = txfm.getMatrix();
Box3F objBox = object->mShape->bounds;
Box3F objBox = object->mShape->mBounds;
Point3F boxCenter = (objBox.minExtents + objBox.maxExtents) * 0.5f;
objBox.minExtents = boxCenter + (objBox.minExtents - boxCenter) * 0.9f;
objBox.maxExtents = boxCenter + (objBox.maxExtents - boxCenter) * 0.9f;
@ -1097,11 +1097,11 @@ bool ShapeBase::onNewDataBlock( GameBaseData *dptr, bool reload )
if (isClientObject())
mShapeInstance->cloneMaterialList();
mObjBox = mDataBlock->mShape->bounds;
mObjBox = mDataBlock->mShape->mBounds;
resetWorldBox();
// Set the initial mesh hidden state.
mMeshHidden.setSize( mDataBlock->mShape->objects.size() );
mMeshHidden.setSize( mDataBlock->mShape->mObjects.size() );
mMeshHidden.clear();
// Initialize the threads
@ -1126,8 +1126,8 @@ bool ShapeBase::onNewDataBlock( GameBaseData *dptr, bool reload )
AssertFatal( prevDB != NULL, "ShapeBase::onNewDataBlock - how did you have a sequence playing without a prior datablock?" );
const TSShape *prevShape = prevDB->mShape;
const TSShape::Sequence &prevSeq = prevShape->sequences[st.sequence];
const String &prevSeqName = prevShape->names[prevSeq.nameIndex];
const TSShape::Sequence &prevSeq = prevShape->mSequences[st.sequence];
const String &prevSeqName = prevShape->mNames[prevSeq.nameIndex];
st.sequence = mDataBlock->mShape->findSequence( prevSeqName );
@ -2123,7 +2123,7 @@ const char *ShapeBase::getThreadSequenceName( U32 slot )
}
// Name Index
const U32 nameIndex = getShape()->sequences[st.sequence].nameIndex;
const U32 nameIndex = getShape()->mSequences[st.sequence].nameIndex;
// Return Name.
return getShape()->getName( nameIndex );
@ -2309,7 +2309,7 @@ void ShapeBase::advanceThreads(F32 dt)
for (U32 i = 0; i < MaxScriptThreads; i++) {
Thread& st = mScriptThread[i];
if (st.thread) {
if (!mShapeInstance->getShape()->sequences[st.sequence].isCyclic() && !st.atEnd &&
if (!mShapeInstance->getShape()->mSequences[st.sequence].isCyclic() && !st.atEnd &&
( ( st.timescale > 0.f )? mShapeInstance->getPos(st.thread) >= 1.0:
mShapeInstance->getPos(st.thread) <= 0)) {
st.atEnd = true;
@ -2589,7 +2589,7 @@ void ShapeBase::_renderBoundingBox( ObjectRenderInst *ri, SceneRenderState *stat
MatrixF mat;
getRenderImageTransform( ri->objectIndex, &mat );
const Box3F &objBox = image.shapeInstance[getImageShapeIndex(image)]->getShape()->bounds;
const Box3F &objBox = image.shapeInstance[getImageShapeIndex(image)]->getShape()->mBounds;
drawer->drawCube( desc, objBox, ColorI( 255, 255, 255 ), &mat );
}
@ -3277,17 +3277,17 @@ void ShapeBaseConvex::findNodeTransform()
TSShapeInstance* si = pShapeBase->getShapeInstance();
TSShape* shape = si->getShape();
const TSShape::Detail* detail = &shape->details[dl];
const TSShape::Detail* detail = &shape->mDetails[dl];
const S32 subs = detail->subShapeNum;
const S32 start = shape->subShapeFirstObject[subs];
const S32 end = start + shape->subShapeNumObjects[subs];
const S32 start = shape->mSubShapeFirstObject[subs];
const S32 end = start + shape->mSubShapeNumObjects[subs];
// Find the first object that contains a mesh for this
// detail level. There should only be one mesh per
// collision detail level.
for (S32 i = start; i < end; i++)
{
const TSShape::Object* obj = &shape->objects[i];
const TSShape::Object* obj = &shape->mObjects[i];
if (obj->numMeshes && detail->objectDetailNum < obj->numMeshes)
{
nodeTransform = &si->mNodeTransforms[obj->nodeIndex];
@ -4857,7 +4857,7 @@ DefineEngineMethod( ShapeBase, changeMaterial, void, ( const char* mapTo, Materi
ShapeBase *clientObj = dynamic_cast< ShapeBase* > ( object->getClientObject() );
// Check the mapTo name exists for this shape
S32 matIndex = serverObj->getShape()->materialList->getMaterialNameList().find_next(String(mapTo));
S32 matIndex = serverObj->getShape()->mMaterialList->getMaterialNameList().find_next(String(mapTo));
if (matIndex < 0)
{
Con::errorf("ShapeBase::changeMaterial failed: Invalid mapTo name '%s'", mapTo);
@ -4876,19 +4876,19 @@ DefineEngineMethod( ShapeBase, changeMaterial, void, ( const char* mapTo, Materi
// Replace instances with the new material being traded in. For ShapeBase
// class we have to update the server/client objects separately so both
// represent our changes
delete serverObj->getShape()->materialList->mMatInstList[matIndex];
serverObj->getShape()->materialList->mMatInstList[matIndex] = newMat->createMatInstance();
delete serverObj->getShape()->mMaterialList->mMatInstList[matIndex];
serverObj->getShape()->mMaterialList->mMatInstList[matIndex] = newMat->createMatInstance();
if (clientObj)
{
delete clientObj->getShape()->materialList->mMatInstList[matIndex];
clientObj->getShape()->materialList->mMatInstList[matIndex] = newMat->createMatInstance();
delete clientObj->getShape()->mMaterialList->mMatInstList[matIndex];
clientObj->getShape()->mMaterialList->mMatInstList[matIndex] = newMat->createMatInstance();
}
// Finish up preparing the material instances for rendering
const GFXVertexFormat *flags = getGFXVertexFormat<GFXVertexPNTTB>();
FeatureSet features = MATMGR->getDefaultFeatures();
serverObj->getShape()->materialList->getMaterialInst(matIndex)->init( features, flags );
serverObj->getShape()->mMaterialList->getMaterialInst(matIndex)->init( features, flags );
if (clientObj)
clientObj->getShapeInstance()->mMaterialList->getMaterialInst(matIndex)->init( features, flags );
}

View file

@ -497,9 +497,9 @@ bool ShapeBaseImageData::preload(bool server, String &errorStr)
do {
MatrixF nmat;
QuatF q;
TSTransform::setMatrix(shape[i]->defaultRotations[node].getQuatF(&q),shape[i]->defaultTranslations[node],&nmat);
TSTransform::setMatrix(shape[i]->mDefaultRotations[node].getQuatF(&q),shape[i]->mDefaultTranslations[node],&nmat);
total.mul(nmat);
node = shape[i]->nodes[node].parentIndex;
node = shape[i]->mNodes[node].parentIndex;
}
while(node != -1);
total.inverse();

View file

@ -334,7 +334,7 @@ bool TSStatic::_createShape()
NetConnection::filesWereDownloaded() )
return false;
mObjBox = mShape->bounds;
mObjBox = mShape->mBounds;
resetWorldBox();
mShapeInstance = new TSShapeInstance( mShape, isClientObject() );
@ -391,7 +391,7 @@ void TSStatic::_updatePhysics()
if ( mCollisionType == Bounds )
{
MatrixF offset( true );
offset.setPosition( mShape->center );
offset.setPosition( mShape->mCenter );
colShape = PHYSICSMGR->createCollision();
colShape->addBox( getObjBox().getExtents() * 0.5f * mObjScale, offset );
}
@ -960,31 +960,31 @@ void TSStatic::buildConvex(const Box3F& box, Convex* convex)
SceneObject* TSStaticPolysoupConvex::smCurObject = NULL;
TSStaticPolysoupConvex::TSStaticPolysoupConvex()
: box( 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f ),
normal( 0.0f, 0.0f, 0.0f, 0.0f ),
idx( 0 ),
mesh( NULL )
: mBox( 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f ),
mNormal( 0.0f, 0.0f, 0.0f, 0.0f ),
mIdx( 0 ),
mMesh( NULL )
{
mType = TSPolysoupConvexType;
for ( U32 i = 0; i < 4; ++i )
{
verts[i].set( 0.0f, 0.0f, 0.0f );
mVerts[i].set( 0.0f, 0.0f, 0.0f );
}
}
Point3F TSStaticPolysoupConvex::support(const VectorF& vec) const
{
F32 bestDot = mDot( verts[0], vec );
F32 bestDot = mDot( mVerts[0], vec );
const Point3F *bestP = &verts[0];
const Point3F *bestP = &mVerts[0];
for(S32 i=1; i<4; i++)
{
F32 newD = mDot(verts[i], vec);
F32 newD = mDot(mVerts[i], vec);
if(newD > bestDot)
{
bestDot = newD;
bestP = &verts[i];
bestP = &mVerts[i];
}
}
@ -993,7 +993,7 @@ Point3F TSStaticPolysoupConvex::support(const VectorF& vec) const
Box3F TSStaticPolysoupConvex::getBoundingBox() const
{
Box3F wbox = box;
Box3F wbox = mBox;
wbox.minExtents.convolve( mObject->getScale() );
wbox.maxExtents.convolve( mObject->getScale() );
mObject->getTransform().mul(wbox);
@ -1003,7 +1003,7 @@ Box3F TSStaticPolysoupConvex::getBoundingBox() const
Box3F TSStaticPolysoupConvex::getBoundingBox(const MatrixF& mat, const Point3F& scale) const
{
AssertISV(false, "TSStaticPolysoupConvex::getBoundingBox(m,p) - Not implemented. -- XEA");
return box;
return mBox;
}
void TSStaticPolysoupConvex::getPolyList(AbstractPolyList *list)
@ -1015,11 +1015,11 @@ void TSStaticPolysoupConvex::getPolyList(AbstractPolyList *list)
list->setObject(mObject);
// Add only the original collision triangle
S32 base = list->addPoint(verts[0]);
list->addPoint(verts[2]);
list->addPoint(verts[1]);
S32 base = list->addPoint(mVerts[0]);
list->addPoint(mVerts[2]);
list->addPoint(mVerts[1]);
list->begin(0, (U32)idx ^ (uintptr_t)mesh);
list->begin(0, (U32)mIdx ^ (uintptr_t)mMesh);
list->vertex(base + 2);
list->vertex(base + 1);
list->vertex(base + 0);
@ -1035,10 +1035,10 @@ void TSStaticPolysoupConvex::getFeatures(const MatrixF& mat,const VectorF& n, Co
// For a tetrahedron this is pretty easy... first
// convert everything into world space.
Point3F tverts[4];
mat.mulP(verts[0], &tverts[0]);
mat.mulP(verts[1], &tverts[1]);
mat.mulP(verts[2], &tverts[2]);
mat.mulP(verts[3], &tverts[3]);
mat.mulP(mVerts[0], &tverts[0]);
mat.mulP(mVerts[1], &tverts[1]);
mat.mulP(mVerts[2], &tverts[2]);
mat.mulP(mVerts[3], &tverts[3]);
// points...
S32 firstVert = cf->mVertexList.size();
@ -1172,7 +1172,7 @@ DefineEngineMethod( TSStatic, changeMaterial, void, ( const char* mapTo, Materia
}
// Check the mapTo name exists for this shape
S32 matIndex = object->getShape()->materialList->getMaterialNameList().find_next(String(mapTo));
S32 matIndex = object->getShape()->mMaterialList->getMaterialNameList().find_next(String(mapTo));
if (matIndex < 0)
{
Con::errorf("TSShape::changeMaterial failed: Invalid mapTo name '%s'", mapTo);
@ -1190,13 +1190,13 @@ DefineEngineMethod( TSStatic, changeMaterial, void, ( const char* mapTo, Materia
// Replace instances with the new material being traded in. Lets make sure that we only
// target the specific targets per inst, this is actually doing more than we thought
delete object->getShape()->materialList->mMatInstList[matIndex];
object->getShape()->materialList->mMatInstList[matIndex] = newMat->createMatInstance();
delete object->getShape()->mMaterialList->mMatInstList[matIndex];
object->getShape()->mMaterialList->mMatInstList[matIndex] = newMat->createMatInstance();
// Finish up preparing the material instances for rendering
const GFXVertexFormat *flags = getGFXVertexFormat<GFXVertexPNTTB>();
FeatureSet features = MATMGR->getDefaultFeatures();
object->getShape()->materialList->getMaterialInst(matIndex)->init( features, flags );
object->getShape()->mMaterialList->getMaterialInst(matIndex)->init( features, flags );
}
DefineEngineMethod( TSStatic, getModelFile, const char *, (),,

View file

@ -56,11 +56,11 @@ public:
~TSStaticPolysoupConvex() {};
public:
Box3F box;
Point3F verts[4];
PlaneF normal;
S32 idx;
TSMesh *mesh;
Box3F mBox;
Point3F mVerts[4];
PlaneF mNormal;
S32 mIdx;
TSMesh *mMesh;
static SceneObject* smCurObject;

View file

@ -823,8 +823,8 @@ void TurretShape::_updateNodes(const Point3F& rot)
if (node != -1)
{
MatrixF* mat = &mShapeInstance->mNodeTransforms[node];
Point3F defaultPos = mShapeInstance->getShape()->defaultTranslations[node];
Quat16 defaultRot = mShapeInstance->getShape()->defaultRotations[node];
Point3F defaultPos = mShapeInstance->getShape()->mDefaultTranslations[node];
Quat16 defaultRot = mShapeInstance->getShape()->mDefaultRotations[node];
QuatF qrot(zRot);
qrot *= defaultRot.getQuatF();
@ -837,8 +837,8 @@ void TurretShape::_updateNodes(const Point3F& rot)
if (node != -1)
{
MatrixF* mat = &mShapeInstance->mNodeTransforms[node];
Point3F defaultPos = mShapeInstance->getShape()->defaultTranslations[node];
Quat16 defaultRot = mShapeInstance->getShape()->defaultRotations[node];
Point3F defaultPos = mShapeInstance->getShape()->mDefaultTranslations[node];
Quat16 defaultRot = mShapeInstance->getShape()->mDefaultRotations[node];
QuatF qrot(xRot);
qrot *= defaultRot.getQuatF();
@ -853,8 +853,8 @@ void TurretShape::_updateNodes(const Point3F& rot)
if (node != -1)
{
MatrixF* mat = &mShapeInstance->mNodeTransforms[node];
Point3F defaultPos = mShapeInstance->getShape()->defaultTranslations[node];
Quat16 defaultRot = mShapeInstance->getShape()->defaultRotations[node];
Point3F defaultPos = mShapeInstance->getShape()->mDefaultTranslations[node];
Quat16 defaultRot = mShapeInstance->getShape()->mDefaultRotations[node];
QuatF qrot(xRot);
qrot *= defaultRot.getQuatF();
@ -866,8 +866,8 @@ void TurretShape::_updateNodes(const Point3F& rot)
if (node != -1)
{
MatrixF* mat = &mShapeInstance->mNodeTransforms[node];
Point3F defaultPos = mShapeInstance->getShape()->defaultTranslations[node];
Quat16 defaultRot = mShapeInstance->getShape()->defaultRotations[node];
Point3F defaultPos = mShapeInstance->getShape()->mDefaultTranslations[node];
Quat16 defaultRot = mShapeInstance->getShape()->mDefaultRotations[node];
QuatF qrot(zRot);
qrot *= defaultRot.getQuatF();

View file

@ -111,7 +111,7 @@ bool WheeledVehicleTire::preload(bool server, String &errorStr)
// Determinw wheel radius from the shape's bounding box.
// The tire should be built with it's hub axis along the
// object's Y axis.
radius = shape->bounds.len_z() / 2;
radius = shape->mBounds.len_z() / 2;
}
return true;
@ -399,8 +399,8 @@ bool WheeledVehicleData::preload(bool server, String &errorStr)
if (collisionDetails[0] != -1) {
MatrixF imat(1);
SphereF sphere;
sphere.center = mShape->center;
sphere.radius = mShape->radius;
sphere.center = mShape->mCenter;
sphere.radius = mShape->mRadius;
PlaneExtractorPolyList polyList;
polyList.mPlaneList = &rigidBody.mPlaneList;
polyList.setTransform(&imat, Point3F(1,1,1));

View file

@ -41,21 +41,21 @@ ConsoleParser *CodeBlock::smCurrentParser = NULL;
CodeBlock::CodeBlock()
{
globalStrings = NULL;
functionStrings = NULL;
functionStringsMaxLen = 0;
globalStringsMaxLen = 0;
globalFloats = NULL;
functionFloats = NULL;
lineBreakPairs = NULL;
breakList = NULL;
breakListSize = 0;
mGlobalStrings = NULL;
mFunctionStrings = NULL;
mFunctionStringsMaxLen = 0;
mGlobalStringsMaxLen = 0;
mGlobalFloats = NULL;
mFunctionFloats = NULL;
mLineBreakPairs = NULL;
mBreakList = NULL;
mBreakListSize = 0;
refCount = 0;
code = NULL;
name = NULL;
fullPath = NULL;
modPath = NULL;
mRefCount = 0;
mCode = NULL;
mName = NULL;
mFullPath = NULL;
mModPath = NULL;
}
CodeBlock::~CodeBlock()
@ -63,18 +63,18 @@ CodeBlock::~CodeBlock()
// Make sure we aren't lingering in the current code block...
AssertFatal(smCurrentCodeBlock != this, "CodeBlock::~CodeBlock - Caught lingering in smCurrentCodeBlock!")
if(name)
if(mName)
removeFromCodeList();
delete[] const_cast<char*>(globalStrings);
delete[] const_cast<char*>(functionStrings);
delete[] const_cast<char*>(mGlobalStrings);
delete[] const_cast<char*>(mFunctionStrings);
functionStringsMaxLen = 0;
globalStringsMaxLen = 0;
mFunctionStringsMaxLen = 0;
mGlobalStringsMaxLen = 0;
delete[] globalFloats;
delete[] functionFloats;
delete[] code;
delete[] breakList;
delete[] mGlobalFloats;
delete[] mFunctionFloats;
delete[] mCode;
delete[] mBreakList;
}
//-------------------------------------------------------------------------
@ -82,7 +82,7 @@ CodeBlock::~CodeBlock()
StringTableEntry CodeBlock::getCurrentCodeBlockName()
{
if (CodeBlock::getCurrentBlock())
return CodeBlock::getCurrentBlock()->name;
return CodeBlock::getCurrentBlock()->mName;
else
return NULL;
}
@ -90,7 +90,7 @@ StringTableEntry CodeBlock::getCurrentCodeBlockName()
StringTableEntry CodeBlock::getCurrentCodeBlockFullPath()
{
if (CodeBlock::getCurrentBlock())
return CodeBlock::getCurrentBlock()->fullPath;
return CodeBlock::getCurrentBlock()->mFullPath;
else
return NULL;
}
@ -98,15 +98,15 @@ StringTableEntry CodeBlock::getCurrentCodeBlockFullPath()
StringTableEntry CodeBlock::getCurrentCodeBlockModName()
{
if (CodeBlock::getCurrentBlock())
return CodeBlock::getCurrentBlock()->modPath;
return CodeBlock::getCurrentBlock()->mModPath;
else
return NULL;
}
CodeBlock *CodeBlock::find(StringTableEntry name)
{
for(CodeBlock *walk = CodeBlock::getCodeBlockList(); walk; walk = walk->nextFile)
if(walk->name == name)
for(CodeBlock *walk = CodeBlock::getCodeBlockList(); walk; walk = walk->mNextFile)
if(walk->mName == name)
return walk;
return NULL;
}
@ -116,39 +116,39 @@ CodeBlock *CodeBlock::find(StringTableEntry name)
void CodeBlock::addToCodeList()
{
// remove any code blocks with my name
for(CodeBlock **walk = &smCodeBlockList; *walk;walk = &((*walk)->nextFile))
for(CodeBlock **walk = &smCodeBlockList; *walk;walk = &((*walk)->mNextFile))
{
if((*walk)->name == name)
if((*walk)->mName == mName)
{
*walk = (*walk)->nextFile;
*walk = (*walk)->mNextFile;
break;
}
}
nextFile = smCodeBlockList;
mNextFile = smCodeBlockList;
smCodeBlockList = this;
}
void CodeBlock::clearAllBreaks()
{
if(!lineBreakPairs)
if(!mLineBreakPairs)
return;
for(U32 i = 0; i < lineBreakPairCount; i++)
for(U32 i = 0; i < mLineBreakPairCount; i++)
{
U32 *p = lineBreakPairs + i * 2;
code[p[1]] = p[0] & 0xFF;
U32 *p = mLineBreakPairs + i * 2;
mCode[p[1]] = p[0] & 0xFF;
}
}
void CodeBlock::clearBreakpoint(U32 lineNumber)
{
if(!lineBreakPairs)
if(!mLineBreakPairs)
return;
for(U32 i = 0; i < lineBreakPairCount; i++)
for(U32 i = 0; i < mLineBreakPairCount; i++)
{
U32 *p = lineBreakPairs + i * 2;
U32 *p = mLineBreakPairs + i * 2;
if((p[0] >> 8) == lineNumber)
{
code[p[1]] = p[0] & 0xFF;
mCode[p[1]] = p[0] & 0xFF;
return;
}
}
@ -156,26 +156,26 @@ void CodeBlock::clearBreakpoint(U32 lineNumber)
void CodeBlock::setAllBreaks()
{
if(!lineBreakPairs)
if(!mLineBreakPairs)
return;
for(U32 i = 0; i < lineBreakPairCount; i++)
for(U32 i = 0; i < mLineBreakPairCount; i++)
{
U32 *p = lineBreakPairs + i * 2;
code[p[1]] = OP_BREAK;
U32 *p = mLineBreakPairs + i * 2;
mCode[p[1]] = OP_BREAK;
}
}
bool CodeBlock::setBreakpoint(U32 lineNumber)
{
if(!lineBreakPairs)
if(!mLineBreakPairs)
return false;
for(U32 i = 0; i < lineBreakPairCount; i++)
for(U32 i = 0; i < mLineBreakPairCount; i++)
{
U32 *p = lineBreakPairs + i * 2;
U32 *p = mLineBreakPairs + i * 2;
if((p[0] >> 8) == lineNumber)
{
code[p[1]] = OP_BREAK;
mCode[p[1]] = OP_BREAK;
return true;
}
}
@ -185,12 +185,12 @@ bool CodeBlock::setBreakpoint(U32 lineNumber)
U32 CodeBlock::findFirstBreakLine(U32 lineNumber)
{
if(!lineBreakPairs)
if(!mLineBreakPairs)
return 0;
for(U32 i = 0; i < lineBreakPairCount; i++)
for(U32 i = 0; i < mLineBreakPairCount; i++)
{
U32 *p = lineBreakPairs + i * 2;
U32 *p = mLineBreakPairs + i * 2;
U32 line = (p[0] >> 8);
if( lineNumber <= line )
@ -209,11 +209,11 @@ struct LinePair
void CodeBlock::findBreakLine(U32 ip, U32 &line, U32 &instruction)
{
U32 min = 0;
U32 max = lineBreakPairCount - 1;
LinePair *p = (LinePair *) lineBreakPairs;
U32 max = mLineBreakPairCount - 1;
LinePair *p = (LinePair *) mLineBreakPairs;
U32 found;
if(!lineBreakPairCount || p[min].ip > ip || p[max].ip < ip)
if(!mLineBreakPairCount || p[min].ip > ip || p[max].ip < ip)
{
line = 0;
instruction = OP_INVALID;
@ -254,17 +254,17 @@ const char *CodeBlock::getFileLine(U32 ip)
U32 line, inst;
findBreakLine(ip, line, inst);
dSprintf(nameBuffer, sizeof(nameBuffer), "%s (%d)", name ? name : "<input>", line);
dSprintf(nameBuffer, sizeof(nameBuffer), "%s (%d)", mName ? mName : "<input>", line);
return nameBuffer;
}
void CodeBlock::removeFromCodeList()
{
for(CodeBlock **walk = &smCodeBlockList; *walk; walk = &((*walk)->nextFile))
for(CodeBlock **walk = &smCodeBlockList; *walk; walk = &((*walk)->mNextFile))
{
if(*walk == this)
{
*walk = nextFile;
*walk = mNextFile;
// clear out all breakpoints
clearAllBreaks();
@ -285,9 +285,9 @@ void CodeBlock::calcBreakList()
S32 line = -1;
U32 seqCount = 0;
U32 i;
for(i = 0; i < lineBreakPairCount; i++)
for(i = 0; i < mLineBreakPairCount; i++)
{
U32 lineNumber = lineBreakPairs[i * 2];
U32 lineNumber = mLineBreakPairs[i * 2];
if(lineNumber == U32(line + 1))
seqCount++;
else
@ -302,23 +302,23 @@ void CodeBlock::calcBreakList()
if(seqCount)
size++;
breakList = new U32[size];
breakListSize = size;
mBreakList = new U32[size];
mBreakListSize = size;
line = -1;
seqCount = 0;
size = 0;
for(i = 0; i < lineBreakPairCount; i++)
for(i = 0; i < mLineBreakPairCount; i++)
{
U32 lineNumber = lineBreakPairs[i * 2];
U32 lineNumber = mLineBreakPairs[i * 2];
if(lineNumber == U32(line + 1))
seqCount++;
else
{
if(seqCount)
breakList[size++] = seqCount;
breakList[size++] = lineNumber - getMax(0, line) - 1;
mBreakList[size++] = seqCount;
mBreakList[size++] = lineNumber - getMax(0, line) - 1;
seqCount = 1;
}
@ -326,12 +326,12 @@ void CodeBlock::calcBreakList()
}
if(seqCount)
breakList[size++] = seqCount;
mBreakList[size++] = seqCount;
for(i = 0; i < lineBreakPairCount; i++)
for(i = 0; i < mLineBreakPairCount; i++)
{
U32 *p = lineBreakPairs + i * 2;
p[0] = (p[0] << 8) | code[p[1]];
U32 *p = mLineBreakPairs + i * 2;
p[0] = (p[0] << 8) | mCode[p[1]];
}
// Let the telnet debugger know that this code
@ -346,27 +346,27 @@ bool CodeBlock::read(StringTableEntry fileName, Stream &st)
const StringTableEntry exePath = Platform::getMainDotCsDir();
const StringTableEntry cwd = Platform::getCurrentDirectory();
name = fileName;
mName = fileName;
if(fileName)
{
fullPath = NULL;
mFullPath = NULL;
if(Platform::isFullPath(fileName))
fullPath = fileName;
mFullPath = fileName;
if(dStrnicmp(exePath, fileName, dStrlen(exePath)) == 0)
name = StringTable->insert(fileName + dStrlen(exePath) + 1, true);
mName = StringTable->insert(fileName + dStrlen(exePath) + 1, true);
else if(dStrnicmp(cwd, fileName, dStrlen(cwd)) == 0)
name = StringTable->insert(fileName + dStrlen(cwd) + 1, true);
mName = StringTable->insert(fileName + dStrlen(cwd) + 1, true);
if(fullPath == NULL)
if(mFullPath == NULL)
{
char buf[1024];
fullPath = StringTable->insert(Platform::makeFullPathName(fileName, buf, sizeof(buf)), true);
mFullPath = StringTable->insert(Platform::makeFullPathName(fileName, buf, sizeof(buf)), true);
}
modPath = Con::getModNameFromPath(fileName);
mModPath = Con::getModNameFromPath(fileName);
}
//
@ -376,53 +376,53 @@ bool CodeBlock::read(StringTableEntry fileName, Stream &st)
st.read(&size);
if(size)
{
globalStrings = new char[size];
globalStringsMaxLen = size;
st.read(size, globalStrings);
mGlobalStrings = new char[size];
mGlobalStringsMaxLen = size;
st.read(size, mGlobalStrings);
}
globalSize = size;
st.read(&size);
if(size)
{
functionStrings = new char[size];
functionStringsMaxLen = size;
st.read(size, functionStrings);
mFunctionStrings = new char[size];
mFunctionStringsMaxLen = size;
st.read(size, mFunctionStrings);
}
st.read(&size);
if(size)
{
globalFloats = new F64[size];
mGlobalFloats = new F64[size];
for(U32 i = 0; i < size; i++)
st.read(&globalFloats[i]);
st.read(&mGlobalFloats[i]);
}
st.read(&size);
if(size)
{
functionFloats = new F64[size];
mFunctionFloats = new F64[size];
for(U32 i = 0; i < size; i++)
st.read(&functionFloats[i]);
st.read(&mFunctionFloats[i]);
}
U32 codeLength;
st.read(&codeLength);
st.read(&lineBreakPairCount);
st.read(&mLineBreakPairCount);
U32 totSize = codeLength + lineBreakPairCount * 2;
code = new U32[totSize];
U32 totSize = codeLength + mLineBreakPairCount * 2;
mCode = new U32[totSize];
for(i = 0; i < codeLength; i++)
{
U8 b;
st.read(&b);
if(b == 0xFF)
st.read(&code[i]);
st.read(&mCode[i]);
else
code[i] = b;
mCode[i] = b;
}
for(i = codeLength; i < totSize; i++)
st.read(&code[i]);
st.read(&mCode[i]);
lineBreakPairs = code + codeLength;
mLineBreakPairs = mCode + codeLength;
// StringTable-ize our identifiers.
U32 identCount;
@ -433,7 +433,7 @@ bool CodeBlock::read(StringTableEntry fileName, Stream &st)
st.read(&offset);
StringTableEntry ste;
if(offset < globalSize)
ste = StringTable->insert(globalStrings + offset);
ste = StringTable->insert(mGlobalStrings + offset);
else
ste = StringTable->insert("");
U32 count;
@ -442,11 +442,11 @@ bool CodeBlock::read(StringTableEntry fileName, Stream &st)
{
U32 ip;
st.read(&ip);
code[ip] = *((U32 *) &ste);
mCode[ip] = *((U32 *) &ste);
}
}
if(lineBreakPairCount)
if(mLineBreakPairCount)
calcBreakList();
return true;
@ -519,14 +519,14 @@ bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, con
}
else
{
codeSize = 1;
mCodeSize = 1;
lastIp = 0;
}
codeStream.emit(OP_RETURN);
codeStream.emitCodeStream(&codeSize, &code, &lineBreakPairs);
codeStream.emitCodeStream(&mCodeSize, &mCode, &mLineBreakPairs);
lineBreakPairCount = codeStream.getNumLineBreaks();
mLineBreakPairCount = codeStream.getNumLineBreaks();
// Write string table data...
getGlobalStringTable().write(st);
@ -536,29 +536,29 @@ bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, con
getGlobalFloatTable().write(st);
getFunctionFloatTable().write(st);
if(lastIp != codeSize)
if(lastIp != mCodeSize)
Con::errorf(ConsoleLogEntry::General, "CodeBlock::compile - precompile size mismatch, a precompile/compile function pair is probably mismatched.");
U32 totSize = codeSize + codeStream.getNumLineBreaks() * 2;
st.write(codeSize);
st.write(lineBreakPairCount);
U32 totSize = mCodeSize + codeStream.getNumLineBreaks() * 2;
st.write(mCodeSize);
st.write(mLineBreakPairCount);
// Write out our bytecode, doing a bit of compression for low numbers.
U32 i;
for(i = 0; i < codeSize; i++)
for(i = 0; i < mCodeSize; i++)
{
if(code[i] < 0xFF)
st.write(U8(code[i]));
if(mCode[i] < 0xFF)
st.write(U8(mCode[i]));
else
{
st.write(U8(0xFF));
st.write(code[i]);
st.write(mCode[i]);
}
}
// Write the break info...
for(i = codeSize; i < totSize; i++)
st.write(code[i]);
for(i = mCodeSize; i < totSize; i++)
st.write(mCode[i]);
getIdentTable().write(st);
@ -581,33 +581,33 @@ ConsoleValueRef CodeBlock::compileExec(StringTableEntry fileName, const char *in
STEtoCode = evalSTEtoCode;
consoleAllocReset();
name = fileName;
mName = fileName;
if(fileName)
{
const StringTableEntry exePath = Platform::getMainDotCsDir();
const StringTableEntry cwd = Platform::getCurrentDirectory();
fullPath = NULL;
mFullPath = NULL;
if(Platform::isFullPath(fileName))
fullPath = fileName;
mFullPath = fileName;
if(dStrnicmp(exePath, fileName, dStrlen(exePath)) == 0)
name = StringTable->insert(fileName + dStrlen(exePath) + 1, true);
mName = StringTable->insert(fileName + dStrlen(exePath) + 1, true);
else if(dStrnicmp(cwd, fileName, dStrlen(cwd)) == 0)
name = StringTable->insert(fileName + dStrlen(cwd) + 1, true);
mName = StringTable->insert(fileName + dStrlen(cwd) + 1, true);
if(fullPath == NULL)
if(mFullPath == NULL)
{
char buf[1024];
fullPath = StringTable->insert(Platform::makeFullPathName(fileName, buf, sizeof(buf)), true);
mFullPath = StringTable->insert(Platform::makeFullPathName(fileName, buf, sizeof(buf)), true);
}
modPath = Con::getModNameFromPath(fileName);
mModPath = Con::getModNameFromPath(fileName);
}
if(name)
if(mName)
addToCodeList();
gStatementList = NULL;
@ -645,29 +645,29 @@ ConsoleValueRef CodeBlock::compileExec(StringTableEntry fileName, const char *in
CodeStream codeStream;
U32 lastIp = compileBlock(gStatementList, codeStream, 0);
lineBreakPairCount = codeStream.getNumLineBreaks();
mLineBreakPairCount = codeStream.getNumLineBreaks();
globalStrings = getGlobalStringTable().build();
globalStringsMaxLen = getGlobalStringTable().totalLen;
mGlobalStrings = getGlobalStringTable().build();
mGlobalStringsMaxLen = getGlobalStringTable().totalLen;
functionStrings = getFunctionStringTable().build();
functionStringsMaxLen = getFunctionStringTable().totalLen;
mFunctionStrings = getFunctionStringTable().build();
mFunctionStringsMaxLen = getFunctionStringTable().totalLen;
globalFloats = getGlobalFloatTable().build();
functionFloats = getFunctionFloatTable().build();
mGlobalFloats = getGlobalFloatTable().build();
mFunctionFloats = getFunctionFloatTable().build();
codeStream.emit(OP_RETURN);
codeStream.emitCodeStream(&codeSize, &code, &lineBreakPairs);
codeStream.emitCodeStream(&mCodeSize, &mCode, &mLineBreakPairs);
//dumpInstructions(0, false);
consoleAllocReset();
if(lineBreakPairCount && fileName)
if(mLineBreakPairCount && fileName)
calcBreakList();
if(lastIp+1 != codeSize)
Con::warnf(ConsoleLogEntry::General, "precompile size mismatch, precompile: %d compile: %d", codeSize, lastIp);
if(lastIp+1 != mCodeSize)
Con::warnf(ConsoleLogEntry::General, "precompile size mismatch, precompile: %d compile: %d", mCodeSize, lastIp);
return exec(0, fileName, NULL, 0, 0, noCalls, NULL, setFrame);
}
@ -676,13 +676,13 @@ ConsoleValueRef CodeBlock::compileExec(StringTableEntry fileName, const char *in
void CodeBlock::incRefCount()
{
refCount++;
mRefCount++;
}
void CodeBlock::decRefCount()
{
refCount--;
if(!refCount)
mRefCount--;
if(!mRefCount)
delete this;
}
@ -692,10 +692,10 @@ String CodeBlock::getFunctionArgs( U32 ip )
{
StringBuilder str;
U32 fnArgc = code[ ip + 5 ];
U32 fnArgc = mCode[ ip + 5 ];
for( U32 i = 0; i < fnArgc; ++ i )
{
StringTableEntry var = CodeToSTE(code, ip + (i*2) + 6);
StringTableEntry var = CodeToSTE(mCode, ip + (i*2) + 6);
if( i != 0 )
str.append( ", " );
@ -720,24 +720,24 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
smInFunction = false;
U32 endFuncIp = 0;
while( ip < codeSize )
while( ip < mCodeSize )
{
if (ip > endFuncIp)
{
smInFunction = false;
}
switch( code[ ip ++ ] )
switch( mCode[ ip ++ ] )
{
case OP_FUNC_DECL:
{
StringTableEntry fnName = CodeToSTE(code, ip);
StringTableEntry fnNamespace = CodeToSTE(code, ip+2);
StringTableEntry fnPackage = CodeToSTE(code, ip+4);
bool hasBody = bool(code[ip+6]);
U32 newIp = code[ ip + 7 ];
U32 argc = code[ ip + 8 ];
StringTableEntry fnName = CodeToSTE(mCode, ip);
StringTableEntry fnNamespace = CodeToSTE(mCode, ip+2);
StringTableEntry fnPackage = CodeToSTE(mCode, ip+4);
bool hasBody = bool(mCode[ip+6]);
U32 newIp = mCode[ ip + 7 ];
U32 argc = mCode[ ip + 8 ];
endFuncIp = newIp;
Con::printf( "%i: OP_FUNC_DECL name=%s nspace=%s package=%s hasbody=%i newip=%i argc=%i",
@ -752,12 +752,12 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_CREATE_OBJECT:
{
StringTableEntry objParent = CodeToSTE(code, ip);
bool isDataBlock = code[ip + 2];
bool isInternal = code[ip + 3];
bool isSingleton = code[ip + 4];
U32 lineNumber = code[ip + 5];
U32 failJump = code[ip + 6];
StringTableEntry objParent = CodeToSTE(mCode, ip);
bool isDataBlock = mCode[ip + 2];
bool isInternal = mCode[ip + 3];
bool isSingleton = mCode[ip + 4];
U32 lineNumber = mCode[ip + 5];
U32 failJump = mCode[ip + 6];
Con::printf( "%i: OP_CREATE_OBJECT objParent=%s isDataBlock=%i isInternal=%i isSingleton=%i lineNumber=%i failJump=%i",
ip - 1, objParent, isDataBlock, isInternal, isSingleton, lineNumber, failJump );
@ -768,14 +768,14 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_ADD_OBJECT:
{
bool placeAtRoot = code[ip++];
bool placeAtRoot = mCode[ip++];
Con::printf( "%i: OP_ADD_OBJECT placeAtRoot=%i", ip - 1, placeAtRoot );
break;
}
case OP_END_OBJECT:
{
bool placeAtRoot = code[ip++];
bool placeAtRoot = mCode[ip++];
Con::printf( "%i: OP_END_OBJECT placeAtRoot=%i", ip - 1, placeAtRoot );
break;
}
@ -788,49 +788,49 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_JMPIFFNOT:
{
Con::printf( "%i: OP_JMPIFFNOT ip=%i", ip - 1, code[ ip ] );
Con::printf( "%i: OP_JMPIFFNOT ip=%i", ip - 1, mCode[ ip ] );
++ ip;
break;
}
case OP_JMPIFNOT:
{
Con::printf( "%i: OP_JMPIFNOT ip=%i", ip - 1, code[ ip ] );
Con::printf( "%i: OP_JMPIFNOT ip=%i", ip - 1, mCode[ ip ] );
++ ip;
break;
}
case OP_JMPIFF:
{
Con::printf( "%i: OP_JMPIFF ip=%i", ip - 1, code[ ip ] );
Con::printf( "%i: OP_JMPIFF ip=%i", ip - 1, mCode[ ip ] );
++ ip;
break;
}
case OP_JMPIF:
{
Con::printf( "%i: OP_JMPIF ip=%i", ip - 1, code[ ip ] );
Con::printf( "%i: OP_JMPIF ip=%i", ip - 1, mCode[ ip ] );
++ ip;
break;
}
case OP_JMPIFNOT_NP:
{
Con::printf( "%i: OP_JMPIFNOT_NP ip=%i", ip - 1, code[ ip ] );
Con::printf( "%i: OP_JMPIFNOT_NP ip=%i", ip - 1, mCode[ ip ] );
++ ip;
break;
}
case OP_JMPIF_NP:
{
Con::printf( "%i: OP_JMPIF_NP ip=%i", ip - 1, code[ ip ] );
Con::printf( "%i: OP_JMPIF_NP ip=%i", ip - 1, mCode[ ip ] );
++ ip;
break;
}
case OP_JMP:
{
Con::printf( "%i: OP_JMP ip=%i", ip - 1, code[ ip ] );
Con::printf( "%i: OP_JMP ip=%i", ip - 1, mCode[ ip ] );
++ ip;
break;
}
@ -1009,7 +1009,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_SETCURVAR:
{
StringTableEntry var = CodeToSTE(code, ip);
StringTableEntry var = CodeToSTE(mCode, ip);
Con::printf( "%i: OP_SETCURVAR var=%s", ip - 1, var );
ip += 2;
@ -1018,7 +1018,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_SETCURVAR_CREATE:
{
StringTableEntry var = CodeToSTE(code, ip);
StringTableEntry var = CodeToSTE(mCode, ip);
Con::printf( "%i: OP_SETCURVAR_CREATE var=%s", ip - 1, var );
ip += 2;
@ -1106,7 +1106,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_SETCURFIELD:
{
StringTableEntry curField = CodeToSTE(code, ip);
StringTableEntry curField = CodeToSTE(mCode, ip);
Con::printf( "%i: OP_SETCURFIELD field=%s", ip - 1, curField );
ip += 2;
break;
@ -1120,7 +1120,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_SETCURFIELD_TYPE:
{
U32 type = code[ ip ];
U32 type = mCode[ ip ];
Con::printf( "%i: OP_SETCURFIELD_TYPE type=%i", ip - 1, type );
++ ip;
break;
@ -1224,7 +1224,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_LOADIMMED_UINT:
{
U32 val = code[ ip ];
U32 val = mCode[ ip ];
Con::printf( "%i: OP_LOADIMMED_UINT val=%i", ip - 1, val );
++ ip;
break;
@ -1232,7 +1232,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_LOADIMMED_FLT:
{
F64 val = (smInFunction ? functionFloats : globalFloats)[ code[ ip ] ];
F64 val = (smInFunction ? mFunctionFloats : mGlobalFloats)[ mCode[ ip ] ];
Con::printf( "%i: OP_LOADIMMED_FLT val=%f", ip - 1, val );
++ ip;
break;
@ -1240,7 +1240,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_TAG_TO_STR:
{
const char* str = (smInFunction ? functionStrings : globalStrings) + code[ ip ];
const char* str = (smInFunction ? mFunctionStrings : mGlobalStrings) + mCode[ ip ];
Con::printf( "%i: OP_TAG_TO_STR str=%s", ip - 1, str );
++ ip;
break;
@ -1248,7 +1248,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_LOADIMMED_STR:
{
const char* str = (smInFunction ? functionStrings : globalStrings) + code[ ip ];
const char* str = (smInFunction ? mFunctionStrings : mGlobalStrings) + mCode[ ip ];
Con::printf( "%i: OP_LOADIMMED_STR str=%s", ip - 1, str );
++ ip;
break;
@ -1256,7 +1256,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_DOCBLOCK_STR:
{
const char* str = (smInFunction ? functionStrings : globalStrings) + code[ ip ];
const char* str = (smInFunction ? mFunctionStrings : mGlobalStrings) + mCode[ ip ];
Con::printf( "%i: OP_DOCBLOCK_STR str=%s", ip - 1, str );
++ ip;
break;
@ -1264,7 +1264,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_LOADIMMED_IDENT:
{
StringTableEntry str = CodeToSTE(code, ip);
StringTableEntry str = CodeToSTE(mCode, ip);
Con::printf( "%i: OP_LOADIMMED_IDENT str=%s", ip - 1, str );
ip += 2;
break;
@ -1272,9 +1272,9 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_CALLFUNC_RESOLVE:
{
StringTableEntry fnNamespace = CodeToSTE(code, ip+2);
StringTableEntry fnName = CodeToSTE(code, ip);
U32 callType = code[ip+2];
StringTableEntry fnNamespace = CodeToSTE(mCode, ip+2);
StringTableEntry fnName = CodeToSTE(mCode, ip);
U32 callType = mCode[ip+2];
Con::printf( "%i: OP_CALLFUNC_RESOLVE name=%s nspace=%s callType=%s", ip - 1, fnName, fnNamespace,
callType == FuncCallExprNode::FunctionCall ? "FunctionCall"
@ -1286,9 +1286,9 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_CALLFUNC:
{
StringTableEntry fnNamespace = CodeToSTE(code, ip+2);
StringTableEntry fnName = CodeToSTE(code, ip);
U32 callType = code[ip+4];
StringTableEntry fnNamespace = CodeToSTE(mCode, ip+2);
StringTableEntry fnName = CodeToSTE(mCode, ip);
U32 callType = mCode[ip+4];
Con::printf( "%i: OP_CALLFUNC name=%s nspace=%s callType=%s", ip - 1, fnName, fnNamespace,
callType == FuncCallExprNode::FunctionCall ? "FunctionCall"
@ -1306,7 +1306,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_ADVANCE_STR_APPENDCHAR:
{
char ch = code[ ip ];
char ch = mCode[ ip ];
Con::printf( "%i: OP_ADVANCE_STR_APPENDCHAR char=%c", ip - 1, ch );
++ ip;
break;
@ -1374,7 +1374,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_ASSERT:
{
const char* message = (smInFunction ? functionStrings : globalStrings) + code[ ip ];
const char* message = (smInFunction ? mFunctionStrings : mGlobalStrings) + mCode[ ip ];
Con::printf( "%i: OP_ASSERT message=%s", ip - 1, message );
++ ip;
break;
@ -1388,8 +1388,8 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_ITER_BEGIN:
{
StringTableEntry varName = CodeToSTE(code, ip);
U32 failIp = code[ ip + 2 ];
StringTableEntry varName = CodeToSTE(mCode, ip);
U32 failIp = mCode[ ip + 2 ];
Con::printf( "%i: OP_ITER_BEGIN varName=%s failIp=%i", ip - 1, varName, failIp );
@ -1399,8 +1399,8 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_ITER_BEGIN_STR:
{
StringTableEntry varName = CodeToSTE(code, ip);
U32 failIp = code[ ip + 2 ];
StringTableEntry varName = CodeToSTE(mCode, ip);
U32 failIp = mCode[ ip + 2 ];
Con::printf( "%i: OP_ITER_BEGIN varName=%s failIp=%i", ip - 1, varName, failIp );
@ -1410,7 +1410,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_ITER:
{
U32 breakIp = code[ ip ];
U32 breakIp = mCode[ ip ];
Con::printf( "%i: OP_ITER breakIp=%i", ip - 1, breakIp );

View file

@ -61,28 +61,28 @@ public:
CodeBlock();
~CodeBlock();
StringTableEntry name;
StringTableEntry fullPath;
StringTableEntry modPath;
StringTableEntry mName;
StringTableEntry mFullPath;
StringTableEntry mModPath;
char *globalStrings;
char *functionStrings;
char *mGlobalStrings;
char *mFunctionStrings;
U32 functionStringsMaxLen;
U32 globalStringsMaxLen;
U32 mFunctionStringsMaxLen;
U32 mGlobalStringsMaxLen;
F64 *globalFloats;
F64 *functionFloats;
F64 *mGlobalFloats;
F64 *mFunctionFloats;
U32 codeSize;
U32 *code;
U32 mCodeSize;
U32 *mCode;
U32 refCount;
U32 lineBreakPairCount;
U32 *lineBreakPairs;
U32 breakListSize;
U32 *breakList;
CodeBlock *nextFile;
U32 mRefCount;
U32 mLineBreakPairCount;
U32 *mLineBreakPairs;
U32 mBreakListSize;
U32 *mBreakList;
CodeBlock *mNextFile;
void addToCodeList();
void removeFromCodeList();

View file

@ -457,8 +457,8 @@ ConsoleValueRef CodeBlock::exec(U32 ip, const char *functionName, Namespace *thi
if(argv)
{
// assume this points into a function decl:
U32 fnArgc = code[ip + 2 + 6];
thisFunctionName = CodeToSTE(code, ip);
U32 fnArgc = mCode[ip + 2 + 6];
thisFunctionName = CodeToSTE(mCode, ip);
S32 wantedArgc = getMin(argc-1, fnArgc); // argv[0] is func name
if(gEvalState.traceOn)
{
@ -494,7 +494,7 @@ ConsoleValueRef CodeBlock::exec(U32 ip, const char *functionName, Namespace *thi
for(i = 0; i < wantedArgc; i++)
{
StringTableEntry var = CodeToSTE(code, ip + (2 + 6 + 1) + (i * 2));
StringTableEntry var = CodeToSTE(mCode, ip + (2 + 6 + 1) + (i * 2));
gEvalState.setCurVarNameCreate(var);
ConsoleValueRef ref = argv[i+1];
@ -519,15 +519,15 @@ ConsoleValueRef CodeBlock::exec(U32 ip, const char *functionName, Namespace *thi
}
ip = ip + (fnArgc * 2) + (2 + 6 + 1);
curFloatTable = functionFloats;
curStringTable = functionStrings;
curStringTableLen = functionStringsMaxLen;
curFloatTable = mFunctionFloats;
curStringTable = mFunctionStrings;
curStringTableLen = mFunctionStringsMaxLen;
}
else
{
curFloatTable = globalFloats;
curStringTable = globalStrings;
curStringTableLen = globalStringsMaxLen;
curFloatTable = mGlobalFloats;
curStringTable = mGlobalStrings;
curStringTableLen = mGlobalStringsMaxLen;
// If requested stack frame isn't available, request a new one
// (this prevents assert failures when creating local
@ -593,10 +593,10 @@ ConsoleValueRef CodeBlock::exec(U32 ip, const char *functionName, Namespace *thi
CodeBlock *saveCodeBlock = smCurrentCodeBlock;
smCurrentCodeBlock = this;
if(this->name)
if(this->mName)
{
Con::gCurrentFile = this->name;
Con::gCurrentRoot = this->modPath;
Con::gCurrentFile = this->mName;
Con::gCurrentRoot = this->mModPath;
}
const char * val;
StringStackPtr retValue;
@ -611,7 +611,7 @@ ConsoleValueRef CodeBlock::exec(U32 ip, const char *functionName, Namespace *thi
for(;;)
{
U32 instruction = code[ip++];
U32 instruction = mCode[ip++];
nsEntry = NULL;
breakContinue:
switch(instruction)
@ -619,11 +619,11 @@ breakContinue:
case OP_FUNC_DECL:
if(!noCalls)
{
fnName = CodeToSTE(code, ip);
fnNamespace = CodeToSTE(code, ip+2);
fnPackage = CodeToSTE(code, ip+4);
bool hasBody = ( code[ ip + 6 ] & 0x01 ) != 0;
U32 lineNumber = code[ ip + 6 ] >> 1;
fnName = CodeToSTE(mCode, ip);
fnNamespace = CodeToSTE(mCode, ip+2);
fnPackage = CodeToSTE(mCode, ip+4);
bool hasBody = ( mCode[ ip + 6 ] & 0x01 ) != 0;
U32 lineNumber = mCode[ ip + 6 ] >> 1;
Namespace::unlinkPackages();
ns = Namespace::find(fnNamespace, fnPackage);
@ -646,18 +646,18 @@ breakContinue:
//Con::printf("Adding function %s::%s (%d)", fnNamespace, fnName, ip);
}
ip = code[ip + 7];
ip = mCode[ip + 7];
break;
case OP_CREATE_OBJECT:
{
// Read some useful info.
objParent = CodeToSTE(code, ip);
bool isDataBlock = code[ip + 2];
bool isInternal = code[ip + 3];
bool isSingleton = code[ip + 4];
U32 lineNumber = code[ip + 5];
failJump = code[ip + 6];
objParent = CodeToSTE(mCode, ip);
bool isDataBlock = mCode[ip + 2];
bool isInternal = mCode[ip + 3];
bool isSingleton = mCode[ip + 4];
U32 lineNumber = mCode[ip + 5];
failJump = mCode[ip + 6];
// If we don't allow calls, we certainly don't allow creating objects!
// Moved this to after failJump is set. Engine was crashing when
@ -871,7 +871,7 @@ breakContinue:
currentNewObject->setDeclarationLine(lineNumber);
// Set the file that this object was created in
currentNewObject->setFilename(name);
currentNewObject->setFilename(mName);
// Does it have a parent object? (ie, the copy constructor : syntax, not inheriance)
if(*objParent)
@ -955,7 +955,7 @@ breakContinue:
curNSDocBlock = NULL;
// Do we place this object at the root?
bool placeAtRoot = code[ip++];
bool placeAtRoot = mCode[ip++];
// Con::printf("Adding object %s", currentNewObject->getName());
@ -1078,7 +1078,7 @@ breakContinue:
{
// If we're not to be placed at the root, make sure we clean up
// our group reference.
bool placeAtRoot = code[ip++];
bool placeAtRoot = mCode[ip++];
if(!placeAtRoot)
_UINT--;
break;
@ -1099,7 +1099,7 @@ breakContinue:
ip++;
break;
}
ip = code[ip];
ip = mCode[ip];
break;
case OP_JMPIFNOT:
if(intStack[_UINT--])
@ -1107,7 +1107,7 @@ breakContinue:
ip++;
break;
}
ip = code[ip];
ip = mCode[ip];
break;
case OP_JMPIFF:
if(!floatStack[_FLT--])
@ -1115,7 +1115,7 @@ breakContinue:
ip++;
break;
}
ip = code[ip];
ip = mCode[ip];
break;
case OP_JMPIF:
if(!intStack[_UINT--])
@ -1123,7 +1123,7 @@ breakContinue:
ip ++;
break;
}
ip = code[ip];
ip = mCode[ip];
break;
case OP_JMPIFNOT_NP:
if(intStack[_UINT])
@ -1132,7 +1132,7 @@ breakContinue:
ip++;
break;
}
ip = code[ip];
ip = mCode[ip];
break;
case OP_JMPIF_NP:
if(!intStack[_UINT])
@ -1141,10 +1141,10 @@ breakContinue:
ip++;
break;
}
ip = code[ip];
ip = mCode[ip];
break;
case OP_JMP:
ip = code[ip];
ip = mCode[ip];
break;
// This fixes a bug when not explicitly returning a value.
@ -1326,7 +1326,7 @@ breakContinue:
break;
case OP_SETCURVAR:
var = CodeToSTE(code, ip);
var = CodeToSTE(mCode, ip);
ip += 2;
// If a variable is set, then these must be NULL. It is necessary
@ -1346,7 +1346,7 @@ breakContinue:
break;
case OP_SETCURVAR_CREATE:
var = CodeToSTE(code, ip);
var = CodeToSTE(mCode, ip);
ip += 2;
// See OP_SETCURVAR
@ -1455,7 +1455,7 @@ breakContinue:
if(set)
{
StringTableEntry intName = StringTable->insert(STR.getStringValue());
bool recurse = code[ip-1];
bool recurse = mCode[ip-1];
SimObject *obj = set->findObjectByInternalName(intName, recurse);
intStack[_UINT+1] = obj ? obj->getId() : 0;
_UINT++;
@ -1476,7 +1476,7 @@ breakContinue:
// Save the previous field for parsing vector fields.
prevField = curField;
dStrcpy( prevFieldArray, curFieldArray );
curField = CodeToSTE(code, ip);
curField = CodeToSTE(mCode, ip);
curFieldArray[0] = 0;
ip += 2;
break;
@ -1487,7 +1487,7 @@ breakContinue:
case OP_SETCURFIELD_TYPE:
if(curObject)
curObject->setDataFieldType(code[ip], curField, curFieldArray);
curObject->setDataFieldType(mCode[ip], curField, curFieldArray);
ip++;
break;
@ -1619,34 +1619,34 @@ breakContinue:
break;
case OP_LOADIMMED_UINT:
intStack[_UINT+1] = code[ip++];
intStack[_UINT+1] = mCode[ip++];
_UINT++;
break;
case OP_LOADIMMED_FLT:
floatStack[_FLT+1] = curFloatTable[code[ip]];
floatStack[_FLT+1] = curFloatTable[mCode[ip]];
ip++;
_FLT++;
break;
case OP_TAG_TO_STR:
code[ip-1] = OP_LOADIMMED_STR;
mCode[ip-1] = OP_LOADIMMED_STR;
// it's possible the string has already been converted
if(U8(curStringTable[code[ip]]) != StringTagPrefixByte)
if(U8(curStringTable[mCode[ip]]) != StringTagPrefixByte)
{
U32 id = GameAddTaggedString(curStringTable + code[ip]);
dSprintf(curStringTable + code[ip] + 1, 7, "%d", id);
*(curStringTable + code[ip]) = StringTagPrefixByte;
U32 id = GameAddTaggedString(curStringTable + mCode[ip]);
dSprintf(curStringTable + mCode[ip] + 1, 7, "%d", id);
*(curStringTable + mCode[ip]) = StringTagPrefixByte;
}
case OP_LOADIMMED_STR:
STR.setStringValue(curStringTable + code[ip++]);
STR.setStringValue(curStringTable + mCode[ip++]);
break;
case OP_DOCBLOCK_STR:
{
// If the first word of the doc is '\class' or '@class', then this
// is a namespace doc block, otherwise it is a function doc block.
const char* docblock = curStringTable + code[ip++];
const char* docblock = curStringTable + mCode[ip++];
const char* sansClass = dStrstr( docblock, "@class" );
if( !sansClass )
@ -1674,14 +1674,14 @@ breakContinue:
break;
case OP_LOADIMMED_IDENT:
STR.setStringValue(CodeToSTE(code, ip));
STR.setStringValue(CodeToSTE(mCode, ip));
ip += 2;
break;
case OP_CALLFUNC_RESOLVE:
// This deals with a function that is potentially living in a namespace.
fnNamespace = CodeToSTE(code, ip+2);
fnName = CodeToSTE(code, ip);
fnNamespace = CodeToSTE(mCode, ip+2);
fnName = CodeToSTE(mCode, ip);
// Try to look it up.
ns = Namespace::find(fnNamespace);
@ -1718,7 +1718,7 @@ breakContinue:
// or just on the object.
S32 routingId = 0;
fnName = CodeToSTE(code, ip);
fnName = CodeToSTE(mCode, ip);
//if this is called from inside a function, append the ip and codeptr
if( gEvalState.getStackDepth() > 0 )
@ -1727,7 +1727,7 @@ breakContinue:
gEvalState.getCurrentFrame().ip = ip - 1;
}
U32 callType = code[ip+4];
U32 callType = mCode[ip+4];
ip += 5;
CSTK.getArgcArgv(fnName, &callArgc, &callArgv);
@ -1836,17 +1836,17 @@ breakContinue:
STR.popFrame();
// Functions are assumed to return strings, so look ahead to see if we can skip the conversion
if(code[ip] == OP_STR_TO_UINT)
if(mCode[ip] == OP_STR_TO_UINT)
{
ip++;
intStack[++_UINT] = (U32)((S32)ret);
}
else if(code[ip] == OP_STR_TO_FLT)
else if(mCode[ip] == OP_STR_TO_FLT)
{
ip++;
floatStack[++_FLT] = (F32)ret;
}
else if(code[ip] == OP_STR_TO_NONE)
else if(mCode[ip] == OP_STR_TO_NONE)
{
STR.setStringValue(ret.getStringValue());
ip++;
@ -1899,19 +1899,19 @@ breakContinue:
S32 result = nsEntry->cb.mIntCallbackFunc(gEvalState.thisObject, callArgc, callArgv);
STR.popFrame();
CSTK.popFrame();
if(code[ip] == OP_STR_TO_UINT)
if(mCode[ip] == OP_STR_TO_UINT)
{
ip++;
intStack[++_UINT] = result;
break;
}
else if(code[ip] == OP_STR_TO_FLT)
else if(mCode[ip] == OP_STR_TO_FLT)
{
ip++;
floatStack[++_FLT] = result;
break;
}
else if(code[ip] == OP_STR_TO_NONE)
else if(mCode[ip] == OP_STR_TO_NONE)
ip++;
else
STR.setIntValue(result);
@ -1922,19 +1922,19 @@ breakContinue:
F64 result = nsEntry->cb.mFloatCallbackFunc(gEvalState.thisObject, callArgc, callArgv);
STR.popFrame();
CSTK.popFrame();
if(code[ip] == OP_STR_TO_UINT)
if(mCode[ip] == OP_STR_TO_UINT)
{
ip++;
intStack[++_UINT] = (S64)result;
break;
}
else if(code[ip] == OP_STR_TO_FLT)
else if(mCode[ip] == OP_STR_TO_FLT)
{
ip++;
floatStack[++_FLT] = result;
break;
}
else if(code[ip] == OP_STR_TO_NONE)
else if(mCode[ip] == OP_STR_TO_NONE)
ip++;
else
STR.setFloatValue(result);
@ -1942,7 +1942,7 @@ breakContinue:
}
case Namespace::Entry::VoidCallbackType:
nsEntry->cb.mVoidCallbackFunc(gEvalState.thisObject, callArgc, callArgv);
if( code[ ip ] != OP_STR_TO_NONE && Con::getBoolVariable( "$Con::warnVoidAssignment", true ) )
if( mCode[ ip ] != OP_STR_TO_NONE && Con::getBoolVariable( "$Con::warnVoidAssignment", true ) )
Con::warnf(ConsoleLogEntry::General, "%s: Call to %s in %s uses result of void function call.", getFileLine(ip-6), fnName, functionName);
STR.popFrame();
@ -1954,19 +1954,19 @@ breakContinue:
bool result = nsEntry->cb.mBoolCallbackFunc(gEvalState.thisObject, callArgc, callArgv);
STR.popFrame();
CSTK.popFrame();
if(code[ip] == OP_STR_TO_UINT)
if(mCode[ip] == OP_STR_TO_UINT)
{
ip++;
intStack[++_UINT] = result;
break;
}
else if(code[ip] == OP_STR_TO_FLT)
else if(mCode[ip] == OP_STR_TO_FLT)
{
ip++;
floatStack[++_FLT] = result;
break;
}
else if(code[ip] == OP_STR_TO_NONE)
else if(mCode[ip] == OP_STR_TO_NONE)
ip++;
else
STR.setIntValue(result);
@ -1984,7 +1984,7 @@ breakContinue:
STR.advance();
break;
case OP_ADVANCE_STR_APPENDCHAR:
STR.advanceChar(code[ip++]);
STR.advanceChar(mCode[ip++]);
break;
case OP_ADVANCE_STR_COMMA:
@ -2034,13 +2034,13 @@ breakContinue:
{
if( !intStack[_UINT--] )
{
const char *message = curStringTable + code[ip];
const char *message = curStringTable + mCode[ip];
U32 breakLine, inst;
findBreakLine( ip - 1, breakLine, inst );
if ( PlatformAssert::processAssert( PlatformAssert::Fatal,
name ? name : "eval",
mName ? mName : "eval",
breakLine,
message ) )
{
@ -2080,8 +2080,8 @@ breakContinue:
case OP_ITER_BEGIN:
{
StringTableEntry varName = CodeToSTE(code, ip);
U32 failIp = code[ ip + 2 ];
StringTableEntry varName = CodeToSTE(mCode, ip);
U32 failIp = mCode[ ip + 2 ];
IterStackRecord& iter = iterStack[ _ITER ];
@ -2122,7 +2122,7 @@ breakContinue:
case OP_ITER:
{
U32 breakIp = code[ ip ];
U32 breakIp = mCode[ ip ];
IterStackRecord& iter = iterStack[ _ITER - 1 ];
if( iter.mIsStringIter )
@ -2237,10 +2237,10 @@ execFinished:
}
smCurrentCodeBlock = saveCodeBlock;
if(saveCodeBlock && saveCodeBlock->name)
if(saveCodeBlock && saveCodeBlock->mName)
{
Con::gCurrentFile = saveCodeBlock->name;
Con::gCurrentRoot = saveCodeBlock->modPath;
Con::gCurrentFile = saveCodeBlock->mName;
Con::gCurrentRoot = saveCodeBlock->mModPath;
}
decRefCount();

View file

@ -2159,8 +2159,8 @@ DefineConsoleMethod( SimObject, dumpMethods, ArrayObject*, (),,
str.append( e->getPrototypeString() );
str.append( '\n' );
if( e->mCode && e->mCode->fullPath )
str.append( e->mCode->fullPath );
if( e->mCode && e->mCode->mFullPath )
str.append( e->mCode->mFullPath );
str.append( '\n' );
if( e->mCode )
str.append( String::ToString( e->mFunctionLineNumber ) );

View file

@ -384,7 +384,7 @@ void TelnetDebugger::executionStopped(CodeBlock *code, U32 lineNumber)
return;
}
Breakpoint **bp = findBreakpoint(code->name, lineNumber);
Breakpoint **bp = findBreakpoint(code->mName, lineNumber);
if(!bp)
return;
@ -398,7 +398,7 @@ void TelnetDebugger::executionStopped(CodeBlock *code, U32 lineNumber)
{
brk->curCount = 0;
if(brk->clearOnHit)
removeBreakpoint(code->name, lineNumber);
removeBreakpoint(code->mName, lineNumber);
breakProcess();
}
}
@ -457,8 +457,8 @@ void TelnetDebugger::sendBreak()
{
CodeBlock *code = gEvalState.stack[i]->code;
const char *file = "<none>";
if (code && code->name && code->name[0])
file = code->name;
if (code && code->mName && code->mName[0])
file = code->mName;
Namespace *ns = gEvalState.stack[i]->scopeNamespace;
scope[0] = 0;
@ -582,7 +582,7 @@ void TelnetDebugger::addAllBreakpoints(CodeBlock *code)
{
// TODO: This assumes that the OS file names are case
// insensitive... Torque needs a dFilenameCmp() function.
if( dStricmp( cur->fileName, code->name ) == 0 )
if( dStricmp( cur->fileName, code->mName ) == 0 )
{
cur->code = code;
@ -776,7 +776,7 @@ void TelnetDebugger::setBreakOnNextStatement( bool enabled )
if ( enabled )
{
// Apply breaks on all the code blocks.
for(CodeBlock *walk = CodeBlock::getCodeBlockList(); walk; walk = walk->nextFile)
for(CodeBlock *walk = CodeBlock::getCodeBlockList(); walk; walk = walk->mNextFile)
walk->setAllBreaks();
mBreakOnNextStatement = true;
}
@ -784,7 +784,7 @@ void TelnetDebugger::setBreakOnNextStatement( bool enabled )
{
// Clear all the breaks on the codeblocks
// then go reapply the breakpoints.
for(CodeBlock *walk = CodeBlock::getCodeBlockList(); walk; walk = walk->nextFile)
for(CodeBlock *walk = CodeBlock::getCodeBlockList(); walk; walk = walk->mNextFile)
walk->clearAllBreaks();
for(Breakpoint *w = mBreakpoints; w; w = w->next)
{
@ -880,10 +880,10 @@ void TelnetDebugger::evaluateExpression(const char *tag, S32 frame, const char *
void TelnetDebugger::dumpFileList()
{
send("FILELISTOUT ");
for(CodeBlock *walk = CodeBlock::getCodeBlockList(); walk; walk = walk->nextFile)
for(CodeBlock *walk = CodeBlock::getCodeBlockList(); walk; walk = walk->mNextFile)
{
send(walk->name);
if(walk->nextFile)
send(walk->mName);
if(walk->mNextFile)
send(" ");
}
send("\r\n");
@ -896,11 +896,11 @@ void TelnetDebugger::dumpBreakableList(const char *fileName)
char buffer[MaxCommandSize];
if(file)
{
dSprintf(buffer, MaxCommandSize, "BREAKLISTOUT %s %d", fileName, file->breakListSize >> 1);
dSprintf(buffer, MaxCommandSize, "BREAKLISTOUT %s %d", fileName, file->mBreakListSize >> 1);
send(buffer);
for(U32 i = 0; i < file->breakListSize; i += 2)
for(U32 i = 0; i < file->mBreakListSize; i += 2)
{
dSprintf(buffer, MaxCommandSize, " %d %d", file->breakList[i], file->breakList[i+1]);
dSprintf(buffer, MaxCommandSize, " %d %d", file->mBreakList[i], file->mBreakList[i+1]);
send(buffer);
}
send("\r\n");

View file

@ -78,18 +78,18 @@ ResizeBitStream::ResizeBitStream(U32 minSpace, U32 initialSize) : BitStream(NULL
ResizeBitStream::~ResizeBitStream()
{
dFree(dataPtr);
dFree(mDataPtr);
}
void ResizeBitStream::validate()
{
if(getPosition() + mMinSpace > bufSize)
if(getPosition() + mMinSpace > mBufSize)
{
bufSize = getPosition() + mMinSpace * 2;
dataPtr = (U8 *) dRealloc(dataPtr, bufSize);
mBufSize = getPosition() + mMinSpace * 2;
mDataPtr = (U8 *) dRealloc(mDataPtr, mBufSize);
maxReadBitNum = bufSize << 3;
maxWriteBitNum = bufSize << 3;
mMaxReadBitNum = mBufSize << 3;
mMaxWriteBitNum = mBufSize << 3;
}
}
@ -148,53 +148,53 @@ HuffmanProcessor HuffmanProcessor::g_huffProcessor;
void BitStream::setBuffer(void *bufPtr, S32 size, S32 maxSize)
{
dataPtr = (U8 *) bufPtr;
bitNum = 0;
bufSize = size;
maxReadBitNum = size << 3;
mDataPtr = (U8 *) bufPtr;
mBitNum = 0;
mBufSize = size;
mMaxReadBitNum = size << 3;
if(maxSize < 0)
maxSize = size;
maxWriteBitNum = maxSize << 3;
error = false;
mMaxWriteBitNum = maxSize << 3;
mError = false;
clearCompressionPoint();
}
U32 BitStream::getPosition() const
{
return (bitNum + 7) >> 3;
return (mBitNum + 7) >> 3;
}
bool BitStream::setPosition(const U32 pos)
{
bitNum = pos << 3;
mBitNum = pos << 3;
return (true);
}
U32 BitStream::getStreamSize()
{
return bufSize;
return mBufSize;
}
U8 *BitStream::getBytePtr()
{
return dataPtr + getPosition();
return mDataPtr + getPosition();
}
U32 BitStream::getReadByteSize()
{
return (maxReadBitNum >> 3) - getPosition();
return (mMaxReadBitNum >> 3) - getPosition();
}
U32 BitStream::getWriteByteSize()
{
return (maxWriteBitNum >> 3) - getPosition();
return (mMaxWriteBitNum >> 3) - getPosition();
}
void BitStream::clear()
{
dMemset(dataPtr, 0, bufSize);
dMemset(mDataPtr, 0, mBufSize);
}
void BitStream::writeClassId(U32 classId, U32 classType, U32 classGroup)
@ -228,9 +228,9 @@ void BitStream::writeBits(S32 bitCount, const void *bitPtr)
if(!bitCount)
return;
if(bitCount + bitNum > maxWriteBitNum)
if(bitCount + mBitNum > mMaxWriteBitNum)
{
error = true;
mError = true;
AssertFatal(false, "Out of range write");
return;
}
@ -242,39 +242,39 @@ void BitStream::writeBits(S32 bitCount, const void *bitPtr)
for(S32 srcBitNum = 0;srcBitNum < bitCount;srcBitNum++)
{
if((*(ptr + (srcBitNum >> 3)) & (1 << (srcBitNum & 0x7))) != 0)
*(dataPtr + (bitNum >> 3)) |= (1 << (bitNum & 0x7));
*(mDataPtr + (mBitNum >> 3)) |= (1 << (mBitNum & 0x7));
else
*(dataPtr + (bitNum >> 3)) &= ~(1 << (bitNum & 0x7));
bitNum++;
*(mDataPtr + (mBitNum >> 3)) &= ~(1 << (mBitNum & 0x7));
mBitNum++;
}
}
void BitStream::setBit(S32 bitCount, bool set)
{
if(set)
*(dataPtr + (bitCount >> 3)) |= (1 << (bitCount & 0x7));
*(mDataPtr + (bitCount >> 3)) |= (1 << (bitCount & 0x7));
else
*(dataPtr + (bitCount >> 3)) &= ~(1 << (bitCount & 0x7));
*(mDataPtr + (bitCount >> 3)) &= ~(1 << (bitCount & 0x7));
}
bool BitStream::testBit(S32 bitCount)
{
return (*(dataPtr + (bitCount >> 3)) & (1 << (bitCount & 0x7))) != 0;
return (*(mDataPtr + (bitCount >> 3)) & (1 << (bitCount & 0x7))) != 0;
}
bool BitStream::writeFlag(bool val)
{
if(bitNum + 1 > maxWriteBitNum)
if(mBitNum + 1 > mMaxWriteBitNum)
{
error = true;
mError = true;
AssertFatal(false, "Out of range write");
return false;
}
if(val)
*(dataPtr + (bitNum >> 3)) |= (1 << (bitNum & 0x7));
*(mDataPtr + (mBitNum >> 3)) |= (1 << (mBitNum & 0x7));
else
*(dataPtr + (bitNum >> 3)) &= ~(1 << (bitNum & 0x7));
bitNum++;
*(mDataPtr + (mBitNum >> 3)) &= ~(1 << (mBitNum & 0x7));
mBitNum++;
return (val);
}
@ -282,23 +282,23 @@ void BitStream::readBits(S32 bitCount, void *bitPtr)
{
if(!bitCount)
return;
if(bitCount + bitNum > maxReadBitNum)
if(bitCount + mBitNum > mMaxReadBitNum)
{
error = true;
mError = true;
//AssertFatal(false, "Out of range read");
AssertWarn(false, "Out of range read");
return;
}
U8 *stPtr = dataPtr + (bitNum >> 3);
U8 *stPtr = mDataPtr + (mBitNum >> 3);
S32 byteCount = (bitCount + 7) >> 3;
U8 *ptr = (U8 *) bitPtr;
S32 downShift = bitNum & 0x7;
S32 downShift = mBitNum & 0x7;
S32 upShift = 8 - downShift;
U8 curB = *stPtr;
const U8 *stEnd = dataPtr + bufSize;
const U8 *stEnd = mDataPtr + mBufSize;
while(byteCount--)
{
stPtr++;
@ -307,7 +307,7 @@ void BitStream::readBits(S32 bitCount, void *bitPtr)
curB = nextB;
}
bitNum += bitCount;
mBitNum += bitCount;
}
bool BitStream::_read(U32 size, void *dataPtr)
@ -625,69 +625,69 @@ void InfiniteBitStream::reset()
void InfiniteBitStream::validate(U32 upcomingBytes)
{
if(getPosition() + upcomingBytes + mMinSpace > bufSize)
if(getPosition() + upcomingBytes + mMinSpace > mBufSize)
{
bufSize = getPosition() + upcomingBytes + mMinSpace;
dataPtr = (U8 *) dRealloc(dataPtr, bufSize);
mBufSize = getPosition() + upcomingBytes + mMinSpace;
mDataPtr = (U8 *) dRealloc(mDataPtr, mBufSize);
maxReadBitNum = bufSize << 3;
maxWriteBitNum = bufSize << 3;
mMaxReadBitNum = mBufSize << 3;
mMaxWriteBitNum = mBufSize << 3;
}
}
void InfiniteBitStream::compact()
{
// Prepare to copy...
U32 oldSize = bufSize;
U8 *tmp = (U8*)dMalloc(bufSize);
U32 oldSize = mBufSize;
U8 *tmp = (U8*)dMalloc(mBufSize);
// Copy things...
bufSize = getPosition() + mMinSpace * 2;
dMemcpy(tmp, dataPtr, oldSize);
mBufSize = getPosition() + mMinSpace * 2;
dMemcpy(tmp, mDataPtr, oldSize);
// And clean up.
dFree(dataPtr);
dataPtr = tmp;
dFree(mDataPtr);
mDataPtr = tmp;
maxReadBitNum = bufSize << 3;
maxWriteBitNum = bufSize << 3;
mMaxReadBitNum = mBufSize << 3;
mMaxWriteBitNum = mBufSize << 3;
}
void InfiniteBitStream::writeToStream(Stream &s)
{
s.write(getPosition(), dataPtr);
s.write(getPosition(), mDataPtr);
}
//------------------------------------------------------------------------------
void BitStream::readString(char buf[256])
{
if(stringBuffer)
if(mStringBuffer)
{
if(readFlag())
{
S32 offset = readInt(8);
HuffmanProcessor::g_huffProcessor.readHuffBuffer(this, stringBuffer + offset);
dStrcpy(buf, stringBuffer);
HuffmanProcessor::g_huffProcessor.readHuffBuffer(this, mStringBuffer + offset);
dStrcpy(buf, mStringBuffer);
return;
}
}
HuffmanProcessor::g_huffProcessor.readHuffBuffer(this, buf);
if(stringBuffer)
dStrcpy(stringBuffer, buf);
if(mStringBuffer)
dStrcpy(mStringBuffer, buf);
}
void BitStream::writeString(const char *string, S32 maxLen)
{
if(!string)
string = "";
if(stringBuffer)
if(mStringBuffer)
{
S32 j;
for(j = 0; j < maxLen && stringBuffer[j] == string[j] && string[j];j++)
for(j = 0; j < maxLen && mStringBuffer[j] == string[j] && string[j];j++)
;
dStrncpy(stringBuffer, string, maxLen);
stringBuffer[maxLen] = 0;
dStrncpy(mStringBuffer, string, maxLen);
mStringBuffer[maxLen] = 0;
if(writeFlag(j > 2))
{
@ -781,7 +781,7 @@ void HuffmanProcessor::generateCodes(BitStream& rBS, S32 index, S32 depth)
// leaf node, copy the code in, and back out...
HuffLeaf& rLeaf = m_huffLeaves[-(index + 1)];
dMemcpy(&rLeaf.code, rBS.dataPtr, sizeof(rLeaf.code));
dMemcpy(&rLeaf.code, rBS.mDataPtr, sizeof(rLeaf.code));
rLeaf.numBits = depth;
} else {
HuffNode& rNode = m_huffNodes[index];

View file

@ -48,13 +48,13 @@ class QuatF;
class BitStream : public Stream
{
protected:
U8 *dataPtr;
S32 bitNum;
S32 bufSize;
bool error;
S32 maxReadBitNum;
S32 maxWriteBitNum;
char *stringBuffer;
U8 *mDataPtr;
S32 mBitNum;
S32 mBufSize;
bool mError;
S32 mMaxReadBitNum;
S32 mMaxWriteBitNum;
char *mStringBuffer;
Point3F mCompressPoint;
friend class HuffmanProcessor;
@ -63,7 +63,7 @@ public:
static void sendPacketStream(const NetAddress *addr);
void setBuffer(void *bufPtr, S32 bufSize, S32 maxSize = 0);
U8* getBuffer() { return dataPtr; }
U8* getBuffer() { return mDataPtr; }
U8* getBytePtr();
U32 getReadByteSize();
@ -83,7 +83,7 @@ public:
S32 getBitPosition() const { return getCurPos(); }
void clearStringBuffer();
BitStream(void *bufPtr, S32 bufSize, S32 maxWriteSize = -1) { setBuffer(bufPtr, bufSize,maxWriteSize); stringBuffer = NULL; }
BitStream(void *bufPtr, S32 bufSize, S32 maxWriteSize = -1) { setBuffer(bufPtr, bufSize,maxWriteSize); mStringBuffer = NULL; }
void clear();
void setStringBuffer(char buffer[256]);
@ -241,8 +241,8 @@ public:
void setBit(S32 bitCount, bool set);
bool testBit(S32 bitCount);
bool isFull() { return bitNum > (bufSize << 3); }
bool isValid() { return !error; }
bool isFull() { return mBitNum > (mBufSize << 3); }
bool isValid() { return !mError; }
bool _read (const U32 size,void* d);
bool _write(const U32 size,const void* d);
@ -313,26 +313,26 @@ public:
//
inline S32 BitStream::getCurPos() const
{
return bitNum;
return mBitNum;
}
inline void BitStream::setCurPos(const U32 in_position)
{
AssertFatal(in_position < (U32)(bufSize << 3), "Out of range bitposition");
bitNum = S32(in_position);
AssertFatal(in_position < (U32)(mBufSize << 3), "Out of range bitposition");
mBitNum = S32(in_position);
}
inline bool BitStream::readFlag()
{
if(bitNum > maxReadBitNum)
if(mBitNum > mMaxReadBitNum)
{
error = true;
mError = true;
AssertFatal(false, "Out of range read");
return false;
}
S32 mask = 1 << (bitNum & 0x7);
bool ret = (*(dataPtr + (bitNum >> 3)) & mask) != 0;
bitNum++;
S32 mask = 1 << (mBitNum & 0x7);
bool ret = (*(mDataPtr + (mBitNum >> 3)) & mask) != 0;
mBitNum++;
return ret;
}

View file

@ -154,7 +154,7 @@ TSShapeInstance* TSForestItemData::_getShapeInstance() const
void TSForestItemData::_checkLastDetail()
{
const S32 dl = mShape->mSmallestVisibleDL;
const TSDetail *detail = &mShape->details[dl];
const TSDetail *detail = &mShape->mDetails[dl];
// TODO: Expose some real parameters to the datablock maybe?
if ( detail->subShapeNum != -1 )
@ -162,8 +162,8 @@ void TSForestItemData::_checkLastDetail()
mShape->addImposter( mShapeFile, 10, 4, 0, 0, 256, 0, 0 );
// HACK: If i don't do this it crashes!
while ( mShape->detailCollisionAccelerators.size() < mShape->details.size() )
mShape->detailCollisionAccelerators.push_back( NULL );
while ( mShape->mDetailCollisionAccelerators.size() < mShape->mDetails.size() )
mShape->mDetailCollisionAccelerators.push_back( NULL );
}
}
@ -174,12 +174,12 @@ TSLastDetail* TSForestItemData::getLastDetail() const
return NULL;
const S32 dl = mShape->mSmallestVisibleDL;
const TSDetail* detail = &mShape->details[dl];
const TSDetail* detail = &mShape->mDetails[dl];
if ( detail->subShapeNum >= 0 ||
mShape->billboardDetails.size() <= dl )
mShape->mBillboardDetails.size() <= dl )
return NULL;
return mShape->billboardDetails[dl];
return mShape->mBillboardDetails[dl];
}
ForestCellBatch* TSForestItemData::allocateBatch() const
@ -207,8 +207,8 @@ bool TSForestItemData::canBillboard( const SceneRenderState *state, const Forest
if ( dl < 0 )
return true;
const TSDetail *detail = &mShape->details[dl];
if ( detail->subShapeNum < 0 && dl < mShape->billboardDetails.size() )
const TSDetail *detail = &mShape->mDetails[dl];
if ( detail->subShapeNum < 0 && dl < mShape->mBillboardDetails.size() )
return true;
return false;

View file

@ -88,7 +88,7 @@ public:
const Vector<S32>& getLOSDetails() const { return mLOSDetails; }
// ForestItemData
const Box3F& getObjBox() const { return mShape ? mShape->bounds : Box3F::Invalid; }
const Box3F& getObjBox() const { return mShape ? mShape->mBounds : Box3F::Invalid; }
bool render( TSRenderState *rdata, const ForestItem& item ) const;
ForestCellBatch* allocateBatch() const;
bool canBillboard( const SceneRenderState *state, const ForestItem &item, F32 distToCamera ) const;

View file

@ -331,7 +331,7 @@ void GuiShapeEdPreview::setCurrentDetail(S32 dl)
if ( mModel )
{
S32 smallest = mModel->getShape()->mSmallestVisibleDL;
mModel->getShape()->mSmallestVisibleDL = mModel->getShape()->details.size()-1;
mModel->getShape()->mSmallestVisibleDL = mModel->getShape()->mDetails.size()-1;
mModel->setCurrentDetail( dl );
mModel->getShape()->mSmallestVisibleDL = smallest;
@ -360,18 +360,18 @@ bool GuiShapeEdPreview::setObjectModel(const char* modelName)
AssertFatal( mModel, avar("GuiShapeEdPreview: Failed to load model %s. Please check your model name and load a valid model.", modelName ));
// Initialize camera values:
mOrbitPos = mModel->getShape()->center;
mOrbitPos = mModel->getShape()->mCenter;
// Set camera move and zoom speed according to model size
mMoveSpeed = mModel->getShape()->radius / sMoveScaler;
mZoomSpeed = mModel->getShape()->radius / sZoomScaler;
mMoveSpeed = mModel->getShape()->mRadius / sMoveScaler;
mZoomSpeed = mModel->getShape()->mRadius / sZoomScaler;
// Reset node selection
mHoverNode = -1;
mSelectedNode = -1;
mSelectedObject = -1;
mSelectedObjDetail = 0;
mProjectedNodes.setSize( mModel->getShape()->nodes.size() );
mProjectedNodes.setSize( mModel->getShape()->mNodes.size() );
// Reset detail stats
mCurrentDL = 0;
@ -683,9 +683,9 @@ void GuiShapeEdPreview::refreshShape()
mModel->initNodeTransforms();
mModel->initMeshObjects();
mProjectedNodes.setSize( mModel->getShape()->nodes.size() );
mProjectedNodes.setSize( mModel->getShape()->mNodes.size() );
if ( mSelectedObject >= mModel->getShape()->objects.size() )
if ( mSelectedObject >= mModel->getShape()->mObjects.size() )
{
mSelectedObject = -1;
mSelectedObjDetail = 0;
@ -694,9 +694,9 @@ void GuiShapeEdPreview::refreshShape()
// Re-compute the collision mesh stats
mColMeshes = 0;
mColPolys = 0;
for ( S32 i = 0; i < mModel->getShape()->details.size(); i++ )
for ( S32 i = 0; i < mModel->getShape()->mDetails.size(); i++ )
{
const TSShape::Detail& det = mModel->getShape()->details[i];
const TSShape::Detail& det = mModel->getShape()->mDetails[i];
const String& detName = mModel->getShape()->getName( det.nameIndex );
if ( ( det.subShapeNum < 0 ) || !detName.startsWith( "collision-" ) )
continue;
@ -704,12 +704,12 @@ void GuiShapeEdPreview::refreshShape()
mColPolys += det.polyCount;
S32 od = det.objectDetailNum;
S32 start = mModel->getShape()->subShapeFirstObject[det.subShapeNum];
S32 end = start + mModel->getShape()->subShapeNumObjects[det.subShapeNum];
S32 start = mModel->getShape()->mSubShapeFirstObject[det.subShapeNum];
S32 end = start + mModel->getShape()->mSubShapeNumObjects[det.subShapeNum];
for ( S32 j = start; j < end; j++ )
{
const TSShape::Object &obj = mModel->getShape()->objects[j];
const TSMesh* mesh = ( od < obj.numMeshes ) ? mModel->getShape()->meshes[obj.startMeshIndex + od] : NULL;
const TSShape::Object &obj = mModel->getShape()->mObjects[j];
const TSMesh* mesh = ( od < obj.numMeshes ) ? mModel->getShape()->mMeshes[obj.startMeshIndex + od] : NULL;
if ( mesh )
mColMeshes++;
}
@ -850,7 +850,7 @@ void GuiShapeEdPreview::exportToCollada( const String& path )
if ( mModel )
{
MatrixF orientation( true );
orientation.setPosition( mModel->getShape()->bounds.getCenter() );
orientation.setPosition( mModel->getShape()->mBounds.getCenter() );
orientation.inverse();
OptimizedPolyList polyList;
@ -1135,8 +1135,8 @@ bool GuiShapeEdPreview::getCameraTransform(MatrixF* cameraMatrix)
cameraMatrix->identity();
if ( mModel )
{
Point3F camPos = mModel->getShape()->bounds.getCenter();
F32 offset = mModel->getShape()->bounds.len();
Point3F camPos = mModel->getShape()->mBounds.getCenter();
F32 offset = mModel->getShape()->mBounds.len();
switch (mDisplayType)
{
@ -1166,11 +1166,11 @@ void GuiShapeEdPreview::computeSceneBounds(Box3F& bounds)
void GuiShapeEdPreview::updateDetailLevel(const SceneRenderState* state)
{
// Make sure current detail is valid
if ( !mModel->getShape()->details.size() )
if ( !mModel->getShape()->mDetails.size() )
return;
if ( mModel->getCurrentDetail() >= mModel->getShape()->details.size() )
setCurrentDetail( mModel->getShape()->details.size() - 1 );
if ( mModel->getCurrentDetail() >= mModel->getShape()->mDetails.size() )
setCurrentDetail( mModel->getShape()->mDetails.size() - 1 );
// Convert between FOV and distance so zoom is consistent between Perspective
// and Orthographic views (conversion factor found by trial and error)
@ -1193,7 +1193,7 @@ void GuiShapeEdPreview::updateDetailLevel(const SceneRenderState* state)
setCurrentDetail( 0 );
currentDetail = mModel->getCurrentDetail();
const TSShape::Detail& det = mModel->getShape()->details[ currentDetail ];
const TSShape::Detail& det = mModel->getShape()->mDetails[ currentDetail ];
mDetailPolys = det.polyCount;
mDetailSize = det.size;
@ -1213,31 +1213,31 @@ void GuiShapeEdPreview::updateDetailLevel(const SceneRenderState* state)
{
Vector<U32> usedMaterials;
S32 start = mModel->getShape()->subShapeFirstObject[det.subShapeNum];
S32 end = start + mModel->getShape()->subShapeNumObjects[det.subShapeNum];
S32 start = mModel->getShape()->mSubShapeFirstObject[det.subShapeNum];
S32 end = start + mModel->getShape()->mSubShapeNumObjects[det.subShapeNum];
for ( S32 iObj = start; iObj < end; iObj++ )
{
const TSShape::Object& obj = mModel->getShape()->objects[iObj];
const TSShape::Object& obj = mModel->getShape()->mObjects[iObj];
if ( obj.numMeshes <= currentDetail )
continue;
const TSMesh* mesh = mModel->getShape()->meshes[ obj.startMeshIndex + currentDetail ];
const TSMesh* mesh = mModel->getShape()->mMeshes[ obj.startMeshIndex + currentDetail ];
if ( !mesh )
continue;
// Count the number of draw calls and materials
mNumDrawCalls += mesh->primitives.size();
for ( S32 iPrim = 0; iPrim < mesh->primitives.size(); iPrim++ )
usedMaterials.push_back_unique( mesh->primitives[iPrim].matIndex & TSDrawPrimitive::MaterialMask );
mNumDrawCalls += mesh->mPrimitives.size();
for ( S32 iPrim = 0; iPrim < mesh->mPrimitives.size(); iPrim++ )
usedMaterials.push_back_unique( mesh->mPrimitives[iPrim].matIndex & TSDrawPrimitive::MaterialMask );
// For skinned meshes, count the number of bones and weights
if ( mesh->getMeshType() == TSMesh::SkinMeshType )
{
const TSSkinMesh* skin = dynamic_cast<const TSSkinMesh*>(mesh);
mNumBones += skin->batchData.initialTransforms.size();
mNumWeights += skin->weight.size();
mNumBones += skin->mBatchData.initialTransforms.size();
mNumWeights += skin->mWeight.size();
}
}
@ -1262,7 +1262,7 @@ void GuiShapeEdPreview::updateThreads(F32 delta)
continue;
// Make sure thread priority matches sequence priority (which may have changed)
mModel->setPriority( thread.key, mModel->getShape()->sequences[mModel->getSequence( thread.key )].priority );
mModel->setPriority( thread.key, mModel->getShape()->mSequences[mModel->getSequence( thread.key )].priority );
// Handle ping-pong
if ( thread.pingpong && !mModel->isInTransition( thread.key ) )
@ -1426,18 +1426,18 @@ void GuiShapeEdPreview::renderWorld(const RectI &updateRect)
// Render the shape bounding box
if ( mRenderBounds )
{
Point3F boxSize = mModel->getShape()->bounds.maxExtents - mModel->getShape()->bounds.minExtents;
Point3F boxSize = mModel->getShape()->mBounds.maxExtents - mModel->getShape()->mBounds.minExtents;
GFXStateBlockDesc desc;
desc.fillMode = GFXFillWireframe;
GFX->getDrawUtil()->drawCube( desc, boxSize, mModel->getShape()->center, ColorF::WHITE );
GFX->getDrawUtil()->drawCube( desc, boxSize, mModel->getShape()->mCenter, ColorF::WHITE );
}
// Render the selected object bounding box
if ( mRenderObjBox && ( mSelectedObject != -1 ) )
{
const TSShape::Object& obj = mModel->getShape()->objects[mSelectedObject];
const TSMesh* mesh = ( mCurrentDL < obj.numMeshes ) ? mModel->getShape()->meshes[obj.startMeshIndex + mSelectedObjDetail] : NULL;
const TSShape::Object& obj = mModel->getShape()->mObjects[mSelectedObject];
const TSMesh* mesh = ( mCurrentDL < obj.numMeshes ) ? mModel->getShape()->mMeshes[obj.startMeshIndex + mSelectedObjDetail] : NULL;
if ( mesh )
{
GFX->pushWorldMatrix();
@ -1528,7 +1528,7 @@ void GuiShapeEdPreview::renderSunDirection() const
{
// Render four arrows aiming in the direction of the sun's light
ColorI color( mFakeSun->getColor() );
F32 length = mModel->getShape()->bounds.len() * 0.8f;
F32 length = mModel->getShape()->mBounds.len() * 0.8f;
// Get the sun's vectors
Point3F fwd = mFakeSun->getTransform().getForwardVector();
@ -1536,8 +1536,8 @@ void GuiShapeEdPreview::renderSunDirection() const
Point3F right = mFakeSun->getTransform().getRightVector() * length / 8;
// Calculate the start and end points of the first arrow (bottom left)
Point3F start = mModel->getShape()->center - fwd * length - up/2 - right/2;
Point3F end = mModel->getShape()->center - fwd * length / 3 - up/2 - right/2;
Point3F start = mModel->getShape()->mCenter - fwd * length - up/2 - right/2;
Point3F end = mModel->getShape()->mCenter - fwd * length / 3 - up/2 - right/2;
GFXStateBlockDesc desc;
desc.setZReadWrite( true, true );
@ -1560,10 +1560,10 @@ void GuiShapeEdPreview::renderNodes() const
GFX->setStateBlockByDesc( desc );
PrimBuild::color( ColorI::WHITE );
PrimBuild::begin( GFXLineList, mModel->getShape()->nodes.size() * 2 );
for ( S32 i = 0; i < mModel->getShape()->nodes.size(); i++)
PrimBuild::begin( GFXLineList, mModel->getShape()->mNodes.size() * 2 );
for ( S32 i = 0; i < mModel->getShape()->mNodes.size(); i++)
{
const TSShape::Node& node = mModel->getShape()->nodes[i];
const TSShape::Node& node = mModel->getShape()->mNodes[i];
if (node.parentIndex >= 0)
{
Point3F start(mModel->mNodeTransforms[i].getPosition());
@ -1576,7 +1576,7 @@ void GuiShapeEdPreview::renderNodes() const
PrimBuild::end();
// Render the node axes
for ( S32 i = 0; i < mModel->getShape()->nodes.size(); i++)
for ( S32 i = 0; i < mModel->getShape()->mNodes.size(); i++)
{
// Render the selected and hover nodes last (so they are on top)
if ( ( i == mSelectedNode ) || ( i == mHoverNode ) )
@ -1626,7 +1626,7 @@ void GuiShapeEdPreview::renderNodeAxes(S32 index, const ColorF& nodeColor) const
void GuiShapeEdPreview::renderNodeName(S32 index, const ColorF& textColor) const
{
const TSShape::Node& node = mModel->getShape()->nodes[index];
const TSShape::Node& node = mModel->getShape()->mNodes[index];
const String& nodeName = mModel->getShape()->getName( node.nameIndex );
Point2I pos( mProjectedNodes[index].x, mProjectedNodes[index].y + sNodeRectSize + 6 );
@ -1641,9 +1641,9 @@ void GuiShapeEdPreview::renderCollisionMeshes() const
{
ConcretePolyList polylist;
polylist.setTransform( &MatrixF::Identity, Point3F::One );
for ( S32 iDet = 0; iDet < mModel->getShape()->details.size(); iDet++ )
for ( S32 iDet = 0; iDet < mModel->getShape()->mDetails.size(); iDet++ )
{
const TSShape::Detail& det = mModel->getShape()->details[iDet];
const TSShape::Detail& det = mModel->getShape()->mDetails[iDet];
const String& detName = mModel->getShape()->getName( det.nameIndex );
// Ignore non-collision details

View file

@ -95,8 +95,8 @@ bool BlobShadow::shouldRender(F32 camDist)
if (mShapeBase && mShapeBase->getFadeVal() < TSMesh::VISIBILITY_EPSILON)
return false;
F32 shadowLen = 10.0f * mShapeInstance->getShape()->radius;
Point3F pos = mShapeInstance->getShape()->center;
F32 shadowLen = 10.0f * mShapeInstance->getShape()->mRadius;
Point3F pos = mShapeInstance->getShape()->mCenter;
// this is a bit of a hack...move generic shadows towards feet/base of shape
pos *= 0.5f;
@ -182,7 +182,7 @@ void BlobShadow::setRadius(F32 radius)
void BlobShadow::setRadius(TSShapeInstance * shapeInstance, const Point3F & scale)
{
const Box3F & bounds = shapeInstance->getShape()->bounds;
const Box3F & bounds = shapeInstance->getShape()->mBounds;
F32 dx = 0.5f * (bounds.maxExtents.x-bounds.minExtents.x) * scale.x;
F32 dy = 0.5f * (bounds.maxExtents.y-bounds.minExtents.y) * scale.y;
F32 dz = 0.5f * (bounds.maxExtents.z-bounds.minExtents.z) * scale.z;

View file

@ -31,79 +31,79 @@ NetStringTable *gNetStringTable = NULL;
NetStringTable::NetStringTable()
{
firstFree = 1;
firstValid = 1;
mFirstFree = 1;
mFirstValid = 1;
table = (Entry *) dMalloc(sizeof(Entry) * InitialSize);
size = InitialSize;
mTable = (Entry *) dMalloc(sizeof(Entry) * InitialSize);
mSize = InitialSize;
for(U32 i = 0; i < InitialSize; i++)
{
table[i].next = i + 1;
table[i].refCount = 0;
table[i].scriptRefCount = 0;
mTable[i].next = i + 1;
mTable[i].refCount = 0;
mTable[i].scriptRefCount = 0;
}
table[InitialSize-1].next = InvalidEntry;
mTable[InitialSize-1].next = InvalidEntry;
for(U32 j = 0; j < HashTableSize; j++)
hashTable[j] = 0;
allocator = new DataChunker(DataChunkerSize);
mHashTable[j] = 0;
mAllocator = new DataChunker(DataChunkerSize);
}
NetStringTable::~NetStringTable()
{
delete allocator;
dFree( table );
delete mAllocator;
dFree( mTable );
}
void NetStringTable::incStringRef(U32 id)
{
AssertFatal(table[id].refCount != 0 || table[id].scriptRefCount != 0 , "Cannot inc ref count from zero.");
table[id].refCount++;
AssertFatal(mTable[id].refCount != 0 || mTable[id].scriptRefCount != 0 , "Cannot inc ref count from zero.");
mTable[id].refCount++;
}
void NetStringTable::incStringRefScript(U32 id)
{
AssertFatal(table[id].refCount != 0 || table[id].scriptRefCount != 0 , "Cannot inc ref count from zero.");
table[id].scriptRefCount++;
AssertFatal(mTable[id].refCount != 0 || mTable[id].scriptRefCount != 0 , "Cannot inc ref count from zero.");
mTable[id].scriptRefCount++;
}
U32 NetStringTable::addString(const char *string)
{
U32 hash = _StringTable::hashString(string);
U32 bucket = hash % HashTableSize;
for(U32 walk = hashTable[bucket];walk; walk = table[walk].next)
for(U32 walk = mHashTable[bucket];walk; walk = mTable[walk].next)
{
if(!dStrcmp(table[walk].string, string))
if(!dStrcmp(mTable[walk].string, string))
{
table[walk].refCount++;
mTable[walk].refCount++;
return walk;
}
}
U32 e = firstFree;
firstFree = table[e].next;
if(firstFree == InvalidEntry)
U32 e = mFirstFree;
mFirstFree = mTable[e].next;
if(mFirstFree == InvalidEntry)
{
// in this case, we should expand the table for next time...
U32 newSize = size * 2;
table = (Entry *) dRealloc(table, newSize * sizeof(Entry));
for(U32 i = size; i < newSize; i++)
U32 newSize = mSize * 2;
mTable = (Entry *) dRealloc(mTable, newSize * sizeof(Entry));
for(U32 i = mSize; i < newSize; i++)
{
table[i].next = i + 1;
table[i].refCount = 0;
table[i].scriptRefCount = 0;
mTable[i].next = i + 1;
mTable[i].refCount = 0;
mTable[i].scriptRefCount = 0;
}
firstFree = size;
table[newSize - 1].next = InvalidEntry;
size = newSize;
mFirstFree = mSize;
mTable[newSize - 1].next = InvalidEntry;
mSize = newSize;
}
table[e].refCount++;
table[e].string = (char *) allocator->alloc(dStrlen(string) + 1);
dStrcpy(table[e].string, string);
table[e].next = hashTable[bucket];
hashTable[bucket] = e;
table[e].link = firstValid;
table[firstValid].prevLink = e;
firstValid = e;
table[e].prevLink = 0;
mTable[e].refCount++;
mTable[e].string = (char *) mAllocator->alloc(dStrlen(string) + 1);
dStrcpy(mTable[e].string, string);
mTable[e].next = mHashTable[bucket];
mHashTable[bucket] = e;
mTable[e].link = mFirstValid;
mTable[mFirstValid].prevLink = e;
mFirstValid = e;
mTable[e].prevLink = 0;
return e;
}
@ -114,75 +114,75 @@ U32 GameAddTaggedString(const char *string)
const char *NetStringTable::lookupString(U32 id)
{
if(table[id].refCount == 0 && table[id].scriptRefCount == 0)
if(mTable[id].refCount == 0 && mTable[id].scriptRefCount == 0)
return NULL;
return table[id].string;
return mTable[id].string;
}
void NetStringTable::removeString(U32 id, bool script)
{
if(!script)
{
AssertFatal(table[id].refCount != 0, "Error, ref count is already 0!!");
if(--table[id].refCount)
AssertFatal(mTable[id].refCount != 0, "Error, ref count is already 0!!");
if(--mTable[id].refCount)
return;
if(table[id].scriptRefCount)
if(mTable[id].scriptRefCount)
return;
}
else
{
// If both ref counts are already 0, this id is not valid. Ignore
// the remove
if (table[id].scriptRefCount == 0 && table[id].refCount == 0)
if (mTable[id].scriptRefCount == 0 && mTable[id].refCount == 0)
return;
if(table[id].scriptRefCount == 0 && table[id].refCount)
if(mTable[id].scriptRefCount == 0 && mTable[id].refCount)
{
Con::errorf("removeTaggedString failed! Ref count is already 0 for string: %s", table[id].string);
Con::errorf("removeTaggedString failed! Ref count is already 0 for string: %s", mTable[id].string);
return;
}
if(--table[id].scriptRefCount)
if(--mTable[id].scriptRefCount)
return;
if(table[id].refCount)
if(mTable[id].refCount)
return;
}
// unlink first:
U32 prev = table[id].prevLink;
U32 next = table[id].link;
U32 prev = mTable[id].prevLink;
U32 next = mTable[id].link;
if(next)
table[next].prevLink = prev;
mTable[next].prevLink = prev;
if(prev)
table[prev].link = next;
mTable[prev].link = next;
else
firstValid = next;
mFirstValid = next;
// remove it from the hash table
U32 hash = _StringTable::hashString(table[id].string);
U32 hash = _StringTable::hashString(mTable[id].string);
U32 bucket = hash % HashTableSize;
for(U32 *walk = &hashTable[bucket];*walk; walk = &table[*walk].next)
for(U32 *walk = &mHashTable[bucket];*walk; walk = &mTable[*walk].next)
{
if(*walk == id)
{
*walk = table[id].next;
*walk = mTable[id].next;
break;
}
}
table[id].next = firstFree;
firstFree = id;
mTable[id].next = mFirstFree;
mFirstFree = id;
}
void NetStringTable::repack()
{
DataChunker *newAllocator = new DataChunker(DataChunkerSize);
for(U32 walk = firstValid; walk; walk = table[walk].link)
for(U32 walk = mFirstValid; walk; walk = mTable[walk].link)
{
const char *prevStr = table[walk].string;
const char *prevStr = mTable[walk].string;
table[walk].string = (char *) newAllocator->alloc(dStrlen(prevStr) + 1);
dStrcpy(table[walk].string, prevStr);
mTable[walk].string = (char *) newAllocator->alloc(dStrlen(prevStr) + 1);
dStrcpy(mTable[walk].string, prevStr);
}
delete allocator;
allocator = newAllocator;
delete mAllocator;
mAllocator = newAllocator;
}
void NetStringTable::create()
@ -249,21 +249,21 @@ void NetStringTable::dumpToConsole()
{
U32 count = 0;
S32 maxIndex = -1;
for ( U32 i = 0; i < size; i++ )
for ( U32 i = 0; i < mSize; i++ )
{
if ( table[i].refCount > 0 || table[i].scriptRefCount > 0)
if ( mTable[i].refCount > 0 || mTable[i].scriptRefCount > 0)
{
Con::printf( "%d: \"%c%s%c\" REF: %d", i, 0x10, table[i].string, 0x11, table[i].refCount );
if ( maxIndex == -1 || table[i].refCount > table[maxIndex].refCount )
Con::printf( "%d: \"%c%s%c\" REF: %d", i, 0x10, mTable[i].string, 0x11, mTable[i].refCount );
if ( maxIndex == -1 || mTable[i].refCount > mTable[maxIndex].refCount )
maxIndex = i;
count++;
}
}
Con::printf( ">> STRINGS: %d MAX REF COUNT: %d \"%c%s%c\" <<",
count,
( maxIndex == -1 ) ? 0 : table[maxIndex].refCount,
( maxIndex == -1 ) ? 0 : mTable[maxIndex].refCount,
0x10,
( maxIndex == -1 ) ? "" : table[maxIndex].string,
( maxIndex == -1 ) ? "" : mTable[maxIndex].string,
0x11 );
}

View file

@ -60,14 +60,14 @@ class NetStringTable
U32 prevLink;
U32 seq;
};
U32 size;
U32 firstFree;
U32 firstValid;
U32 sequenceCount;
U32 mSize;
U32 mFirstFree;
U32 mFirstValid;
U32 mSequenceCount;
Entry *table;
U32 hashTable[HashTableSize];
DataChunker *allocator;
Entry *mTable;
U32 mHashTable[HashTableSize];
DataChunker *mAllocator;
NetStringTable();
~NetStringTable();

View file

@ -82,9 +82,9 @@ ColladaAppMaterial::ColladaAppMaterial(const domMaterial *pMat)
const domCommon_color_or_texture_type_complexType* domSpecular = findEffectSpecular(effect);
// Wrap flags
if (effectExt->wrapU)
if (effectExt->mWrapU)
flags |= TSMaterialList::S_Wrap;
if (effectExt->wrapV)
if (effectExt->mWrapV)
flags |= TSMaterialList::T_Wrap;
// Set material attributes
@ -146,17 +146,17 @@ ColladaAppMaterial::ColladaAppMaterial(const domMaterial *pMat)
}
// Double-sided flag
doubleSided = effectExt->double_sided;
doubleSided = effectExt->mDoubleSided;
// Get the paths for the various textures => Collada indirection at its finest!
// <texture>.<newparam>.<sampler2D>.<source>.<newparam>.<surface>.<init_from>.<image>.<init_from>
diffuseMap = getSamplerImagePath(effect, getTextureSampler(effect, domDiffuse));
specularMap = getSamplerImagePath(effect, getTextureSampler(effect, domSpecular));
normalMap = getSamplerImagePath(effect, effectExt->bumpSampler);
normalMap = getSamplerImagePath(effect, effectExt->mBumpSampler);
// Set the material name
name = ColladaUtils::getOptions().matNamePrefix;
if ( ColladaUtils::getOptions().useDiffuseNames )
name = ColladaUtils::getOptions().mMatNamePrefix;
if ( ColladaUtils::getOptions().mUseDiffuseNames )
{
Torque::Path diffusePath( diffuseMap );
name += diffusePath.getFileName();

View file

@ -40,8 +40,8 @@ namespace DictHash
using namespace ColladaUtils;
bool ColladaAppMesh::fixedSizeEnabled = false;
S32 ColladaAppMesh::fixedSize = 2;
bool ColladaAppMesh::mFixedSizeEnabled = false;
S32 ColladaAppMesh::mFixedSize = 2;
//-----------------------------------------------------------------------------
// Define a VertTuple dictionary to allow fast tuple lookups
@ -49,7 +49,7 @@ namespace DictHash
{
inline U32 hash(const VertTuple& data)
{
return (U32)data.vertex;
return (U32)data.mVertex;
}
}
@ -197,27 +197,27 @@ private:
public:
_SourceReader points;
_SourceReader normals;
_SourceReader colors;
_SourceReader uvs;
_SourceReader uv2s;
_SourceReader mPoints;
_SourceReader mNormals;
_SourceReader mColors;
_SourceReader mUVs;
_SourceReader mUV2s;
_SourceReader joints;
_SourceReader weights;
_SourceReader invBindMatrices;
_SourceReader mJoints;
_SourceReader mWeights;
_SourceReader mInvBindMatrices;
/// Clear the mesh streams
void reset()
{
points.reset();
normals.reset();
colors.reset();
uvs.reset();
uv2s.reset();
joints.reset();
weights.reset();
invBindMatrices.reset();
mPoints.reset();
mNormals.reset();
mColors.reset();
mUVs.reset();
mUV2s.reset();
mJoints.reset();
mWeights.reset();
mInvBindMatrices.reset();
}
/// Classify a set of inputs by type and set number (needs to be a template
@ -283,32 +283,32 @@ public:
// Attempt to initialise the SourceReaders
const char* vertex_params[] = { "X", "Y", "Z", "" };
initSourceReader(sortedInputs[Points], Points, points, vertex_params);
initSourceReader(sortedInputs[Points], Points, mPoints, vertex_params);
const char* normal_params[] = { "X", "Y", "Z", "" };
initSourceReader(sortedInputs[Normals], Normals, normals, normal_params);
initSourceReader(sortedInputs[Normals], Normals, mNormals, normal_params);
const char* color_params[] = { "R", "G", "B", "A", "" };
initSourceReader(sortedInputs[Colors], Colors, colors, color_params);
initSourceReader(sortedInputs[Colors], Colors, mColors, color_params);
const char* uv_params[] = { "S", "T", "" };
const char* uv_params2[] = { "U", "V", "" }; // some files use the nonstandard U,V or X,Y param names
const char* uv_params3[] = { "X", "Y", "" };
if (!initSourceReader(sortedInputs[UVs], UVs, uvs, uv_params))
if (!initSourceReader(sortedInputs[UVs], UVs, uvs, uv_params2))
initSourceReader(sortedInputs[UVs], UVs, uvs, uv_params3);
if (!initSourceReader(sortedInputs[UV2s], UV2s, uv2s, uv_params))
if (!initSourceReader(sortedInputs[UV2s], UV2s, uv2s, uv_params2))
initSourceReader(sortedInputs[UV2s], UV2s, uv2s, uv_params3);
if (!initSourceReader(sortedInputs[UVs], UVs, mUVs, uv_params))
if (!initSourceReader(sortedInputs[UVs], UVs, mUVs, uv_params2))
initSourceReader(sortedInputs[UVs], UVs, mUVs, uv_params3);
if (!initSourceReader(sortedInputs[UV2s], UV2s, mUV2s, uv_params))
if (!initSourceReader(sortedInputs[UV2s], UV2s, mUV2s, uv_params2))
initSourceReader(sortedInputs[UV2s], UV2s, mUV2s, uv_params3);
const char* joint_params[] = { "JOINT", "" };
initSourceReader(sortedInputs[Joints], Joints, joints, joint_params);
initSourceReader(sortedInputs[Joints], Joints, mJoints, joint_params);
const char* weight_params[] = { "WEIGHT", "" };
initSourceReader(sortedInputs[Weights], Weights, weights, weight_params);
initSourceReader(sortedInputs[Weights], Weights, mWeights, weight_params);
const char* matrix_params[] = { "TRANSFORM", "" };
initSourceReader(sortedInputs[InvBindMatrices], InvBindMatrices, invBindMatrices, matrix_params);
initSourceReader(sortedInputs[InvBindMatrices], InvBindMatrices, mInvBindMatrices, matrix_params);
return true;
}
@ -317,19 +317,19 @@ public:
//------------------------------------------------------------------------------
ColladaAppMesh::ColladaAppMesh(const domInstance_geometry* instance, ColladaAppNode* node)
: instanceGeom(instance), instanceCtrl(0), appNode(node), geomExt(0)
: mInstanceGeom(instance), mInstanceCtrl(0), mAppNode(node), mGeomExt(0)
{
flags = 0;
numFrames = 0;
numMatFrames = 0;
mFlags = 0;
mNumFrames = 0;
mNumMatFrames = 0;
}
ColladaAppMesh::ColladaAppMesh(const domInstance_controller* instance, ColladaAppNode* node)
: instanceGeom(0), instanceCtrl(instance), appNode(node), geomExt(0)
: mInstanceGeom(0), mInstanceCtrl(instance), mAppNode(node), mGeomExt(0)
{
flags = 0;
numFrames = 0;
numMatFrames = 0;
mFlags = 0;
mNumFrames = 0;
mNumMatFrames = 0;
}
const char* ColladaAppMesh::getName(bool allowFixed)
@ -337,27 +337,27 @@ const char* ColladaAppMesh::getName(bool allowFixed)
// Some exporters add a 'PIVOT' or unnamed node between the mesh and the
// actual object node. Detect this and return the object node name instead
// of the pivot node.
const char* nodeName = appNode->getName();
const char* nodeName = mAppNode->getName();
if ( dStrEqual(nodeName, "null") || dStrEndsWith(nodeName, "PIVOT") )
nodeName = appNode->getParentName();
nodeName = mAppNode->getParentName();
// If all geometry is being fixed to the same size, append the size
// to the name
return allowFixed && fixedSizeEnabled ? avar("%s %d", nodeName, fixedSize) : nodeName;
return allowFixed && mFixedSizeEnabled ? avar("%s %d", nodeName, mFixedSize) : nodeName;
}
MatrixF ColladaAppMesh::getMeshTransform(F32 time)
{
return appNode->getNodeTransform(time);
return mAppNode->getNodeTransform(time);
}
bool ColladaAppMesh::animatesVis(const AppSequence* appSeq)
{
#define IS_VIS_ANIMATED(node) \
(dynamic_cast<const ColladaAppNode*>(node)->nodeExt->visibility.isAnimated(appSeq->getStart(), appSeq->getEnd()))
(dynamic_cast<const ColladaAppNode*>(node)->nodeExt->mVisibility.isAnimated(appSeq->getStart(), appSeq->getEnd()))
// Check if the node visibility is animated within the sequence interval
return IS_VIS_ANIMATED(appNode) || (appNode->appParent ? IS_VIS_ANIMATED(appNode->appParent) : false);
return IS_VIS_ANIMATED(mAppNode) || (mAppNode->appParent ? IS_VIS_ANIMATED(mAppNode->appParent) : false);
}
bool ColladaAppMesh::animatesMatFrame(const AppSequence* appSeq)
@ -367,8 +367,8 @@ bool ColladaAppMesh::animatesMatFrame(const AppSequence* appSeq)
// - by animating the morph weights for morph targets with different UVs
// Check if the MAYA profile texture transform is animated
for (S32 iMat = 0; iMat < appMaterials.size(); iMat++) {
ColladaAppMaterial* appMat = static_cast<ColladaAppMaterial*>(appMaterials[iMat]);
for (S32 iMat = 0; iMat < mAppMaterials.size(); iMat++) {
ColladaAppMaterial* appMat = static_cast<ColladaAppMaterial*>(mAppMaterials[iMat]);
if (appMat->effectExt &&
appMat->effectExt->animatesTextureTransform(appSeq->getStart(), appSeq->getEnd()))
return true;
@ -418,10 +418,10 @@ bool ColladaAppMesh::animatesFrame(const AppSequence* appSeq)
F32 ColladaAppMesh::getVisValue(F32 t)
{
#define GET_VIS(node) \
(dynamic_cast<const ColladaAppNode*>(node)->nodeExt->visibility.getValue(t))
(dynamic_cast<const ColladaAppNode*>(node)->nodeExt->mVisibility.getValue(t))
// Get the visibility of the mesh's node at time, 't'
return GET_VIS(appNode) * (appNode->appParent ? GET_VIS(appNode->appParent) : 1.0f);
return GET_VIS(mAppNode) * (mAppNode->appParent ? GET_VIS(mAppNode->appParent) : 1.0f);
}
S32 ColladaAppMesh::addMaterial(const char* symbol)
@ -431,14 +431,14 @@ S32 ColladaAppMesh::addMaterial(const char* symbol)
// Lookup the symbol in the materials already bound to this geometry/controller
// instance
Map<StringTableEntry,U32>::Iterator itr = boundMaterials.find(symbol);
if (itr != boundMaterials.end())
Map<StringTableEntry,U32>::Iterator itr = mBoundMaterials.find(symbol);
if (itr != mBoundMaterials.end())
return itr->value;
// Find the Collada material that this symbol maps to
U32 matIndex = TSDrawPrimitive::NoMaterial;
const domBind_material* binds = instanceGeom ? instanceGeom->getBind_material() :
instanceCtrl->getBind_material();
const domBind_material* binds = mInstanceGeom ? mInstanceGeom->getBind_material() :
mInstanceCtrl->getBind_material();
if (binds) {
const domInstance_material_Array& matArray = binds->getTechnique_common()->getInstance_material_array();
for (S32 iBind = 0; iBind < matArray.getCount(); iBind++) {
@ -446,17 +446,17 @@ S32 ColladaAppMesh::addMaterial(const char* symbol)
// Find the index of the bound material in the shape global list
const domMaterial* mat = daeSafeCast<domMaterial>(matArray[iBind]->getTarget().getElement());
for (matIndex = 0; matIndex < appMaterials.size(); matIndex++) {
if (static_cast<ColladaAppMaterial*>(appMaterials[matIndex])->mat == mat)
for (matIndex = 0; matIndex < mAppMaterials.size(); matIndex++) {
if (static_cast<ColladaAppMaterial*>(mAppMaterials[matIndex])->mat == mat)
break;
}
// Check if this material needs to be added to the shape global list
if (matIndex == appMaterials.size()) {
if (matIndex == mAppMaterials.size()) {
if (mat)
appMaterials.push_back(new ColladaAppMaterial(mat));
mAppMaterials.push_back(new ColladaAppMaterial(mat));
else
appMaterials.push_back(new ColladaAppMaterial(symbol));
mAppMaterials.push_back(new ColladaAppMaterial(symbol));
}
break;
@ -466,23 +466,23 @@ S32 ColladaAppMesh::addMaterial(const char* symbol)
else
{
// No Collada material is present for this symbol, so just create an empty one
appMaterials.push_back(new ColladaAppMaterial(symbol));
mAppMaterials.push_back(new ColladaAppMaterial(symbol));
}
// Add this symbol to the bound list for the mesh
boundMaterials.insert(StringTable->insert(symbol), matIndex);
mBoundMaterials.insert(StringTable->insert(symbol), matIndex);
return matIndex;
}
void ColladaAppMesh::getPrimitives(const domGeometry* geometry)
{
// Only do this once
if (primitives.size())
if (mPrimitives.size())
return;
// Read the <geometry> extension
if (!geomExt)
geomExt = new ColladaExtension_geometry(geometry);
if (!mGeomExt)
mGeomExt = new ColladaExtension_geometry(geometry);
// Get the supported primitive elements for this geometry, and warn
// about unsupported elements
@ -517,25 +517,25 @@ void ColladaAppMesh::getPrimitives(const domGeometry* geometry)
continue;
// Create TSMesh primitive
primitives.increment();
TSDrawPrimitive& primitive = primitives.last();
primitive.start = indices.size();
mPrimitives.increment();
TSDrawPrimitive& primitive = mPrimitives.last();
primitive.start = mIndices.size();
primitive.matIndex = (TSDrawPrimitive::Triangles | TSDrawPrimitive::Indexed) |
addMaterial(meshPrims[iPrim]->getMaterial());
// Get the AppMaterial associated with this primitive
ColladaAppMaterial* appMat = 0;
if (!(primitive.matIndex & TSDrawPrimitive::NoMaterial))
appMat = static_cast<ColladaAppMaterial*>(appMaterials[primitive.matIndex & TSDrawPrimitive::MaterialMask]);
appMat = static_cast<ColladaAppMaterial*>(mAppMaterials[primitive.matIndex & TSDrawPrimitive::MaterialMask]);
// Force the material to be double-sided if this geometry is double-sided.
if (geomExt->double_sided && appMat && appMat->effectExt)
appMat->effectExt->double_sided = true;
if (mGeomExt->mDoubleSided && appMat && appMat->effectExt)
appMat->effectExt->mDoubleSided = true;
// Pre-allocate triangle indices
primitive.numElements = numTriangles * 3;
indices.setSize(indices.size() + primitive.numElements);
U32* dstIndex = indices.end() - primitive.numElements;
mIndices.setSize(mIndices.size() + primitive.numElements);
U32* dstIndex = mIndices.end() - primitive.numElements;
// Determine the offset for each element type in the stream, and also the
// maximum input offset, which will be the number of indices per vertex we
@ -555,12 +555,12 @@ void ColladaAppMesh::getPrimitives(const domGeometry* geometry)
// If the next triangle could cause us to index across a 16-bit
// boundary, split this primitive and clear the tuple map to
// ensure primitives only index verts within a 16-bit range.
if (vertTuples.size() &&
(((vertTuples.size()-1) ^ (vertTuples.size()+2)) & 0x10000))
if (mVertTuples.size() &&
(((mVertTuples.size()-1) ^ (mVertTuples.size()+2)) & 0x10000))
{
// Pad vertTuples up to the next 16-bit boundary
while (vertTuples.size() & 0xFFFF)
vertTuples.push_back(VertTuple(vertTuples.last()));
while (mVertTuples.size() & 0xFFFF)
mVertTuples.push_back(VertTuple(mVertTuples.last()));
// Split the primitive at the current triangle
S32 indicesRemaining = (numTriangles - iTri) * 3;
@ -569,12 +569,12 @@ void ColladaAppMesh::getPrimitives(const domGeometry* geometry)
daeErrorHandler::get()->handleWarning(avar("Splitting primitive "
"in %s: too many verts for 16-bit indices.", _GetNameOrId(geometry)));
primitives.last().numElements -= indicesRemaining;
primitives.push_back(TSDrawPrimitive(primitives.last()));
mPrimitives.last().numElements -= indicesRemaining;
mPrimitives.push_back(TSDrawPrimitive(mPrimitives.last()));
}
primitives.last().numElements = indicesRemaining;
primitives.last().start = indices.size() - indicesRemaining;
mPrimitives.last().numElements = indicesRemaining;
mPrimitives.last().start = mIndices.size() - indicesRemaining;
tupleMap.clear();
}
@ -586,29 +586,29 @@ void ColladaAppMesh::getPrimitives(const domGeometry* geometry)
// Collect vert tuples into a single array so we can easily grab
// vertex data later.
VertTuple tuple;
tuple.prim = iPrim;
tuple.vertex = offsets[MeshStreams::Points] >= 0 ? pSrcData[offsets[MeshStreams::Points]] : -1;
tuple.normal = offsets[MeshStreams::Normals] >= 0 ? pSrcData[offsets[MeshStreams::Normals]] : -1;
tuple.color = offsets[MeshStreams::Colors] >= 0 ? pSrcData[offsets[MeshStreams::Colors]] : -1;
tuple.uv = offsets[MeshStreams::UVs] >= 0 ? pSrcData[offsets[MeshStreams::UVs]] : -1;
tuple.uv2 = offsets[MeshStreams::UV2s] >= 0 ? pSrcData[offsets[MeshStreams::UV2s]] : -1;
tuple.mPrim = iPrim;
tuple.mVertex = offsets[MeshStreams::Points] >= 0 ? pSrcData[offsets[MeshStreams::Points]] : -1;
tuple.mNormal = offsets[MeshStreams::Normals] >= 0 ? pSrcData[offsets[MeshStreams::Normals]] : -1;
tuple.mColor = offsets[MeshStreams::Colors] >= 0 ? pSrcData[offsets[MeshStreams::Colors]] : -1;
tuple.mUV = offsets[MeshStreams::UVs] >= 0 ? pSrcData[offsets[MeshStreams::UVs]] : -1;
tuple.mUV2 = offsets[MeshStreams::UV2s] >= 0 ? pSrcData[offsets[MeshStreams::UV2s]] : -1;
tuple.dataVertex = tuple.vertex > -1 ? streams.points.getPoint3FValue(tuple.vertex) : Point3F::Max;
tuple.dataNormal = tuple.normal > -1 ? streams.normals.getPoint3FValue(tuple.normal) : Point3F::Max;
tuple.dataColor = tuple.color > -1 ? streams.colors.getColorIValue(tuple.color) : ColorI(0,0,0);
tuple.dataUV = tuple.uv > -1 ? streams.uvs.getPoint2FValue(tuple.uv) : Point2F::Max;
tuple.dataUV2 = tuple.uv2 > -1 ? streams.uv2s.getPoint2FValue(tuple.uv2) : Point2F::Max;
tuple.mDataVertex = tuple.mVertex > -1 ? streams.mPoints.getPoint3FValue(tuple.mVertex) : Point3F::Max;
tuple.mDataNormal = tuple.mNormal > -1 ? streams.mNormals.getPoint3FValue(tuple.mNormal) : Point3F::Max;
tuple.mDataColor = tuple.mColor > -1 ? streams.mColors.getColorIValue(tuple.mColor) : ColorI(0,0,0);
tuple.mDataUV = tuple.mUV > -1 ? streams.mUVs.getPoint2FValue(tuple.mUV) : Point2F::Max;
tuple.mDataUV2 = tuple.mUV2 > -1 ? streams.mUV2s.getPoint2FValue(tuple.mUV2) : Point2F::Max;
VertTupleMap::Iterator itr = tupleMap.find(tuple);
if (itr == tupleMap.end())
{
itr = tupleMap.insert(tuple, vertTuples.size());
vertTuples.push_back(tuple);
itr = tupleMap.insert(tuple, mVertTuples.size());
mVertTuples.push_back(tuple);
}
// Collada uses CCW for front face and Torque uses the opposite, so
// for normal (non-inverted) meshes, the indices are flipped.
if (appNode->invertMeshes)
if (mAppNode->invertMeshes)
dstIndex[v] = itr->value;
else
dstIndex[2 - v] = itr->value;
@ -631,7 +631,7 @@ void ColladaAppMesh::getVertexData(const domGeometry* geometry, F32 time, const
Vector<Point2F>& v_uv2s,
bool appendValues)
{
if (!primitives.size())
if (!mPrimitives.size())
return;
MeshStreams streams;
@ -648,24 +648,24 @@ void ColladaAppMesh::getVertexData(const domGeometry* geometry, F32 time, const
// If appending values, pre-allocate the arrays
if (appendValues) {
v_points.setSize(v_points.size() + vertTuples.size());
v_uvs.setSize(v_uvs.size() + vertTuples.size());
v_points.setSize(v_points.size() + mVertTuples.size());
v_uvs.setSize(v_uvs.size() + mVertTuples.size());
}
// Get pointers to arrays
Point3F* points_array = &v_points[v_points.size() - vertTuples.size()];
Point2F* uvs_array = &v_uvs[v_uvs.size() - vertTuples.size()];
Point3F* points_array = &v_points[v_points.size() - mVertTuples.size()];
Point2F* uvs_array = &v_uvs[v_uvs.size() - mVertTuples.size()];
Point3F* norms_array = NULL;
ColorI* colors_array = NULL;
Point2F* uv2s_array = NULL;
for (S32 iVert = 0; iVert < vertTuples.size(); iVert++) {
for (S32 iVert = 0; iVert < mVertTuples.size(); iVert++) {
const VertTuple& tuple = vertTuples[iVert];
const VertTuple& tuple = mVertTuples[iVert];
// Change primitives?
if (tuple.prim != lastPrimitive) {
if (meshPrims.size() <= tuple.prim) {
if (tuple.mPrim != lastPrimitive) {
if (meshPrims.size() <= tuple.mPrim) {
daeErrorHandler::get()->handleError(avar("Failed to get vertex data "
"for %s. Primitives do not match base geometry.", geometry->getID()));
break;
@ -673,31 +673,31 @@ void ColladaAppMesh::getVertexData(const domGeometry* geometry, F32 time, const
// Update vertex/normal/UV streams and get the new material index
streams.reset();
streams.readInputs(meshPrims[tuple.prim]->getInputs());
S32 matIndex = addMaterial(meshPrims[tuple.prim]->getMaterial());
streams.readInputs(meshPrims[tuple.mPrim]->getInputs());
S32 matIndex = addMaterial(meshPrims[tuple.mPrim]->getMaterial());
if (matIndex != TSDrawPrimitive::NoMaterial)
appMat = static_cast<ColladaAppMaterial*>(appMaterials[matIndex]);
appMat = static_cast<ColladaAppMaterial*>(mAppMaterials[matIndex]);
else
appMat = 0;
lastPrimitive = tuple.prim;
lastPrimitive = tuple.mPrim;
}
// If we are NOT appending values, only set the value if it actually exists
// in the mesh data stream.
if (appendValues || ((tuple.vertex >= 0) && (tuple.vertex < streams.points.size()))) {
points_array[iVert] = streams.points.getPoint3FValue(tuple.vertex);
if (appendValues || ((tuple.mVertex >= 0) && (tuple.mVertex < streams.mPoints.size()))) {
points_array[iVert] = streams.mPoints.getPoint3FValue(tuple.mVertex);
// Flip verts for inverted meshes
if (appNode->invertMeshes)
if (mAppNode->invertMeshes)
points_array[iVert].z = -points_array[iVert].z;
objOffset.mulP(points_array[iVert]);
}
if (appendValues || ((tuple.uv >= 0) && (tuple.uv < streams.uvs.size()))) {
uvs_array[iVert] = streams.uvs.getPoint2FValue(tuple.uv);
if (appendValues || ((tuple.mUV >= 0) && (tuple.mUV < streams.mUVs.size()))) {
uvs_array[iVert] = streams.mUVs.getPoint2FValue(tuple.mUV);
if (appMat && appMat->effectExt)
appMat->effectExt->applyTextureTransform(uvs_array[iVert], time);
uvs_array[iVert].y = 1.0f - uvs_array[iVert].y; // Collada texcoords are upside down compared to TGE
@ -705,45 +705,45 @@ void ColladaAppMesh::getVertexData(const domGeometry* geometry, F32 time, const
// The rest is non-required data... if it doesn't exist then don't append it.
if ( (tuple.normal >= 0) && (tuple.normal < streams.normals.size()) ) {
if ( (tuple.mNormal >= 0) && (tuple.mNormal < streams.mNormals.size()) ) {
if ( !norms_array && iVert == 0 )
{
v_norms.setSize(v_norms.size() + vertTuples.size());
norms_array = &v_norms[v_norms.size() - vertTuples.size()];
v_norms.setSize(v_norms.size() + mVertTuples.size());
norms_array = &v_norms[v_norms.size() - mVertTuples.size()];
}
if ( norms_array ) {
norms_array[iVert] = streams.normals.getPoint3FValue(tuple.normal);
norms_array[iVert] = streams.mNormals.getPoint3FValue(tuple.mNormal);
// Flip normals for inverted meshes
if (appNode->invertMeshes)
if (mAppNode->invertMeshes)
norms_array[iVert].z = -norms_array[iVert].z;
}
}
if ( (tuple.color >= 0) && (tuple.color < streams.colors.size()))
if ( (tuple.mColor >= 0) && (tuple.mColor < streams.mColors.size()))
{
if ( !colors_array && iVert == 0 )
{
v_colors.setSize(v_colors.size() + vertTuples.size());
colors_array = &v_colors[v_colors.size() - vertTuples.size()];
v_colors.setSize(v_colors.size() + mVertTuples.size());
colors_array = &v_colors[v_colors.size() - mVertTuples.size()];
}
if ( colors_array )
colors_array[iVert] = streams.colors.getColorIValue(tuple.color);
colors_array[iVert] = streams.mColors.getColorIValue(tuple.mColor);
}
if ( (tuple.uv2 >= 0) && (tuple.uv2 < streams.uv2s.size()) )
if ( (tuple.mUV2 >= 0) && (tuple.mUV2 < streams.mUV2s.size()) )
{
if ( !uv2s_array && iVert == 0 )
{
v_uv2s.setSize(v_uv2s.size() + vertTuples.size());
uv2s_array = &v_uv2s[v_uv2s.size() - vertTuples.size()];
v_uv2s.setSize(v_uv2s.size() + mVertTuples.size());
uv2s_array = &v_uv2s[v_uv2s.size() - mVertTuples.size()];
}
if ( uv2s_array )
{
uv2s_array[iVert] = streams.uv2s.getPoint2FValue(tuple.uv2);
uv2s_array[iVert] = streams.mUV2s.getPoint2FValue(tuple.mUV2);
if (appMat && appMat->effectExt)
appMat->effectExt->applyTextureTransform(uv2s_array[iVert], time);
uv2s_array[iVert].y = 1.0f - uv2s_array[iVert].y; // Collada texcoords are upside down compared to TGE
@ -810,11 +810,11 @@ void ColladaAppMesh::getMorphVertexData(const domMorph* morph, F32 time, const M
getVertexData(baseGeometry, time, objOffset, v_points, v_norms, v_colors, v_uvs, v_uv2s, true);
// Get pointers to the arrays of base geometry data
Point3F* points_array = &v_points[v_points.size() - vertTuples.size()];
Point3F* norms_array = &v_norms[v_norms.size() - vertTuples.size()];
Point2F* uvs_array = &v_uvs[v_uvs.size() - vertTuples.size()];
ColorI* colors_array = v_colors.size() ? &v_colors[v_colors.size() - vertTuples.size()] : 0;
Point2F* uv2s_array = v_uv2s.size() ? &v_uv2s[v_uv2s.size() - vertTuples.size()] : 0;
Point3F* points_array = &v_points[v_points.size() - mVertTuples.size()];
Point3F* norms_array = &v_norms[v_norms.size() - mVertTuples.size()];
Point2F* uvs_array = &v_uvs[v_uvs.size() - mVertTuples.size()];
ColorI* colors_array = v_colors.size() ? &v_colors[v_colors.size() - mVertTuples.size()] : 0;
Point2F* uv2s_array = v_uv2s.size() ? &v_uv2s[v_uv2s.size() - mVertTuples.size()] : 0;
// Normalize base vertex data?
if (morph->getMethod() == MORPHMETHODTYPE_NORMALIZED) {
@ -827,14 +827,14 @@ void ColladaAppMesh::getMorphVertexData(const domMorph* morph, F32 time, const M
// Result = Base*(1.0-w1-w2 ... -wN) + w1*Target1 + w2*Target2 ... + wN*TargetN
weightSum = mClampF(1.0f - weightSum, 0.0f, 1.0f);
for (S32 iVert = 0; iVert < vertTuples.size(); iVert++) {
for (S32 iVert = 0; iVert < mVertTuples.size(); iVert++) {
points_array[iVert] *= weightSum;
norms_array[iVert] *= weightSum;
uvs_array[iVert] *= weightSum;
}
if (uv2s_array) {
for (S32 iVert = 0; iVert < vertTuples.size(); iVert++)
for (S32 iVert = 0; iVert < mVertTuples.size(); iVert++)
uv2s_array[iVert] *= weightSum;
}
}
@ -855,29 +855,29 @@ void ColladaAppMesh::getMorphVertexData(const domMorph* morph, F32 time, const M
// Copy base geometry into target geometry (will be used if target does
// not define normals or uvs)
targetPoints.set(points_array, vertTuples.size());
targetNorms.set(norms_array, vertTuples.size());
targetUvs.set(uvs_array, vertTuples.size());
targetPoints.set(points_array, mVertTuples.size());
targetNorms.set(norms_array, mVertTuples.size());
targetUvs.set(uvs_array, mVertTuples.size());
if (colors_array)
targetColors.set(colors_array, vertTuples.size());
targetColors.set(colors_array, mVertTuples.size());
if (uv2s_array)
targetUv2s.set(uv2s_array, vertTuples.size());
targetUv2s.set(uv2s_array, mVertTuples.size());
getVertexData(targetGeoms[iTarget], time, objOffset, targetPoints, targetNorms, targetColors, targetUvs, targetUv2s, false);
// Combine with base geometry
for (S32 iVert = 0; iVert < vertTuples.size(); iVert++) {
for (S32 iVert = 0; iVert < mVertTuples.size(); iVert++) {
points_array[iVert] += targetPoints[iVert] * targetWeights[iTarget];
norms_array[iVert] += targetNorms[iVert] * targetWeights[iTarget];
uvs_array[iVert] += targetUvs[iVert] * targetWeights[iTarget];
}
if (uv2s_array) {
for (S32 iVert = 0; iVert < vertTuples.size(); iVert++)
for (S32 iVert = 0; iVert < mVertTuples.size(); iVert++)
uv2s_array[iVert] += targetUv2s[iVert] * targetWeights[iTarget];
}
if (colors_array) {
for (S32 iVert = 0; iVert < vertTuples.size(); iVert++)
for (S32 iVert = 0; iVert < mVertTuples.size(); iVert++)
colors_array[iVert] += targetColors[iVert] * (F32)targetWeights[iTarget];
}
}
@ -891,12 +891,12 @@ void ColladaAppMesh::lockMesh(F32 t, const MatrixF& objOffset)
// 3) a skin (skin geometry could also be a morph!)
daeElement* geometry = 0;
if (instanceGeom) {
if (mInstanceGeom) {
// Simple, static mesh
geometry = instanceGeom->getUrl().getElement();
geometry = mInstanceGeom->getUrl().getElement();
}
else if (instanceCtrl) {
const domController* ctrl = daeSafeCast<domController>(instanceCtrl->getUrl().getElement());
else if (mInstanceCtrl) {
const domController* ctrl = daeSafeCast<domController>(mInstanceCtrl->getUrl().getElement());
if (!ctrl) {
daeErrorHandler::get()->handleWarning(avar("Failed to find <controller> "
"element for %s", getName()));
@ -922,11 +922,10 @@ void ColladaAppMesh::lockMesh(F32 t, const MatrixF& objOffset)
// Now get the vertex data at the specified time
if (geometry->getElementType() == COLLADA_TYPE::GEOMETRY) {
getPrimitives(daeSafeCast<domGeometry>(geometry));
getVertexData(daeSafeCast<domGeometry>(geometry), t, objOffset, points, normals, colors, uvs, uv2s, true);
getPrimitives(daeSafeCast<domGeometry>(geometry));(daeSafeCast<domGeometry>(geometry), t, objOffset, mPoints, mNormals, mColors, mUVs, mUV2s, true);
}
else if (geometry->getElementType() == COLLADA_TYPE::MORPH) {
getMorphVertexData(daeSafeCast<domMorph>(geometry), t, objOffset, points, normals, colors, uvs, uv2s);
getMorphVertexData(daeSafeCast<domMorph>(geometry), t, objOffset, mPoints, mNormals, mColors, mUVs, mUV2s);
}
else {
daeErrorHandler::get()->handleWarning(avar("Unsupported geometry type "
@ -937,11 +936,11 @@ void ColladaAppMesh::lockMesh(F32 t, const MatrixF& objOffset)
void ColladaAppMesh::lookupSkinData()
{
// Only lookup skin data once
if (!isSkin() || weight.size())
if (!isSkin() || mWeight.size())
return;
// Get the skin and vertex weight data
const domSkin* skin = daeSafeCast<domController>(instanceCtrl->getUrl().getElement())->getSkin();
const domSkin* skin = daeSafeCast<domController>(mInstanceCtrl->getUrl().getElement())->getSkin();
const domSkin::domVertex_weights& weightIndices = *(skin->getVertex_weights());
const domListOfInts& weights_v = weightIndices.getV()->getValue();
const domListOfUInts& weights_vcount = weightIndices.getVcount()->getValue();
@ -950,7 +949,7 @@ void ColladaAppMesh::lookupSkinData()
streams.readInputs(skin->getJoints()->getInput_array());
streams.readInputs(weightIndices.getInput_array());
MatrixF invObjOffset(objectOffset);
MatrixF invObjOffset(mObjectOffset);
invObjOffset.inverse();
// Get the bind shape matrix
@ -971,17 +970,17 @@ void ColladaAppMesh::lookupSkinData()
// Set vertex weights
bool tooManyWeightsWarning = false;
for (S32 iVert = 0; iVert < vertsPerFrame; iVert++) {
for (S32 iVert = 0; iVert < mVertsPerFrame; iVert++) {
const domUint* vcount = (domUint*)weights_vcount.getRaw(0);
const domInt* vindices = (domInt*)weights_v.getRaw(0);
vindices += vindicesOffset[vertTuples[iVert].vertex];
vindices += vindicesOffset[mVertTuples[iVert].mVertex];
S32 nonZeroWeightCount = 0;
for (S32 iWeight = 0; iWeight < vcount[vertTuples[iVert].vertex]; iWeight++) {
for (S32 iWeight = 0; iWeight < vcount[mVertTuples[iVert].mVertex]; iWeight++) {
S32 bIndex = vindices[iWeight*2];
F32 bWeight = streams.weights.getFloatValue( vindices[iWeight*2 + 1] );
F32 bWeight = streams.mWeights.getFloatValue( vindices[iWeight*2 + 1] );
// Ignore empty weights
if ( bIndex < 0 || bWeight == 0 )
@ -990,7 +989,7 @@ void ColladaAppMesh::lookupSkinData()
// Limit the number of weights per bone (keep the N largest influences)
if ( nonZeroWeightCount >= TSSkinMesh::BatchData::maxBonePerVert )
{
if (vcount[vertTuples[iVert].vertex] > TSSkinMesh::BatchData::maxBonePerVert)
if (vcount[mVertTuples[iVert].mVertex] > TSSkinMesh::BatchData::maxBonePerVert)
{
if (!tooManyWeightsWarning)
{
@ -1002,25 +1001,25 @@ void ColladaAppMesh::lookupSkinData()
}
// Too many weights => find and replace the smallest one
S32 minIndex = weight.size() - TSSkinMesh::BatchData::maxBonePerVert;
F32 minWeight = weight[minIndex];
for (S32 i = minIndex + 1; i < weight.size(); i++)
S32 minIndex = mWeight.size() - TSSkinMesh::BatchData::maxBonePerVert;
F32 minWeight = mWeight[minIndex];
for (S32 i = minIndex + 1; i < mWeight.size(); i++)
{
if (weight[i] < minWeight)
if (mWeight[i] < minWeight)
{
minWeight = weight[i];
minWeight = mWeight[i];
minIndex = i;
}
}
boneIndex[minIndex] = bIndex;
weight[minIndex] = bWeight;
mBoneIndex[minIndex] = bIndex;
mWeight[minIndex] = bWeight;
}
else
{
vertexIndex.push_back( iVert );
boneIndex.push_back( bIndex );
weight.push_back( bWeight );
mVertexIndex.push_back( iVert );
mBoneIndex.push_back( bIndex );
mWeight.push_back( bWeight );
nonZeroWeightCount++;
}
}
@ -1028,36 +1027,36 @@ void ColladaAppMesh::lookupSkinData()
// Normalize vertex weights (force weights for each vert to sum to 1)
S32 iWeight = 0;
while (iWeight < weight.size()) {
while (iWeight < mWeight.size()) {
// Find the last weight with the same vertex number, and sum all weights for
// that vertex
F32 invTotalWeight = 0;
S32 iLast;
for (iLast = iWeight; iLast < weight.size(); iLast++) {
if (vertexIndex[iLast] != vertexIndex[iWeight])
for (iLast = iWeight; iLast < mWeight.size(); iLast++) {
if (mVertexIndex[iLast] != mVertexIndex[iWeight])
break;
invTotalWeight += weight[iLast];
invTotalWeight += mWeight[iLast];
}
// Then normalize the vertex weights
invTotalWeight = 1.0f / invTotalWeight;
for (; iWeight < iLast; iWeight++)
weight[iWeight] *= invTotalWeight;
mWeight[iWeight] *= invTotalWeight;
}
// Add dummy AppNodes to allow Collada joints to be mapped to 3space nodes
bones.setSize(streams.joints.size());
initialTransforms.setSize(streams.joints.size());
for (S32 iJoint = 0; iJoint < streams.joints.size(); iJoint++)
mBones.setSize(streams.mJoints.size());
mInitialTransforms.setSize(streams.mJoints.size());
for (S32 iJoint = 0; iJoint < streams.mJoints.size(); iJoint++)
{
const char* jointName = streams.joints.getStringValue(iJoint);
const char* jointName = streams.mJoints.getStringValue(iJoint);
// Lookup the joint element
const domNode* joint = 0;
if (instanceCtrl->getSkeleton_array().getCount()) {
if (mInstanceCtrl->getSkeleton_array().getCount()) {
// Search for the node using the <skeleton> as the base element
for (S32 iSkel = 0; iSkel < instanceCtrl->getSkeleton_array().getCount(); iSkel++) {
xsAnyURI skeleton = instanceCtrl->getSkeleton_array()[iSkel]->getValue();
for (S32 iSkel = 0; iSkel < mInstanceCtrl->getSkeleton_array().getCount(); iSkel++) {
xsAnyURI skeleton = mInstanceCtrl->getSkeleton_array()[iSkel]->getValue();
daeSIDResolver resolver(skeleton.getElement(), jointName);
joint = daeSafeCast<domNode>(resolver.getElement());
if (joint)
@ -1072,33 +1071,33 @@ void ColladaAppMesh::lookupSkinData()
if (!joint) {
daeErrorHandler::get()->handleWarning(avar("Failed to find bone '%s', "
"defaulting to instance_controller parent node '%s'", jointName, appNode->getName()));
joint = appNode->getDomNode();
"defaulting to instance_controller parent node '%s'", jointName, mAppNode->getName()));
joint = mAppNode->getDomNode();
}
bones[iJoint] = new ColladaAppNode(joint);
mBones[iJoint] = new ColladaAppNode(joint);
initialTransforms[iJoint] = objectOffset;
mInitialTransforms[iJoint] = mObjectOffset;
// Bone scaling is generally ignored during import, since 3space only
// stores default node transform and rotation. Compensate for this by
// removing the scaling from the inverse bind transform as well
MatrixF invBind = streams.invBindMatrices.getMatrixFValue(iJoint);
if (!ColladaUtils::getOptions().ignoreNodeScale)
MatrixF invBind = streams.mInvBindMatrices.getMatrixFValue(iJoint);
if (!ColladaUtils::getOptions().mIgnoreNodeScale)
{
Point3F invScale = invBind.getScale();
invScale.x = invScale.x ? (1.0f / invScale.x) : 0;
invScale.y = invScale.y ? (1.0f / invScale.y) : 0;
invScale.z = invScale.z ? (1.0f / invScale.z) : 0;
initialTransforms[iJoint].scale(invScale);
mInitialTransforms[iJoint].scale(invScale);
}
// Inverted node coordinate spaces (negative scale factor) are corrected
// in ColladaAppNode::getNodeTransform, so need to apply the same operation
// here to match
if (m_matF_determinant(invBind) < 0.0f)
initialTransforms[iJoint].scale(Point3F(1, 1, -1));
mInitialTransforms[iJoint].scale(Point3F(1, 1, -1));
initialTransforms[iJoint].mul(invBind);
initialTransforms[iJoint].mul(bindShapeMatrix);
mInitialTransforms[iJoint].mul(invBind);
mInitialTransforms[iJoint].mul(bindShapeMatrix);
}
}

View file

@ -57,20 +57,20 @@
// AND all of the target geometries because they MUST have the same topology.
struct VertTuple
{
S32 prim, vertex, normal, color, uv, uv2;
S32 mPrim, mVertex, mNormal, mColor, mUV, mUV2;
Point3F dataVertex, dataNormal;
ColorI dataColor;
Point2F dataUV, dataUV2;
Point3F mDataVertex, mDataNormal;
ColorI mDataColor;
Point2F mDataUV, mDataUV2;
VertTuple(): prim(-1), vertex(-1), normal(-1), color(-1), uv(-1), uv2(-1) {}
VertTuple(): mPrim(-1), mVertex(-1), mNormal(-1), mColor(-1), mUV(-1), mUV2(-1) {}
bool operator==(const VertTuple& p) const
{
return dataVertex == p.dataVertex &&
dataColor == p.dataColor &&
dataNormal == p.dataNormal &&
dataUV == p.dataUV &&
dataUV2 == p.dataUV2;
return mDataVertex == p.mDataVertex &&
mDataColor == p.mDataColor &&
mDataNormal == p.mDataNormal &&
mDataUV == p.mDataUV &&
mDataUV2 == p.mDataUV2;
}
};
@ -79,24 +79,24 @@ class ColladaAppMesh : public AppMesh
typedef AppMesh Parent;
protected:
class ColladaAppNode* appNode; ///< Pointer to the node that owns this mesh
const domInstance_geometry* instanceGeom;
const domInstance_controller* instanceCtrl;
ColladaExtension_geometry* geomExt; ///< geometry extension
class ColladaAppNode* mAppNode; ///< Pointer to the node that owns this mesh
const domInstance_geometry* mInstanceGeom;
const domInstance_controller* mInstanceCtrl;
ColladaExtension_geometry* mGeomExt; ///< geometry extension
Vector<VertTuple> vertTuples; ///<
Map<StringTableEntry,U32> boundMaterials; ///< Local map of symbols to materials
Vector<VertTuple> mVertTuples; ///<
Map<StringTableEntry,U32> mBoundMaterials; ///< Local map of symbols to materials
static bool fixedSizeEnabled; ///< Set to true to fix the detail size to a particular value for all geometry
static S32 fixedSize; ///< The fixed detail size value for all geometry
static bool mFixedSizeEnabled; ///< Set to true to fix the detail size to a particular value for all geometry
static S32 mFixedSize; ///< The fixed detail size value for all geometry
//-----------------------------------------------------------------------
/// Get the morph controller for this mesh (if any)
const domMorph* getMorph()
{
if (instanceCtrl) {
const domController* ctrl = daeSafeCast<domController>(instanceCtrl->getUrl().getElement());
if (mInstanceCtrl) {
const domController* ctrl = daeSafeCast<domController>(mInstanceCtrl->getUrl().getElement());
if (ctrl && ctrl->getSkin())
ctrl = daeSafeCast<domController>(ctrl->getSkin()->getSource().getElement());
return ctrl ? ctrl->getMorph() : NULL;
@ -123,13 +123,13 @@ public:
ColladaAppMesh(const domInstance_controller* instance, ColladaAppNode* node);
~ColladaAppMesh()
{
delete geomExt;
delete mGeomExt;
}
static void fixDetailSize(bool fixed, S32 size=2)
{
fixedSizeEnabled = fixed;
fixedSize = size;
mFixedSizeEnabled = fixed;
mFixedSize = size;
}
/// Get the name of this mesh
@ -147,7 +147,7 @@ public:
/// @return True if a value was set, false if not
bool getFloat(const char *propName, F32 &defaultVal)
{
return appNode->getFloat(propName,defaultVal);
return mAppNode->getFloat(propName,defaultVal);
}
/// Get an integer property value
@ -158,7 +158,7 @@ public:
/// @return True if a value was set, false if not
bool getInt(const char *propName, S32 &defaultVal)
{
return appNode->getInt(propName,defaultVal);
return mAppNode->getInt(propName,defaultVal);
}
/// Get a boolean property value
@ -169,14 +169,14 @@ public:
/// @return True if a value was set, false if not
bool getBool(const char *propName, bool &defaultVal)
{
return appNode->getBool(propName,defaultVal);
return mAppNode->getBool(propName,defaultVal);
}
/// Return true if this mesh is a skin
bool isSkin()
{
if (instanceCtrl) {
const domController* ctrl = daeSafeCast<domController>(instanceCtrl->getUrl().getElement());
if (mInstanceCtrl) {
const domController* ctrl = daeSafeCast<domController>(mInstanceCtrl->getUrl().getElement());
if (ctrl && ctrl->getSkin() &&
(ctrl->getSkin()->getVertex_weights()->getV()->getValue().getCount() > 0))
return true;

View file

@ -58,7 +58,7 @@ static char* TrimFirstWord(char* str)
ColladaAppNode::ColladaAppNode(const domNode* node, ColladaAppNode* parent)
: p_domNode(node), appParent(parent), nodeExt(new ColladaExtension_node(node)),
lastTransformTime(TSShapeLoader::DefaultTime-1), defaultTransformValid(false),
lastTransformTime(TSShapeLoader::smDefaultTime-1), defaultTransformValid(false),
invertMeshes(false)
{
mName = dStrdup(_GetNameOrId(node));
@ -66,7 +66,7 @@ ColladaAppNode::ColladaAppNode(const domNode* node, ColladaAppNode* parent)
// Extract user properties from the <node> extension as whitespace separated
// "name=value" pairs
char* properties = dStrdup(nodeExt->user_properties);
char* properties = dStrdup(nodeExt->mUserProperties);
char* pos = properties;
char* end = properties + dStrlen( properties );
while ( pos < end )
@ -99,7 +99,7 @@ ColladaAppNode::ColladaAppNode(const domNode* node, ColladaAppNode* parent)
case COLLADA_TYPE::MATRIX:
case COLLADA_TYPE::LOOKAT:
nodeTransforms.increment();
nodeTransforms.last().element = node->getContents()[iChild];
nodeTransforms.last().mElement = node->getContents()[iChild];
break;
}
}
@ -178,7 +178,7 @@ bool ColladaAppNode::animatesTransform(const AppSequence* appSeq)
MatrixF ColladaAppNode::getNodeTransform(F32 time)
{
// Avoid re-computing the default transform if possible
if (defaultTransformValid && time == TSShapeLoader::DefaultTime)
if (defaultTransformValid && time == TSShapeLoader::smDefaultTime)
{
return defaultNodeTransform;
}
@ -198,7 +198,7 @@ MatrixF ColladaAppNode::getNodeTransform(F32 time)
}
// Cache the default transform
if (time == TSShapeLoader::DefaultTime)
if (time == TSShapeLoader::smDefaultTime)
{
defaultTransformValid = true;
defaultNodeTransform = nodeTransform;
@ -221,7 +221,7 @@ MatrixF ColladaAppNode::getTransform(F32 time)
else {
// no parent (ie. root level) => scale by global shape <unit>
lastTransform.identity();
lastTransform.scale(ColladaUtils::getOptions().unit);
lastTransform.scale(ColladaUtils::getOptions().mUnit);
if (!isBounds())
ColladaUtils::convertTransform(lastTransform); // don't convert bounds node transform (or upAxis won't work!)
}
@ -232,7 +232,7 @@ MatrixF ColladaAppNode::getTransform(F32 time)
MatrixF mat(true);
// Convert the transform element to a MatrixF
switch (nodeTransforms[iTxfm].element->getElementType()) {
switch (nodeTransforms[iTxfm].mElement->getElementType()) {
case COLLADA_TYPE::TRANSLATE: mat = vecToMatrixF<domTranslate>(nodeTransforms[iTxfm].getValue(time)); break;
case COLLADA_TYPE::SCALE: mat = vecToMatrixF<domScale>(nodeTransforms[iTxfm].getValue(time)); break;
case COLLADA_TYPE::ROTATE: mat = vecToMatrixF<domRotate>(nodeTransforms[iTxfm].getValue(time)); break;
@ -242,7 +242,7 @@ MatrixF ColladaAppNode::getTransform(F32 time)
}
// Remove node scaling (but keep reflections) if desired
if (ColladaUtils::getOptions().ignoreNodeScale)
if (ColladaUtils::getOptions().mIgnoreNodeScale)
{
Point3F invScale = mat.getScale();
invScale.x = invScale.x ? (1.0f / invScale.x) : 0;

View file

@ -45,31 +45,31 @@ const char* ColladaAppSequence::getName() const
S32 ColladaAppSequence::getNumTriggers()
{
return clipExt->triggers.size();
return clipExt->mTriggers.size();
}
void ColladaAppSequence::getTrigger(S32 index, TSShape::Trigger& trigger)
{
trigger.pos = clipExt->triggers[index].time;
trigger.state = clipExt->triggers[index].state;
trigger.pos = clipExt->mTriggers[index].time;
trigger.state = clipExt->mTriggers[index].state;
}
U32 ColladaAppSequence::getFlags() const
{
U32 flags = 0;
if (clipExt->cyclic) flags |= TSShape::Cyclic;
if (clipExt->blend) flags |= TSShape::Blend;
if (clipExt->mCyclic) flags |= TSShape::Cyclic;
if (clipExt->mBlend) flags |= TSShape::Blend;
return flags;
}
F32 ColladaAppSequence::getPriority()
{
return clipExt->priority;
return clipExt->mPriority;
}
F32 ColladaAppSequence::getBlendRefTime()
{
return clipExt->blendReferenceTime;
return clipExt->mBlendReferenceTime;
}
void ColladaAppSequence::setActive(bool active)
@ -88,7 +88,7 @@ void ColladaAppSequence::setAnimationActive(const domAnimation* anim, bool activ
domChannel* channel = anim->getChannel_array()[iChannel];
AnimData* animData = reinterpret_cast<AnimData*>(channel->getUserData());
if (animData)
animData->enabled = active;
animData->mEnabled = active;
}
// Recurse into child animations

View file

@ -29,10 +29,10 @@
/// the interval
bool ColladaExtension_effect::animatesTextureTransform(F32 start, F32 end)
{
return repeatU.isAnimated(start, end) || repeatV.isAnimated(start, end) ||
offsetU.isAnimated(start, end) || offsetV.isAnimated(start, end) ||
rotateUV.isAnimated(start, end) || noiseU.isAnimated(start, end) ||
noiseV.isAnimated(start, end);
return mRepeatU.isAnimated(start, end) || mRepeatV.isAnimated(start, end) ||
mOffsetU.isAnimated(start, end) || mOffsetV.isAnimated(start, end) ||
mRotateUV.isAnimated(start, end) || mNoiseU.isAnimated(start, end) ||
mNoiseV.isAnimated(start, end);
}
/// Apply the MAYA texture transform to the given UV coordinates
@ -41,21 +41,21 @@ void ColladaExtension_effect::applyTextureTransform(Point2F& uv, F32 time)
// This function will be called for every tvert, every frame. So cache the
// texture transform parameters to avoid interpolating them every call (since
// they are constant for all tverts for a given 't')
if (time != lastAnimTime) {
if (time != mLastAnimTime) {
// Update texture transform
textureTransform.set(EulerF(0, 0, rotateUV.getValue(time)));
textureTransform.setPosition(Point3F(
offsetU.getValue(time) + noiseU.getValue(time)*gRandGen.randF(),
offsetV.getValue(time) + noiseV.getValue(time)*gRandGen.randF(),
mTextureTransform.set(EulerF(0, 0, mRotateUV.getValue(time)));
mTextureTransform.setPosition(Point3F(
mOffsetU.getValue(time) + mNoiseU.getValue(time)*gRandGen.randF(),
mOffsetV.getValue(time) + mNoiseV.getValue(time)*gRandGen.randF(),
0));
textureTransform.scale(Point3F(repeatU.getValue(time), repeatV.getValue(time), 1.0f));
mTextureTransform.scale(Point3F(mRepeatU.getValue(time), mRepeatV.getValue(time), 1.0f));
lastAnimTime = time;
mLastAnimTime = time;
}
// Apply texture transform
Point3F result;
textureTransform.mulP(Point3F(uv.x, uv.y, 0), &result);
mTextureTransform.mulP(Point3F(uv.x, uv.y, 0), &result);
uv.x = result.x;
uv.y = result.y;

View file

@ -53,7 +53,7 @@ class ColladaExtension
get(#param, param, defaultVal)
protected:
const domTechnique* pTechnique;
const domTechnique* mTechnique;
/// Find the technique with the named profile
template<class T> const domTechnique* findExtraTechnique(const T* element, const char* name) const
@ -86,10 +86,10 @@ protected:
/// Find the parameter with the given name
const domAny* findParam(const char* name)
{
if (pTechnique) {
if (mTechnique) {
// search the technique contents for the desired parameter
for (S32 iParam = 0; iParam < pTechnique->getContents().getCount(); iParam++) {
const domAny* param = daeSafeCast<domAny>(pTechnique->getContents()[iParam]);
for (S32 iParam = 0; iParam < mTechnique->getContents().getCount(); iParam++) {
const domAny* param = daeSafeCast<domAny>(mTechnique->getContents()[iParam]);
if (param && !dStrcmp(param->getElementName(), name))
return param;
}
@ -108,13 +108,13 @@ protected:
/// Get the value of the named animated parameter (use defaultVal if parameter not found)
template<typename T> void get(const char* name, AnimatedElement<T>& value, T defaultVal)
{
value.defaultVal = defaultVal;
value.mDefaultVal = defaultVal;
if (const domAny* param = findParam(name))
value.element = param;
value.mElement = param;
}
public:
ColladaExtension() : pTechnique(0) { }
ColladaExtension() : mTechnique(0) { }
virtual ~ColladaExtension() { }
};
@ -122,14 +122,14 @@ public:
class ColladaExtension_effect : public ColladaExtension
{
// Cached texture transform
F32 lastAnimTime;
MatrixF textureTransform;
F32 mLastAnimTime;
MatrixF mTextureTransform;
public:
//----------------------------------
// <effect>
// MAX3D profile elements
bool double_sided;
bool mDoubleSided;
//----------------------------------
// <effect>.<profile_COMMON>
@ -139,39 +139,39 @@ public:
//----------------------------------
// <effect>.<profile_COMMON>.<technique>.<blinn/phong/lambert>.<diffuse>.<texture>
// MAYA profile elements
bool wrapU, wrapV;
bool mirrorU, mirrorV;
AnimatedFloat coverageU, coverageV;
AnimatedFloat translateFrameU, translateFrameV;
AnimatedFloat rotateFrame;
AnimatedBool stagger; // @todo: not supported yet
AnimatedFloat repeatU, repeatV;
AnimatedFloat offsetU, offsetV;
AnimatedFloat rotateUV;
AnimatedFloat noiseU, noiseV;
bool mWrapU, mWrapV;
bool mMirrorU, mMirrorV;
AnimatedFloat mCoverageU, mCoverageV;
AnimatedFloat mTranslateFrameU, mTranslateFrameV;
AnimatedFloat mRotateFrame;
AnimatedBool mStagger; // @todo: not supported yet
AnimatedFloat mRepeatU, mRepeatV;
AnimatedFloat mOffsetU, mOffsetV;
AnimatedFloat mRotateUV;
AnimatedFloat mNoiseU, mNoiseV;
//----------------------------------
// <effect>.<profile_COMMON>.<technique>
// FCOLLADA profile elements
domFx_sampler2D_common_complexType* bumpSampler;
domFx_sampler2D_common_complexType* mBumpSampler;
public:
ColladaExtension_effect(const domEffect* effect)
: lastAnimTime(TSShapeLoader::DefaultTime-1), textureTransform(true), bumpSampler(0)
: mLastAnimTime(TSShapeLoader::smDefaultTime-1), mTextureTransform(true), mBumpSampler(0)
{
//----------------------------------
// <effect>
// MAX3D profile
pTechnique = findExtraTechnique(effect, "MAX3D");
GET_EXTRA_PARAM(double_sided, false);
mTechnique = findExtraTechnique(effect, "MAX3D");
GET_EXTRA_PARAM(mDoubleSided, false);
//----------------------------------
// <effect>.<profile_COMMON>
const domProfile_COMMON* profileCommon = ColladaUtils::findEffectCommonProfile(effect);
// GOOGLEEARTH profile (same double_sided element)
pTechnique = findExtraTechnique(profileCommon, "GOOGLEEARTH");
GET_EXTRA_PARAM(double_sided, double_sided);
mTechnique = findExtraTechnique(profileCommon, "GOOGLEEARTH");
GET_EXTRA_PARAM(mDoubleSided, mDoubleSided);
//----------------------------------
// <effect>.<profile_COMMON>.<technique>.<blinn/phong/lambert>.<diffuse>.<texture>
@ -179,43 +179,43 @@ public:
const domFx_sampler2D_common_complexType* sampler2D = ColladaUtils::getTextureSampler(effect, domDiffuse);
// Use the sampler2D to set default values for wrap/mirror flags
wrapU = wrapV = true;
mirrorU = mirrorV = false;
mWrapU = mWrapV = true;
mMirrorU = mMirrorV = false;
if (sampler2D) {
domFx_sampler2D_common_complexType::domWrap_s* wrap_s = sampler2D->getWrap_s();
domFx_sampler2D_common_complexType::domWrap_t* wrap_t = sampler2D->getWrap_t();
mirrorU = (wrap_s && wrap_s->getValue() == FX_SAMPLER_WRAP_COMMON_MIRROR);
wrapU = (mirrorU || !wrap_s || (wrap_s->getValue() == FX_SAMPLER_WRAP_COMMON_WRAP));
mirrorV = (wrap_t && wrap_t->getValue() == FX_SAMPLER_WRAP_COMMON_MIRROR);
wrapV = (mirrorV || !wrap_t || (wrap_t->getValue() == FX_SAMPLER_WRAP_COMMON_WRAP));
mMirrorU = (wrap_s && wrap_s->getValue() == FX_SAMPLER_WRAP_COMMON_MIRROR);
mWrapU = (mMirrorU || !wrap_s || (wrap_s->getValue() == FX_SAMPLER_WRAP_COMMON_WRAP));
mMirrorV = (wrap_t && wrap_t->getValue() == FX_SAMPLER_WRAP_COMMON_MIRROR);
mWrapV = (mMirrorV || !wrap_t || (wrap_t->getValue() == FX_SAMPLER_WRAP_COMMON_WRAP));
}
// MAYA profile
pTechnique = findExtraTechnique(domDiffuse ? domDiffuse->getTexture() : 0, "MAYA");
GET_EXTRA_PARAM(wrapU, wrapU); GET_EXTRA_PARAM(wrapV, wrapV);
GET_EXTRA_PARAM(mirrorU, mirrorU); GET_EXTRA_PARAM(mirrorV, mirrorV);
GET_EXTRA_PARAM(coverageU, 1.0); GET_EXTRA_PARAM(coverageV, 1.0);
GET_EXTRA_PARAM(translateFrameU, 0.0); GET_EXTRA_PARAM(translateFrameV, 0.0);
GET_EXTRA_PARAM(rotateFrame, 0.0);
GET_EXTRA_PARAM(stagger, false);
GET_EXTRA_PARAM(repeatU, 1.0); GET_EXTRA_PARAM(repeatV, 1.0);
GET_EXTRA_PARAM(offsetU, 0.0); GET_EXTRA_PARAM(offsetV, 0.0);
GET_EXTRA_PARAM(rotateUV, 0.0);
GET_EXTRA_PARAM(noiseU, 0.0); GET_EXTRA_PARAM(noiseV, 0.0);
mTechnique = findExtraTechnique(domDiffuse ? domDiffuse->getTexture() : 0, "MAYA");
GET_EXTRA_PARAM(mWrapU, mWrapU); GET_EXTRA_PARAM(mWrapV, mWrapV);
GET_EXTRA_PARAM(mMirrorU, mMirrorU); GET_EXTRA_PARAM(mMirrorV, mMirrorV);
GET_EXTRA_PARAM(mCoverageU, 1.0); GET_EXTRA_PARAM(mCoverageV, 1.0);
GET_EXTRA_PARAM(mTranslateFrameU, 0.0); GET_EXTRA_PARAM(mTranslateFrameV, 0.0);
GET_EXTRA_PARAM(mRotateFrame, 0.0);
GET_EXTRA_PARAM(mStagger, false);
GET_EXTRA_PARAM(mRepeatU, 1.0); GET_EXTRA_PARAM(mRepeatV, 1.0);
GET_EXTRA_PARAM(mOffsetU, 0.0); GET_EXTRA_PARAM(mOffsetV, 0.0);
GET_EXTRA_PARAM(mRotateUV, 0.0);
GET_EXTRA_PARAM(mNoiseU, 0.0); GET_EXTRA_PARAM(mNoiseV, 0.0);
// FCOLLADA profile
if (profileCommon) {
pTechnique = findExtraTechnique((const domProfile_COMMON::domTechnique*)profileCommon->getTechnique(), "FCOLLADA");
if (pTechnique) {
domAny* bump = daeSafeCast<domAny>(const_cast<domTechnique*>(pTechnique)->getChild("bump"));
mTechnique = findExtraTechnique((const domProfile_COMMON::domTechnique*)profileCommon->getTechnique(), "FCOLLADA");
if (mTechnique) {
domAny* bump = daeSafeCast<domAny>(const_cast<domTechnique*>(mTechnique)->getChild("bump"));
if (bump) {
domAny* bumpTexture = daeSafeCast<domAny>(bump->getChild("texture"));
if (bumpTexture) {
daeSIDResolver resolver(const_cast<domEffect*>(effect), bumpTexture->getAttribute("texture").c_str());
domCommon_newparam_type* param = daeSafeCast<domCommon_newparam_type>(resolver.getElement());
if (param)
bumpSampler = param->getSampler2D();
mBumpSampler = param->getSampler2D();
}
}
}
@ -235,21 +235,21 @@ class ColladaExtension_node : public ColladaExtension
{
public:
// FCOLLADA or OpenCOLLADA profile elements
AnimatedFloat visibility;
const char* user_properties;
AnimatedFloat mVisibility;
const char* mUserProperties;
ColladaExtension_node(const domNode* node)
{
// FCOLLADA profile
pTechnique = findExtraTechnique(node, "FCOLLADA");
GET_EXTRA_PARAM(visibility, 1.0);
GET_EXTRA_PARAM(user_properties, "");
mTechnique = findExtraTechnique(node, "FCOLLADA");
GET_EXTRA_PARAM(mVisibility, 1.0);
GET_EXTRA_PARAM(mUserProperties, "");
// OpenCOLLADA profile
pTechnique = findExtraTechnique(node, "OpenCOLLADA");
if (!visibility.element)
GET_EXTRA_PARAM(visibility, 1.0);
GET_EXTRA_PARAM(user_properties, user_properties);
mTechnique = findExtraTechnique(node, "OpenCOLLADA");
if (!mVisibility.mElement)
GET_EXTRA_PARAM(mVisibility, 1.0);
GET_EXTRA_PARAM(mUserProperties, mUserProperties);
}
};
@ -258,13 +258,13 @@ class ColladaExtension_geometry : public ColladaExtension
{
public:
// MAYA profile elements
bool double_sided;
bool mDoubleSided;
ColladaExtension_geometry(const domGeometry* geometry)
{
// MAYA profile
pTechnique = findExtraTechnique(geometry, "MAYA");
GET_EXTRA_PARAM(double_sided, false);
mTechnique = findExtraTechnique(geometry, "MAYA");
GET_EXTRA_PARAM(mDoubleSided, false);
}
};
@ -278,27 +278,27 @@ public:
};
// Torque profile elements (none of these are animatable)
S32 num_triggers;
Vector<Trigger> triggers;
bool cyclic;
bool blend;
F32 blendReferenceTime;
F32 priority;
S32 mNumTriggers;
Vector<Trigger> mTriggers;
bool mCyclic;
bool mBlend;
F32 mBlendReferenceTime;
F32 mPriority;
ColladaExtension_animation_clip(const domAnimation_clip* clip)
{
// Torque profile
pTechnique = findExtraTechnique(clip, "Torque");
GET_EXTRA_PARAM(num_triggers, 0);
for (S32 iTrigger = 0; iTrigger < num_triggers; iTrigger++) {
triggers.increment();
get(avar("trigger_time%d", iTrigger), triggers.last().time, 0.0f);
get(avar("trigger_state%d", iTrigger), triggers.last().state, 0);
mTechnique = findExtraTechnique(clip, "Torque");
GET_EXTRA_PARAM(mNumTriggers, 0);
for (S32 iTrigger = 0; iTrigger < mNumTriggers; iTrigger++) {
mTriggers.increment();
get(avar("trigger_time%d", iTrigger), mTriggers.last().time, 0.0f);
get(avar("trigger_state%d", iTrigger), mTriggers.last().state, 0);
}
GET_EXTRA_PARAM(cyclic, false);
GET_EXTRA_PARAM(blend, false);
GET_EXTRA_PARAM(blendReferenceTime, 0.0f);
GET_EXTRA_PARAM(priority, 5.0f);
GET_EXTRA_PARAM(mCyclic, false);
GET_EXTRA_PARAM(mBlend, false);
GET_EXTRA_PARAM(mBlendReferenceTime, 0.0f);
GET_EXTRA_PARAM(mPriority, 5.0f);
}
};

View file

@ -117,7 +117,7 @@ static void processNodeLights(AppNode* appNode, const MatrixF& offset, SimGroup*
Con::printf("Adding <%s> light \"%s\" as a %s", lightType, lightName.c_str(), pLight->getClassName());
MatrixF mat(offset);
mat.mul(appNode->getNodeTransform(TSShapeLoader::DefaultTime));
mat.mul(appNode->getNodeTransform(TSShapeLoader::smDefaultTime));
pLight->setDataField(StringTable->insert("color"), 0,
avar("%f %f %f %f", color.red, color.green, color.blue, color.alpha));
@ -210,8 +210,8 @@ DefineConsoleFunction( loadColladaLights, bool, (const char * filename, const ch
upAxis = root->getAsset()->getUp_axis()->getValue();
}
ColladaUtils::getOptions().unit = unit;
ColladaUtils::getOptions().upAxis = upAxis;
ColladaUtils::getOptions().mUnit = unit;
ColladaUtils::getOptions().mUpAxis = upAxis;
// First grab all of the top-level nodes
Vector<ColladaAppNode*> sceneNodes;

View file

@ -95,11 +95,11 @@ ColladaShapeLoader::ColladaShapeLoader(domCOLLADA* _root)
}
// Set import options (if they are not set to override)
if (ColladaUtils::getOptions().unit <= 0.0f)
ColladaUtils::getOptions().unit = unit;
if (ColladaUtils::getOptions().mUnit <= 0.0f)
ColladaUtils::getOptions().mUnit = unit;
if (ColladaUtils::getOptions().upAxis == UPAXISTYPE_COUNT)
ColladaUtils::getOptions().upAxis = upAxis;
if (ColladaUtils::getOptions().mUpAxis == UPAXISTYPE_COUNT)
ColladaUtils::getOptions().mUpAxis = upAxis;
}
ColladaShapeLoader::~ColladaShapeLoader()
@ -169,14 +169,14 @@ void ColladaShapeLoader::processAnimation(const domAnimation* anim, F32& maxEndT
// @todo:don't care about the input param names for now. Could
// validate against the target type....
if (dStrEqual(input->getSemantic(), "INPUT")) {
data.input.initFromSource(source);
data.mInput.initFromSource(source);
// Adjust the maximum sequence end time
maxEndTime = getMax(maxEndTime, data.input.getFloatValue((S32)data.input.size()-1));
maxEndTime = getMax(maxEndTime, data.mInput.getFloatValue((S32)data.mInput.size()-1));
// Detect the frame rate (minimum time between keyframes)
for (S32 iFrame = 1; iFrame < data.input.size(); iFrame++)
for (S32 iFrame = 1; iFrame < data.mInput.size(); iFrame++)
{
F32 delta = data.input.getFloatValue( iFrame ) - data.input.getFloatValue( iFrame-1 );
F32 delta = data.mInput.getFloatValue( iFrame ) - data.mInput.getFloatValue( iFrame-1 );
if ( delta < 0 )
{
daeErrorHandler::get()->handleError(avar("<animation> INPUT '%s' "
@ -187,13 +187,13 @@ void ColladaShapeLoader::processAnimation(const domAnimation* anim, F32& maxEndT
}
}
else if (dStrEqual(input->getSemantic(), "OUTPUT"))
data.output.initFromSource(source);
data.mOutput.initFromSource(source);
else if (dStrEqual(input->getSemantic(), "IN_TANGENT"))
data.inTangent.initFromSource(source);
data.mInTangent.initFromSource(source);
else if (dStrEqual(input->getSemantic(), "OUT_TANGENT"))
data.outTangent.initFromSource(source);
data.mOutTangent.initFromSource(source);
else if (dStrEqual(input->getSemantic(), "INTERPOLATION"))
data.interpolation.initFromSource(source);
data.mInterpolation.initFromSource(source);
}
// Set initial value for visibility targets that were added automatically (in colladaUtils.cpp
@ -201,11 +201,11 @@ void ColladaShapeLoader::processAnimation(const domAnimation* anim, F32& maxEndT
{
domAny* visTarget = daeSafeCast<domAny>(target);
if (visTarget && dStrEqual(visTarget->getValue(), ""))
visTarget->setValue(avar("%g", data.output.getFloatValue(0)));
visTarget->setValue(avar("%g", data.mOutput.getFloatValue(0)));
}
// Ignore empty animations
if (data.input.size() == 0) {
if (data.mInput.size() == 0) {
channel->setUserData(0);
delete targetChannels->last();
targetChannels->pop_back();
@ -239,14 +239,14 @@ void ColladaShapeLoader::enumerateScene()
for (S32 iClipLib = 0; iClipLib < root->getLibrary_animation_clips_array().getCount(); iClipLib++) {
const domLibrary_animation_clips* libraryClips = root->getLibrary_animation_clips_array()[iClipLib];
for (S32 iClip = 0; iClip < libraryClips->getAnimation_clip_array().getCount(); iClip++)
appSequences.push_back(new ColladaAppSequence(libraryClips->getAnimation_clip_array()[iClip]));
mAppSequences.push_back(new ColladaAppSequence(libraryClips->getAnimation_clip_array()[iClip]));
}
// Process all animations => this attaches animation channels to the targeted
// Collada elements, and determines the length of the sequence if it is not
// already specified in the Collada <animation_clip> element
for (S32 iSeq = 0; iSeq < appSequences.size(); iSeq++) {
ColladaAppSequence* appSeq = dynamic_cast<ColladaAppSequence*>(appSequences[iSeq]);
for (S32 iSeq = 0; iSeq < mAppSequences.size(); iSeq++) {
ColladaAppSequence* appSeq = dynamic_cast<ColladaAppSequence*>(mAppSequences[iSeq]);
F32 maxEndTime = 0;
F32 minFrameTime = 1000.0f;
for (S32 iAnim = 0; iAnim < appSeq->getClip()->getInstance_animation_array().getCount(); iAnim++) {
@ -260,7 +260,7 @@ void ColladaShapeLoader::enumerateScene()
// Collada animations can be stored as sampled frames or true keyframes. For
// sampled frames, use the same frame rate as the DAE file. For true keyframes,
// resample at a fixed frame rate.
appSeq->fps = mClamp(1.0f / minFrameTime + 0.5f, TSShapeLoader::MinFrameRate, TSShapeLoader::MaxFrameRate);
appSeq->fps = mClamp(1.0f / minFrameTime + 0.5f, TSShapeLoader::smMinFrameRate, TSShapeLoader::smMaxFrameRate);
}
// First grab all of the top-level nodes
@ -276,7 +276,7 @@ void ColladaShapeLoader::enumerateScene()
// Set LOD option
bool singleDetail = true;
switch (ColladaUtils::getOptions().lodType)
switch (ColladaUtils::getOptions().mLodType)
{
case ColladaUtils::ImportOptions::DetectDTS:
// Check for a baseXX->startXX hierarchy at the top-level, if we find
@ -307,7 +307,7 @@ void ColladaShapeLoader::enumerateScene()
break;
}
ColladaAppMesh::fixDetailSize( singleDetail, ColladaUtils::getOptions().singleDetailSize );
ColladaAppMesh::fixDetailSize( singleDetail, ColladaUtils::getOptions().mSingleDetailSize );
// Process the top level nodes
for (S32 iNode = 0; iNode < sceneNodes.size(); iNode++) {
@ -317,7 +317,7 @@ void ColladaShapeLoader::enumerateScene()
}
// Make sure that the scene has a bounds node (for getting the root scene transform)
if (!boundsNode)
if (!mBoundsNode)
{
domVisual_scene* visualScene = root->getLibrary_visual_scenes_array()[0]->getVisual_scene_array()[0];
domNode* dombounds = daeSafeCast<domNode>( visualScene->createAndPlace( "node" ) );
@ -330,18 +330,18 @@ void ColladaShapeLoader::enumerateScene()
bool ColladaShapeLoader::ignoreNode(const String& name)
{
if (FindMatch::isMatchMultipleExprs(ColladaUtils::getOptions().alwaysImport, name, false))
if (FindMatch::isMatchMultipleExprs(ColladaUtils::getOptions().mAlwaysImport, name, false))
return false;
else
return FindMatch::isMatchMultipleExprs(ColladaUtils::getOptions().neverImport, name, false);
return FindMatch::isMatchMultipleExprs(ColladaUtils::getOptions().mNeverImport, name, false);
}
bool ColladaShapeLoader::ignoreMesh(const String& name)
{
if (FindMatch::isMatchMultipleExprs(ColladaUtils::getOptions().alwaysImportMesh, name, false))
if (FindMatch::isMatchMultipleExprs(ColladaUtils::getOptions().mAlwaysImportMesh, name, false))
return false;
else
return FindMatch::isMatchMultipleExprs(ColladaUtils::getOptions().neverImportMesh, name, false);
return FindMatch::isMatchMultipleExprs(ColladaUtils::getOptions().mNeverImportMesh, name, false);
}
void ColladaShapeLoader::computeBounds(Box3F& bounds)
@ -350,17 +350,17 @@ void ColladaShapeLoader::computeBounds(Box3F& bounds)
// Check if the model origin needs adjusting
if ( bounds.isValidBox() &&
(ColladaUtils::getOptions().adjustCenter ||
ColladaUtils::getOptions().adjustFloor) )
(ColladaUtils::getOptions().mAdjustCenter ||
ColladaUtils::getOptions().mAdjustFloor) )
{
// Compute shape offset
Point3F shapeOffset = Point3F::Zero;
if ( ColladaUtils::getOptions().adjustCenter )
if ( ColladaUtils::getOptions().mAdjustCenter )
{
bounds.getCenter( &shapeOffset );
shapeOffset = -shapeOffset;
}
if ( ColladaUtils::getOptions().adjustFloor )
if ( ColladaUtils::getOptions().mAdjustFloor )
shapeOffset.z = -bounds.minExtents.z;
// Adjust bounds
@ -368,24 +368,24 @@ void ColladaShapeLoader::computeBounds(Box3F& bounds)
bounds.maxExtents += shapeOffset;
// Now adjust all positions for root level nodes (nodes with no parent)
for (S32 iNode = 0; iNode < shape->nodes.size(); iNode++)
for (S32 iNode = 0; iNode < mShape->mNodes.size(); iNode++)
{
if ( !appNodes[iNode]->isParentRoot() )
if ( !mAppNodes[iNode]->isParentRoot() )
continue;
// Adjust default translation
shape->defaultTranslations[iNode] += shapeOffset;
mShape->mDefaultTranslations[iNode] += shapeOffset;
// Adjust animated translations
for (S32 iSeq = 0; iSeq < shape->sequences.size(); iSeq++)
for (S32 iSeq = 0; iSeq < mShape->mSequences.size(); iSeq++)
{
const TSShape::Sequence& seq = shape->sequences[iSeq];
const TSShape::Sequence& seq = mShape->mSequences[iSeq];
if ( seq.translationMatters.test(iNode) )
{
for (S32 iFrame = 0; iFrame < seq.numKeyframes; iFrame++)
{
S32 index = seq.baseTranslation + seq.translationMatters.count(iNode)*seq.numKeyframes + iFrame;
shape->nodeTranslations[index] += shapeOffset;
mShape->mNodeTranslations[index] += shapeOffset;
}
}
}
@ -457,7 +457,7 @@ void copySketchupTexture(const Torque::Path &path, String &textureFilename)
void updateMaterialsScript(const Torque::Path &path, bool copyTextures = false)
{
#ifdef DAE2DTS_TOOL
if (!ColladaUtils::getOptions().forceUpdateMaterials)
if (!ColladaUtils::getOptions().mForceUpdateMaterials)
return;
#endif
@ -467,16 +467,16 @@ void updateMaterialsScript(const Torque::Path &path, bool copyTextures = false)
// First see what materials we need to update
PersistenceManager persistMgr;
for ( U32 iMat = 0; iMat < AppMesh::appMaterials.size(); iMat++ )
for ( U32 iMat = 0; iMat < AppMesh::mAppMaterials.size(); iMat++ )
{
ColladaAppMaterial *mat = dynamic_cast<ColladaAppMaterial*>( AppMesh::appMaterials[iMat] );
ColladaAppMaterial *mat = dynamic_cast<ColladaAppMaterial*>( AppMesh::mAppMaterials[iMat] );
if ( mat )
{
Material *mappedMat;
if ( Sim::findObject( MATMGR->getMapEntry( mat->getName() ), mappedMat ) )
{
// Only update existing materials if forced to
if ( ColladaUtils::getOptions().forceUpdateMaterials )
if ( ColladaUtils::getOptions().mForceUpdateMaterials )
persistMgr.setDirty( mappedMat );
}
else
@ -686,8 +686,8 @@ TSShape* loadColladaShape(const Torque::Path &path)
#ifdef DAE2DTS_TOOL
// Command line overrides certain options
ColladaUtils::getOptions().forceUpdateMaterials = cmdLineOptions.forceUpdateMaterials;
ColladaUtils::getOptions().useDiffuseNames = cmdLineOptions.useDiffuseNames;
ColladaUtils::getOptions().mForceUpdateMaterials = cmdLineOptions.mForceUpdateMaterials;
ColladaUtils::getOptions().mUseDiffuseNames = cmdLineOptions.mUseDiffuseNames;
#endif
}

View file

@ -49,7 +49,7 @@ void ColladaUtils::convertTransform(MatrixF& mat)
{
MatrixF rot(true);
switch (ColladaUtils::getOptions().upAxis)
switch (ColladaUtils::getOptions().mUpAxis)
{
case UPAXISTYPE_X_UP:
// rotate 90 around Y-axis, then 90 around Z-axis
@ -248,27 +248,27 @@ BasePrimitive* BasePrimitive::get(const daeElement* element)
void AnimData::parseTargetString(const char* target, S32 fullCount, const char* elements[])
{
// Assume targeting all elements at offset 0
targetValueCount = fullCount;
targetValueOffset = 0;
mTargetValueCount = fullCount;
mTargetValueOffset = 0;
// Check for array syntax: (n) or (n)(m)
if (const char* p = dStrchr(target, '(')) {
S32 indN, indM;
if (dSscanf(p, "(%d)(%d)", &indN, &indM) == 2) {
targetValueOffset = (indN * 4) + indM; // @todo: 4x4 matrix only
targetValueCount = 1;
mTargetValueOffset = (indN * 4) + indM; // @todo: 4x4 matrix only
mTargetValueCount = 1;
}
else if (dSscanf(p, "(%d)", &indN) == 1) {
targetValueOffset = indN;
targetValueCount = 1;
mTargetValueOffset = indN;
mTargetValueCount = 1;
}
}
else if (const char* p = dStrrchr(target, '.')) {
// Check for named elements
for (S32 iElem = 0; elements[iElem][0] != 0; iElem++) {
if (!dStrcmp(p, elements[iElem])) {
targetValueOffset = iElem;
targetValueCount = 1;
mTargetValueOffset = iElem;
mTargetValueCount = 1;
break;
}
}
@ -327,47 +327,47 @@ F32 AnimData::invertParamCubic(F32 param, F32 x0, F32 x1, F32 x2, F32 x3) const
void AnimData::interpValue(F32 t, U32 offset, double* value) const
{
// handle degenerate animation data
if (input.size() == 0)
if (mInput.size() == 0)
{
*value = 0.0f;
return;
}
else if (input.size() == 1)
else if (mInput.size() == 1)
{
*value = output.getStringArrayData(0)[offset];
*value = mOutput.getStringArrayData(0)[offset];
return;
}
// clamp time to valid range
F32 curveStart = input.getFloatValue(0);
F32 curveEnd = input.getFloatValue(input.size()-1);
F32 curveStart = mInput.getFloatValue(0);
F32 curveEnd = mInput.getFloatValue(mInput.size()-1);
t = mClampF(t, curveStart, curveEnd);
// find the index of the input keyframe BEFORE 't'
S32 index;
for (index = 0; index < input.size()-2; index++) {
if (input.getFloatValue(index + 1) > t)
for (index = 0; index < mInput.size()-2; index++) {
if (mInput.getFloatValue(index + 1) > t)
break;
}
// get the data for the two control points either side of 't'
Point2F v0;
v0.x = input.getFloatValue(index);
v0.y = output.getStringArrayData(index)[offset];
v0.x = mInput.getFloatValue(index);
v0.y = mOutput.getStringArrayData(index)[offset];
Point2F v3;
v3.x = input.getFloatValue(index + 1);
v3.y = output.getStringArrayData(index + 1)[offset];
v3.x = mInput.getFloatValue(index + 1);
v3.y = mOutput.getStringArrayData(index + 1)[offset];
// If spline interpolation is specified but the tangents are not available,
// default to LINEAR.
const char* interp_method = interpolation.getStringValue(index);
const char* interp_method = mInterpolation.getStringValue(index);
if (dStrEqual(interp_method, "BEZIER") ||
dStrEqual(interp_method, "HERMITE") ||
dStrEqual(interp_method, "CARDINAL")) {
const double* inArray = inTangent.getStringArrayData(index + 1);
const double* outArray = outTangent.getStringArrayData(index);
const double* inArray = mInTangent.getStringArrayData(index + 1);
const double* outArray = mOutTangent.getStringArrayData(index);
if (!inArray || !outArray)
interp_method = "LINEAR";
}
@ -398,17 +398,17 @@ void AnimData::interpValue(F32 t, U32 offset, double* value) const
v2 = v3;
if (index > 0) {
v0.x = input.getFloatValue(index-1);
v0.y = output.getStringArrayData(index-1)[offset];
v0.x = mInput.getFloatValue(index-1);
v0.y = mOutput.getStringArrayData(index-1)[offset];
}
else {
// mirror P1 through P0
v0 = v1 + (v1 - v2);
}
if (index < (input.size()-2)) {
v3.x = input.getFloatValue(index+2);
v3.y = output.getStringArrayData(index+2)[offset];
if (index < (mInput.size()-2)) {
v3.x = mInput.getFloatValue(index+2);
v3.y = mOutput.getStringArrayData(index+2)[offset];
}
else {
// mirror P0 through P1
@ -416,10 +416,10 @@ void AnimData::interpValue(F32 t, U32 offset, double* value) const
}
}
else {
const double* inArray = inTangent.getStringArrayData(index + 1);
const double* outArray = outTangent.getStringArrayData(index);
const double* inArray = mInTangent.getStringArrayData(index + 1);
const double* outArray = mOutTangent.getStringArrayData(index);
if (output.stride() == inTangent.stride()) {
if (mOutput.stride() == mInTangent.stride()) {
// This degenerate form (1D control points) does 2 things wrong:
// 1) it does not specify the key (time) value
// 2) the control point is specified as a tangent for both bezier and hermite
@ -458,27 +458,27 @@ void AnimData::interpValue(F32 t, U32 offset, double* value) const
void AnimData::interpValue(F32 t, U32 offset, const char** value) const
{
if (input.size() == 0)
if (mInput.size() == 0)
*value = "";
else if (input.size() == 1)
*value = output.getStringValue(0);
else if (mInput.size() == 1)
*value = mOutput.getStringValue(0);
else
{
// clamp time to valid range
F32 curveStart = input.getFloatValue(0);
F32 curveEnd = input.getFloatValue(input.size()-1);
F32 curveStart = mInput.getFloatValue(0);
F32 curveEnd = mInput.getFloatValue(mInput.size()-1);
t = mClampF(t, curveStart, curveEnd);
// find the index of the input keyframe BEFORE 't'
S32 index;
for (index = 0; index < input.size()-2; index++) {
if (input.getFloatValue(index + 1) > t)
for (index = 0; index < mInput.size()-2; index++) {
if (mInput.getFloatValue(index + 1) > t)
break;
}
// String values only support STEP interpolation, so just get the
// value at the input keyframe
*value = output.getStringValue(index);
*value = mOutput.getStringValue(index);
}
}

View file

@ -76,20 +76,20 @@ namespace ColladaUtils
NumLodTypes
};
domUpAxisType upAxis; // Override for the collada <up_axis> element
F32 unit; // Override for the collada <unit> element
eLodType lodType; // LOD type option
S32 singleDetailSize; // Detail size for all meshes in the model
String matNamePrefix; // Prefix to apply to collada material names
String alwaysImport; // List of node names (with wildcards) to import, even if in the neverImport list
String neverImport; // List of node names (with wildcards) to ignore on loading
String alwaysImportMesh; // List of mesh names (with wildcards) to import, even if in the neverImportMesh list
String neverImportMesh; // List of mesh names (with wildcards) to ignore on loading
bool ignoreNodeScale; // Ignore <scale> elements in <node>s
bool adjustCenter; // Translate model so origin is at the center
bool adjustFloor; // Translate model so origin is at the bottom
bool forceUpdateMaterials; // Force update of materials.cs
bool useDiffuseNames; // Use diffuse texture as the material name
domUpAxisType mUpAxis; // Override for the collada <up_axis> element
F32 mUnit; // Override for the collada <unit> element
eLodType mLodType; // LOD type option
S32 mSingleDetailSize; // Detail size for all meshes in the model
String mMatNamePrefix; // Prefix to apply to collada material names
String mAlwaysImport; // List of node names (with wildcards) to import, even if in the neverImport list
String mNeverImport; // List of node names (with wildcards) to ignore on loading
String mAlwaysImportMesh; // List of mesh names (with wildcards) to import, even if in the neverImportMesh list
String mNeverImportMesh; // List of mesh names (with wildcards) to ignore on loading
bool mIgnoreNodeScale; // Ignore <scale> elements in <node>s
bool mAdjustCenter; // Translate model so origin is at the center
bool mAdjustFloor; // Translate model so origin is at the bottom
bool mForceUpdateMaterials; // Force update of materials.cs
bool mUseDiffuseNames; // Use diffuse texture as the material name
ImportOptions()
{
@ -98,20 +98,20 @@ namespace ColladaUtils
void reset()
{
upAxis = UPAXISTYPE_COUNT;
unit = -1.0f;
lodType = DetectDTS;
singleDetailSize = 2;
matNamePrefix = "";
alwaysImport = "";
neverImport = "";
alwaysImportMesh = "";
neverImportMesh = "";
ignoreNodeScale = false;
adjustCenter = false;
adjustFloor = false;
forceUpdateMaterials = false;
useDiffuseNames = false;
mUpAxis = UPAXISTYPE_COUNT;
mUnit = -1.0f;
mLodType = DetectDTS;
mSingleDetailSize = 2;
mMatNamePrefix = "";
mAlwaysImport = "";
mNeverImport = "";
mAlwaysImportMesh = "";
mNeverImportMesh = "";
mIgnoreNodeScale = false;
mAdjustCenter = false;
mAdjustFloor = false;
mForceUpdateMaterials = false;
mUseDiffuseNames = false;
}
};
@ -291,27 +291,27 @@ template<> inline const char* _GetNameOrId(const domInstance_controller* element
// is done until we actually try to extract values from the source.
class _SourceReader
{
const domSource* source; // the wrapped Collada source
const domAccessor* accessor; // shortcut to the source accessor
Vector<U32> offsets; // offset of each of the desired values to pull from the source array
const domSource* mSource; // the wrapped Collada source
const domAccessor* mAccessor; // shortcut to the source accessor
Vector<U32> mOffsets; // offset of each of the desired values to pull from the source array
public:
_SourceReader() : source(0), accessor(0) {}
_SourceReader() : mSource(0), mAccessor(0) {}
void reset()
{
source = 0;
accessor = 0;
offsets.clear();
mSource = 0;
mAccessor = 0;
mOffsets.clear();
}
//------------------------------------------------------
// Initialize the _SourceReader object
bool initFromSource(const domSource* src, const char* paramNames[] = 0)
{
source = src;
accessor = source->getTechnique_common()->getAccessor();
offsets.clear();
mSource = src;
mAccessor = mSource->getTechnique_common()->getAccessor();
mOffsets.clear();
// The source array has groups of values in a 1D stream => need to map the
// input param names to source params to determine the offset within the
@ -319,11 +319,11 @@ public:
U32 paramCount = 0;
while (paramNames && paramNames[paramCount][0]) {
// lookup the index of the source param that matches the input param
offsets.push_back(paramCount);
for (U32 iParam = 0; iParam < accessor->getParam_array().getCount(); iParam++) {
if (accessor->getParam_array()[iParam]->getName() &&
dStrEqual(accessor->getParam_array()[iParam]->getName(), paramNames[paramCount])) {
offsets.last() = iParam;
mOffsets.push_back(paramCount);
for (U32 iParam = 0; iParam < mAccessor->getParam_array().getCount(); iParam++) {
if (mAccessor->getParam_array()[iParam]->getName() &&
dStrEqual(mAccessor->getParam_array()[iParam]->getName(), paramNames[paramCount])) {
mOffsets.last() = iParam;
break;
}
}
@ -331,9 +331,9 @@ public:
}
// If no input params were specified, just map the source params directly
if (!offsets.size()) {
for (S32 iParam = 0; iParam < accessor->getParam_array().getCount(); iParam++)
offsets.push_back(iParam);
if (!mOffsets.size()) {
for (S32 iParam = 0; iParam < mAccessor->getParam_array().getCount(); iParam++)
mOffsets.push_back(iParam);
}
return true;
@ -341,10 +341,10 @@ public:
//------------------------------------------------------
// Shortcut to the size of the array (should be the number of destination objects)
S32 size() const { return accessor ? accessor->getCount() : 0; }
S32 size() const { return mAccessor ? mAccessor->getCount() : 0; }
// Get the number of elements per group in the source
S32 stride() const { return accessor ? accessor->getStride() : 0; }
S32 stride() const { return mAccessor ? mAccessor->getStride() : 0; }
//------------------------------------------------------
// Get a pointer to the start of a group of values (index advances by stride)
@ -353,8 +353,8 @@ public:
const double* getStringArrayData(S32 index) const
{
if ((index >= 0) && (index < size())) {
if (source->getFloat_array())
return &source->getFloat_array()->getValue()[index*stride()];
if (mSource->getFloat_array())
return &mSource->getFloat_array()->getValue()[index*stride()];
}
return 0;
}
@ -367,10 +367,10 @@ public:
{
if ((index >= 0) && (index < size())) {
// could be plain strings or IDREFs
if (source->getName_array())
return source->getName_array()->getValue()[index*stride()];
else if (source->getIDREF_array())
return source->getIDREF_array()->getValue()[index*stride()].getID();
if (mSource->getName_array())
return mSource->getName_array()->getValue()[index*stride()];
else if (mSource->getIDREF_array())
return mSource->getIDREF_array()->getValue()[index*stride()].getID();
}
return "";
}
@ -379,7 +379,7 @@ public:
{
F32 value(0);
if (const double* data = getStringArrayData(index))
return data[offsets[0]];
return data[mOffsets[0]];
return value;
}
@ -387,7 +387,7 @@ public:
{
Point2F value(0, 0);
if (const double* data = getStringArrayData(index))
value.set(data[offsets[0]], data[offsets[1]]);
value.set(data[mOffsets[0]], data[mOffsets[1]]);
return value;
}
@ -395,7 +395,7 @@ public:
{
Point3F value(1, 0, 0);
if (const double* data = getStringArrayData(index))
value.set(data[offsets[0]], data[offsets[1]], data[offsets[2]]);
value.set(data[mOffsets[0]], data[mOffsets[1]], data[mOffsets[2]]);
return value;
}
@ -404,11 +404,11 @@ public:
ColorI value(255, 255, 255, 255);
if (const double* data = getStringArrayData(index))
{
value.red = data[offsets[0]] * 255.0;
value.green = data[offsets[1]] * 255.0;
value.blue = data[offsets[2]] * 255.0;
value.red = data[mOffsets[0]] * 255.0;
value.green = data[mOffsets[1]] * 255.0;
value.blue = data[mOffsets[2]] * 255.0;
if ( stride() == 4 )
value.alpha = data[offsets[3]] * 255.0;
value.alpha = data[mOffsets[3]] * 255.0;
}
return value;
}
@ -477,14 +477,14 @@ public:
/// Template child class for supported Collada primitive elements
template<class T> class ColladaPrimitive : public BasePrimitive
{
T* primitive;
domListOfUInts *pTriangleData;
T* mPrimitive;
domListOfUInts *mTriangleData;
S32 stride;
public:
ColladaPrimitive(const daeElement* e) : pTriangleData(0)
ColladaPrimitive(const daeElement* e) : mTriangleData(0)
{
// Cast to geometric primitive element
primitive = daeSafeCast<T>(const_cast<daeElement*>(e));
mPrimitive = daeSafeCast<T>(const_cast<daeElement*>(e));
// Determine stride
stride = 0;
@ -495,13 +495,13 @@ public:
}
~ColladaPrimitive()
{
delete pTriangleData;
delete mTriangleData;
}
/// Most primitives can use these common implementations
const char* getElementName() { return primitive->getElementName(); }
const char* getMaterial() { return primitive->getMaterial(); }
const domInputLocalOffset_Array& getInputs() { return primitive->getInput_array(); }
const char* getElementName() { return mPrimitive->getElementName(); }
const char* getMaterial() { return mPrimitive->getMaterial(); }
const domInputLocalOffset_Array& getInputs() { return mPrimitive->getInput_array(); }
S32 getStride() const { return stride; }
/// Each supported primitive needs to implement this method (and convert
@ -514,21 +514,21 @@ public:
template<> inline const domListOfUInts *ColladaPrimitive<domTriangles>::getTriangleData()
{
// Return the <p> integer list directly
return (primitive->getP() ? &(primitive->getP()->getValue()) : NULL);
return (mPrimitive->getP() ? &(mPrimitive->getP()->getValue()) : NULL);
}
//-----------------------------------------------------------------------------
// <tristrips>
template<> inline const domListOfUInts *ColladaPrimitive<domTristrips>::getTriangleData()
{
if (!pTriangleData)
if (!mTriangleData)
{
// Convert strips to triangles
pTriangleData = new domListOfUInts();
mTriangleData = new domListOfUInts();
for (S32 iStrip = 0; iStrip < primitive->getCount(); iStrip++) {
for (S32 iStrip = 0; iStrip < mPrimitive->getCount(); iStrip++) {
domP* P = primitive->getP_array()[iStrip];
domP* P = mPrimitive->getP_array()[iStrip];
// Ignore invalid P arrays
if (!P || !P->getValue().getCount())
@ -543,33 +543,33 @@ template<> inline const domListOfUInts *ColladaPrimitive<domTristrips>::getTrian
if (iTri & 0x1)
{
// CW triangle
pTriangleData->appendArray(stride, v0);
pTriangleData->appendArray(stride, v0 + 2*stride);
pTriangleData->appendArray(stride, v0 + stride);
mTriangleData->appendArray(stride, v0);
mTriangleData->appendArray(stride, v0 + 2*stride);
mTriangleData->appendArray(stride, v0 + stride);
}
else
{
// CCW triangle
pTriangleData->appendArray(stride*3, v0);
mTriangleData->appendArray(stride*3, v0);
}
}
}
}
return pTriangleData;
return mTriangleData;
}
//-----------------------------------------------------------------------------
// <trifans>
template<> inline const domListOfUInts *ColladaPrimitive<domTrifans>::getTriangleData()
{
if (!pTriangleData)
if (!mTriangleData)
{
// Convert strips to triangles
pTriangleData = new domListOfUInts();
mTriangleData = new domListOfUInts();
for (S32 iStrip = 0; iStrip < primitive->getCount(); iStrip++) {
for (S32 iStrip = 0; iStrip < mPrimitive->getCount(); iStrip++) {
domP* P = primitive->getP_array()[iStrip];
domP* P = mPrimitive->getP_array()[iStrip];
// Ignore invalid P arrays
if (!P || !P->getValue().getCount())
@ -581,27 +581,27 @@ template<> inline const domListOfUInts *ColladaPrimitive<domTrifans>::getTriangl
// Convert the fan back to a triangle list
domUint* v0 = pSrcData + stride;
for (S32 iTri = 0; iTri < numTriangles; iTri++, v0 += stride) {
pTriangleData->appendArray(stride, pSrcData); // shared vertex
pTriangleData->appendArray(stride, v0); // previous vertex
pTriangleData->appendArray(stride, v0+stride); // current vertex
mTriangleData->appendArray(stride, pSrcData); // shared vertex
mTriangleData->appendArray(stride, v0); // previous vertex
mTriangleData->appendArray(stride, v0+stride); // current vertex
}
}
}
return pTriangleData;
return mTriangleData;
}
//-----------------------------------------------------------------------------
// <polygons>
template<> inline const domListOfUInts *ColladaPrimitive<domPolygons>::getTriangleData()
{
if (!pTriangleData)
if (!mTriangleData)
{
// Convert polygons to triangles
pTriangleData = new domListOfUInts();
mTriangleData = new domListOfUInts();
for (S32 iPoly = 0; iPoly < primitive->getCount(); iPoly++) {
for (S32 iPoly = 0; iPoly < mPrimitive->getCount(); iPoly++) {
domP* P = primitive->getP_array()[iPoly];
domP* P = mPrimitive->getP_array()[iPoly];
// Ignore invalid P arrays
if (!P || !P->getValue().getCount())
@ -615,41 +615,41 @@ template<> inline const domListOfUInts *ColladaPrimitive<domPolygons>::getTriang
domUint* v0 = pSrcData;
pSrcData += stride;
for (S32 iTri = 0; iTri < numPoints-2; iTri++) {
pTriangleData->appendArray(stride, v0);
pTriangleData->appendArray(stride*2, pSrcData);
mTriangleData->appendArray(stride, v0);
mTriangleData->appendArray(stride*2, pSrcData);
pSrcData += stride;
}
}
}
return pTriangleData;
return mTriangleData;
}
//-----------------------------------------------------------------------------
// <polylist>
template<> inline const domListOfUInts *ColladaPrimitive<domPolylist>::getTriangleData()
{
if (!pTriangleData)
if (!mTriangleData)
{
// Convert polygons to triangles
pTriangleData = new domListOfUInts();
mTriangleData = new domListOfUInts();
// Check that the P element has the right number of values (this
// has been seen with certain models exported using COLLADAMax)
const domListOfUInts& vcount = primitive->getVcount()->getValue();
const domListOfUInts& vcount = mPrimitive->getVcount()->getValue();
U32 expectedCount = 0;
for (S32 iPoly = 0; iPoly < vcount.getCount(); iPoly++)
expectedCount += vcount[iPoly];
expectedCount *= stride;
if (!primitive->getP() || !primitive->getP()->getValue().getCount() ||
(primitive->getP()->getValue().getCount() != expectedCount) )
if (!mPrimitive->getP() || !mPrimitive->getP()->getValue().getCount() ||
(mPrimitive->getP()->getValue().getCount() != expectedCount) )
{
Con::warnf("<polylist> element found with invalid <p> array. This primitive will be ignored.");
return pTriangleData;
return mTriangleData;
}
domUint* pSrcData = &(primitive->getP()->getValue()[0]);
domUint* pSrcData = &(mPrimitive->getP()->getValue()[0]);
for (S32 iPoly = 0; iPoly < vcount.getCount(); iPoly++) {
// Use a simple tri-fan (centered at the first point) method of
@ -657,14 +657,14 @@ template<> inline const domListOfUInts *ColladaPrimitive<domPolylist>::getTriang
domUint* v0 = pSrcData;
pSrcData += stride;
for (S32 iTri = 0; iTri < vcount[iPoly]-2; iTri++) {
pTriangleData->appendArray(stride, v0);
pTriangleData->appendArray(stride*2, pSrcData);
mTriangleData->appendArray(stride, v0);
mTriangleData->appendArray(stride*2, pSrcData);
pSrcData += stride;
}
pSrcData += stride;
}
}
return pTriangleData;
return mTriangleData;
}
//-----------------------------------------------------------------------------
@ -680,32 +680,32 @@ template<> inline F32 convert(const char* value) { return convert<double>(value)
/// Collada animation data
struct AnimChannels : public Vector<struct AnimData*>
{
daeElement *element;
AnimChannels(daeElement* el) : element(el)
daeElement *mElement;
AnimChannels(daeElement* el) : mElement(el)
{
element->setUserData(this);
mElement->setUserData(this);
}
~AnimChannels()
{
if (element)
element->setUserData(0);
if (mElement)
mElement->setUserData(0);
}
};
struct AnimData
{
bool enabled; ///!< Used to select animation channels for the current clip
bool mEnabled; ///!< Used to select animation channels for the current clip
_SourceReader input;
_SourceReader output;
_SourceReader mInput;
_SourceReader mOutput;
_SourceReader inTangent;
_SourceReader outTangent;
_SourceReader mInTangent;
_SourceReader mOutTangent;
_SourceReader interpolation;
_SourceReader mInterpolation;
U32 targetValueOffset; ///< Offset into the target element (for arrays of values)
U32 targetValueCount; ///< Number of values animated (from OUTPUT source array)
U32 mTargetValueOffset; ///< Offset into the target element (for arrays of values)
U32 mTargetValueCount; ///< Number of values animated (from OUTPUT source array)
/// Get the animation channels for the Collada element (if any)
static AnimChannels* getAnimChannels(const daeElement* element)
@ -713,7 +713,7 @@ struct AnimData
return element ? (AnimChannels*)const_cast<daeElement*>(element)->getUserData() : 0;
}
AnimData() : enabled(false) { }
AnimData() : mEnabled(false) { }
void parseTargetString(const char* target, S32 fullCount, const char* elements[]);
@ -737,13 +737,13 @@ struct AnimData
template<class T>
struct AnimatedElement
{
const daeElement* element; ///< The Collada element (can be NULL)
T defaultVal; ///< Default value (used when element is NULL)
const daeElement* mElement; ///< The Collada element (can be NULL)
T mDefaultVal; ///< Default value (used when element is NULL)
AnimatedElement(const daeElement* e=0) : element(e) { }
AnimatedElement(const daeElement* e=0) : mElement(e) { }
/// Check if the element has any animations channels
bool isAnimated() { return (AnimData::getAnimChannels(element) != 0); }
bool isAnimated() { return (AnimData::getAnimChannels(mElement) != 0); }
bool isAnimated(F32 start, F32 end) { return isAnimated(); }
/// Get the value of the element at the specified time
@ -751,17 +751,17 @@ struct AnimatedElement
{
// If the element is NULL, just use the default (handy for <extra> profiles which
// may or may not be present in the document)
T value(defaultVal);
if (const domAny* param = daeSafeCast<domAny>(const_cast<daeElement*>(element))) {
T value(mDefaultVal);
if (const domAny* param = daeSafeCast<domAny>(const_cast<daeElement*>(mElement))) {
// If the element is not animated, just use its current value
value = convert<T>(param->getValue());
// Animate the value
const AnimChannels* channels = AnimData::getAnimChannels(element);
const AnimChannels* channels = AnimData::getAnimChannels(mElement);
if (channels && (time >= 0)) {
for (S32 iChannel = 0; iChannel < channels->size(); iChannel++) {
const AnimData* animData = (*channels)[iChannel];
if (animData->enabled)
if (animData->mEnabled)
animData->interpValue(time, 0, &value);
}
}
@ -781,19 +781,19 @@ template<class T> struct AnimatedElementList : public AnimatedElement<T>
// Get the value of the element list at the specified time
T getValue(F32 time)
{
T vec(this->defaultVal);
if (this->element) {
T vec(this->mDefaultVal);
if (this->mElement) {
// Get a copy of the vector
vec = *(T*)const_cast<daeElement*>(this->element)->getValuePointer();
vec = *(T*)const_cast<daeElement*>(this->mElement)->getValuePointer();
// Animate the vector
const AnimChannels* channels = AnimData::getAnimChannels(this->element);
const AnimChannels* channels = AnimData::getAnimChannels(this->mElement);
if (channels && (time >= 0)) {
for (S32 iChannel = 0; iChannel < channels->size(); iChannel++) {
const AnimData* animData = (*channels)[iChannel];
if (animData->enabled) {
for (S32 iValue = 0; iValue < animData->targetValueCount; iValue++)
animData->interpValue(time, iValue, &vec[animData->targetValueOffset + iValue]);
if (animData->mEnabled) {
for (S32 iValue = 0; iValue < animData->mTargetValueCount; iValue++)
animData->interpValue(time, iValue, &vec[animData->mTargetValueOffset + iValue]);
}
}
}

View file

@ -23,10 +23,10 @@
#include "ts/loader/appMesh.h"
#include "ts/loader/tsShapeLoader.h"
Vector<AppMaterial*> AppMesh::appMaterials;
Vector<AppMaterial*> AppMesh::mAppMaterials;
AppMesh::AppMesh()
: flags(0), numFrames(0), numMatFrames(0), vertsPerFrame(0)
: mFlags(0), mNumFrames(0), mNumMatFrames(0), mVertsPerFrame(0)
{
}
@ -44,43 +44,43 @@ void AppMesh::computeBounds(Box3F& bounds)
// Setup bone transforms
Vector<MatrixF> boneTransforms;
boneTransforms.setSize( nodeIndex.size() );
boneTransforms.setSize( mNodeIndex.size() );
for (S32 iBone = 0; iBone < boneTransforms.size(); iBone++)
{
MatrixF nodeMat = bones[iBone]->getNodeTransform( TSShapeLoader::DefaultTime );
MatrixF nodeMat = mBones[iBone]->getNodeTransform( TSShapeLoader::smDefaultTime );
TSShapeLoader::zapScale(nodeMat);
boneTransforms[iBone].mul( nodeMat, initialTransforms[iBone] );
boneTransforms[iBone].mul( nodeMat, mInitialTransforms[iBone] );
}
// Multiply verts by weighted bone transforms
for (S32 iVert = 0; iVert < initialVerts.size(); iVert++)
points[iVert].set( Point3F::Zero );
for (S32 iVert = 0; iVert < mInitialVerts.size(); iVert++)
mPoints[iVert].set( Point3F::Zero );
for (S32 iWeight = 0; iWeight < vertexIndex.size(); iWeight++)
for (S32 iWeight = 0; iWeight < mVertexIndex.size(); iWeight++)
{
const S32& vertIndex = vertexIndex[iWeight];
const MatrixF& deltaTransform = boneTransforms[ boneIndex[iWeight] ];
const S32& vertIndex = mVertexIndex[iWeight];
const MatrixF& deltaTransform = boneTransforms[ mBoneIndex[iWeight] ];
Point3F v;
deltaTransform.mulP( initialVerts[vertIndex], &v );
v *= weight[iWeight];
deltaTransform.mulP( mInitialVerts[vertIndex], &v );
v *= mWeight[iWeight];
points[vertIndex] += v;
mPoints[vertIndex] += v;
}
// compute bounds for the skinned mesh
for (S32 iVert = 0; iVert < initialVerts.size(); iVert++)
bounds.extend( points[iVert] );
for (S32 iVert = 0; iVert < mInitialVerts.size(); iVert++)
bounds.extend( mPoints[iVert] );
}
else
{
MatrixF transform = getMeshTransform(TSShapeLoader::DefaultTime);
MatrixF transform = getMeshTransform(TSShapeLoader::smDefaultTime);
TSShapeLoader::zapScale(transform);
for (S32 iVert = 0; iVert < points.size(); iVert++)
for (S32 iVert = 0; iVert < mPoints.size(); iVert++)
{
Point3F p;
transform.mulP(points[iVert], &p);
transform.mulP(mPoints[iVert], &p);
bounds.extend(p);
}
}
@ -89,39 +89,39 @@ void AppMesh::computeBounds(Box3F& bounds)
void AppMesh::computeNormals()
{
// Clear normals
normals.setSize( points.size() );
for (S32 iNorm = 0; iNorm < normals.size(); iNorm++)
normals[iNorm] = Point3F::Zero;
mNormals.setSize( mPoints.size() );
for (S32 iNorm = 0; iNorm < mNormals.size(); iNorm++)
mNormals[iNorm] = Point3F::Zero;
// Sum triangle normals for each vertex
for (S32 iPrim = 0; iPrim < primitives.size(); iPrim++)
for (S32 iPrim = 0; iPrim < mPrimitives.size(); iPrim++)
{
const TSDrawPrimitive& prim = primitives[iPrim];
const TSDrawPrimitive& prim = mPrimitives[iPrim];
for (S32 iInd = 0; iInd < prim.numElements; iInd += 3)
{
// Compute the normal for this triangle
S32 idx0 = indices[prim.start + iInd + 0];
S32 idx1 = indices[prim.start + iInd + 1];
S32 idx2 = indices[prim.start + iInd + 2];
S32 idx0 = mIndices[prim.start + iInd + 0];
S32 idx1 = mIndices[prim.start + iInd + 1];
S32 idx2 = mIndices[prim.start + iInd + 2];
const Point3F& v0 = points[idx0];
const Point3F& v1 = points[idx1];
const Point3F& v2 = points[idx2];
const Point3F& v0 = mPoints[idx0];
const Point3F& v1 = mPoints[idx1];
const Point3F& v2 = mPoints[idx2];
Point3F n;
mCross(v2 - v0, v1 - v0, &n);
n.normalize(); // remove this to use 'weighted' normals (large triangles will have more effect)
normals[idx0] += n;
normals[idx1] += n;
normals[idx2] += n;
mNormals[idx0] += n;
mNormals[idx1] += n;
mNormals[idx2] += n;
}
}
// Normalize the vertex normals (this takes care of averaging the triangle normals)
for (S32 iNorm = 0; iNorm < normals.size(); iNorm++)
normals[iNorm].normalize();
for (S32 iNorm = 0; iNorm < mNormals.size(); iNorm++)
mNormals[iNorm].normalize();
}
TSMesh* AppMesh::constructTSMesh()
@ -133,13 +133,13 @@ TSMesh* AppMesh::constructTSMesh()
tsmesh = tsskin;
// Copy skin elements
tsskin->weight = weight;
tsskin->boneIndex = boneIndex;
tsskin->vertexIndex = vertexIndex;
tsskin->batchData.nodeIndex = nodeIndex;
tsskin->batchData.initialTransforms = initialTransforms;
tsskin->batchData.initialVerts = initialVerts;
tsskin->batchData.initialNorms = initialNorms;
tsskin->mWeight = mWeight;
tsskin->mBoneIndex = mBoneIndex;
tsskin->mVertexIndex = mVertexIndex;
tsskin->mBatchData.nodeIndex = mNodeIndex;
tsskin->mBatchData.initialTransforms = mInitialTransforms;
tsskin->mBatchData.initialVerts = mInitialVerts;
tsskin->mBatchData.initialNorms = mInitialNorms;
}
else
{
@ -147,22 +147,22 @@ TSMesh* AppMesh::constructTSMesh()
}
// Copy mesh elements
tsmesh->verts = points;
tsmesh->norms = normals;
tsmesh->tverts = uvs;
tsmesh->primitives = primitives;
tsmesh->indices = indices;
tsmesh->colors = colors;
tsmesh->tverts2 = uv2s;
tsmesh->mVerts = mPoints;
tsmesh->mNorms = mNormals;
tsmesh->mTVerts = mUVs;
tsmesh->mPrimitives = mPrimitives;
tsmesh->mIndices = mIndices;
tsmesh->mColors = mColors;
tsmesh->mTVerts2 = mUV2s;
// Finish initializing the shape
tsmesh->setFlags(flags);
tsmesh->setFlags(mFlags);
tsmesh->computeBounds();
tsmesh->numFrames = numFrames;
tsmesh->numMatFrames = numMatFrames;
tsmesh->vertsPerFrame = vertsPerFrame;
tsmesh->createTangents(tsmesh->verts, tsmesh->norms);
tsmesh->encodedNorms.set(NULL,0);
tsmesh->mNumFrames = mNumFrames;
tsmesh->mNumMatFrames = mNumMatFrames;
tsmesh->mVertsPerFrame = mVertsPerFrame;
tsmesh->createTangents(tsmesh->mVerts, tsmesh->mNorms);
tsmesh->mEncodedNorms.set(NULL,0);
return tsmesh;
}

View file

@ -42,33 +42,33 @@ class AppMesh
{
public:
// Mesh and skin elements
Vector<Point3F> points;
Vector<Point3F> normals;
Vector<Point2F> uvs;
Vector<Point2F> uv2s;
Vector<ColorI> colors;
Vector<TSDrawPrimitive> primitives;
Vector<U32> indices;
Vector<Point3F> mPoints;
Vector<Point3F> mNormals;
Vector<Point2F> mUVs;
Vector<Point2F> mUV2s;
Vector<ColorI> mColors;
Vector<TSDrawPrimitive> mPrimitives;
Vector<U32> mIndices;
// Skin elements
Vector<F32> weight;
Vector<S32> boneIndex;
Vector<S32> vertexIndex;
Vector<S32> nodeIndex;
Vector<MatrixF> initialTransforms;
Vector<Point3F> initialVerts;
Vector<Point3F> initialNorms;
Vector<F32> mWeight;
Vector<S32> mBoneIndex;
Vector<S32> mVertexIndex;
Vector<S32> mNodeIndex;
Vector<MatrixF> mInitialTransforms;
Vector<Point3F> mInitialVerts;
Vector<Point3F> mInitialNorms;
U32 flags;
U32 vertsPerFrame;
S32 numFrames;
S32 numMatFrames;
U32 mFlags;
U32 mVertsPerFrame;
S32 mNumFrames;
S32 mNumMatFrames;
// Loader elements (can be discarded after loading)
S32 detailSize;
MatrixF objectOffset;
Vector<AppNode*> bones;
static Vector<AppMaterial*> appMaterials;
S32 mDetailSize;
MatrixF mObjectOffset;
Vector<AppNode*> mBones;
static Vector<AppMaterial*> mAppMaterials;
public:
AppMesh();

File diff suppressed because it is too large Load diff

View file

@ -94,31 +94,31 @@ protected:
};
public:
static const F32 DefaultTime;
static const F64 MinFrameRate;
static const F64 MaxFrameRate;
static const F64 AppGroundFrameRate;
static const F32 smDefaultTime;
static const F64 smMinFrameRate;
static const F64 smMaxFrameRate;
static const F64 smAppGroundFrameRate;
protected:
// Variables used during loading that must be held until the shape is deleted
TSShape* shape;
Vector<AppMesh*> appMeshes;
TSShape* mShape;
Vector<AppMesh*> mAppMeshes;
// Variables used during loading, but that can be discarded afterwards
static Torque::Path shapePath;
static Torque::Path smShapePath;
AppNode* boundsNode;
Vector<AppNode*> appNodes; ///< Nodes in the loaded shape
Vector<AppSequence*> appSequences;
AppNode* mBoundsNode;
Vector<AppNode*> mAppNodes; ///< Nodes in the loaded shape
Vector<AppSequence*> mAppSequences;
Vector<Subshape*> subshapes;
Vector<Subshape*> mSubShapes;
Vector<QuatF*> nodeRotCache;
Vector<Point3F*> nodeTransCache;
Vector<QuatF*> nodeScaleRotCache;
Vector<Point3F*> nodeScaleCache;
Vector<QuatF*> mNodeRotCache;
Vector<Point3F*> mNodeTransCache;
Vector<QuatF*> mNodeScaleRotCache;
Vector<Point3F*> mNodeScaleCache;
Point3F shapeOffset; ///< Offset used to translate the shape origin
Point3F mShapeOffset; ///< Offset used to translate the shape origin
//--------------------------------------------------------------------------
@ -183,10 +183,10 @@ protected:
void install();
public:
TSShapeLoader() : boundsNode(0) { }
TSShapeLoader() : mBoundsNode(0) { }
virtual ~TSShapeLoader();
static const Torque::Path& getShapePath() { return shapePath; }
static const Torque::Path& getShapePath() { return smShapePath; }
static void zapScale(MatrixF& mat);

View file

@ -43,14 +43,14 @@ void TSShapeInstance::sortThreads()
void TSShapeInstance::setDirty(U32 dirty)
{
AssertFatal((dirty & AllDirtyMask) == dirty,"TSShapeInstance::setDirty: illegal dirty flags");
for (S32 i=0; i<mShape->subShapeFirstNode.size(); i++)
for (S32 i=0; i<mShape->mSubShapeFirstNode.size(); i++)
mDirtyFlags[i] |= dirty;
}
void TSShapeInstance::clearDirty(U32 dirty)
{
AssertFatal((dirty & AllDirtyMask) == dirty,"TSShapeInstance::clearDirty: illegal dirty flags");
for (S32 i=0; i<mShape->subShapeFirstNode.size(); i++)
for (S32 i=0; i<mShape->mSubShapeFirstNode.size(); i++)
mDirtyFlags[i] &= ~dirty;
}
@ -62,25 +62,25 @@ void TSShapeInstance::animateNodes(S32 ss)
{
PROFILE_SCOPE( TSShapeInstance_animateNodes );
if (!mShape->nodes.size())
if (!mShape->mNodes.size())
return;
// @todo: When a node is added, we need to make sure to resize the nodeTransforms array as well
mNodeTransforms.setSize(mShape->nodes.size());
mNodeTransforms.setSize(mShape->mNodes.size());
// temporary storage for node transforms
smNodeCurrentRotations.setSize(mShape->nodes.size());
smNodeCurrentTranslations.setSize(mShape->nodes.size());
smNodeLocalTransforms.setSize(mShape->nodes.size());
smRotationThreads.setSize(mShape->nodes.size());
smTranslationThreads.setSize(mShape->nodes.size());
smNodeCurrentRotations.setSize(mShape->mNodes.size());
smNodeCurrentTranslations.setSize(mShape->mNodes.size());
smNodeLocalTransforms.setSize(mShape->mNodes.size());
smRotationThreads.setSize(mShape->mNodes.size());
smTranslationThreads.setSize(mShape->mNodes.size());
TSIntegerSet rotBeenSet;
TSIntegerSet tranBeenSet;
TSIntegerSet scaleBeenSet;
rotBeenSet.setAll(mShape->nodes.size());
tranBeenSet.setAll(mShape->nodes.size());
scaleBeenSet.setAll(mShape->nodes.size());
rotBeenSet.setAll(mShape->mNodes.size());
tranBeenSet.setAll(mShape->mNodes.size());
scaleBeenSet.setAll(mShape->mNodes.size());
smNodeLocalTransformDirty.clearAll();
S32 i,j,nodeIndex,a,b,start,end,firstBlend = mThreadList.size();
@ -114,18 +114,18 @@ void TSShapeInstance::animateNodes(S32 ss)
// we'll set default regardless of mask status
// all the nodes marked above need to have the default transform
a = mShape->subShapeFirstNode[ss];
b = a + mShape->subShapeNumNodes[ss];
a = mShape->mSubShapeFirstNode[ss];
b = a + mShape->mSubShapeNumNodes[ss];
for (i=a; i<b; i++)
{
if (rotBeenSet.test(i))
{
mShape->defaultRotations[i].getQuatF(&smNodeCurrentRotations[i]);
mShape->mDefaultRotations[i].getQuatF(&smNodeCurrentRotations[i]);
smRotationThreads[i] = NULL;
}
if (tranBeenSet.test(i))
{
smNodeCurrentTranslations[i] = mShape->defaultTranslations[i];
smNodeCurrentTranslations[i] = mShape->mDefaultTranslations[i];
smTranslationThreads[i] = NULL;
}
}
@ -157,9 +157,9 @@ void TSShapeInstance::animateNodes(S32 ss)
if (!rotBeenSet.test(nodeIndex))
{
QuatF q1,q2;
mShape->getRotation(*th->getSequence(),th->keyNum1,j,&q1);
mShape->getRotation(*th->getSequence(),th->keyNum2,j,&q2);
TSTransform::interpolate(q1,q2,th->keyPos,&smNodeCurrentRotations[nodeIndex]);
mShape->getRotation(*th->getSequence(),th->mKeyNum1,j,&q1);
mShape->getRotation(*th->getSequence(),th->mKeyNum2,j,&q2);
TSTransform::interpolate(q1,q2,th->mKeyPos,&smNodeCurrentRotations[nodeIndex]);
rotBeenSet.set(nodeIndex);
smRotationThreads[nodeIndex] = th;
}
@ -178,9 +178,9 @@ void TSShapeInstance::animateNodes(S32 ss)
handleMaskedPositionNode(th,nodeIndex,j);
else
{
const Point3F & p1 = mShape->getTranslation(*th->getSequence(),th->keyNum1,j);
const Point3F & p2 = mShape->getTranslation(*th->getSequence(),th->keyNum2,j);
TSTransform::interpolate(p1,p2,th->keyPos,&smNodeCurrentTranslations[nodeIndex]);
const Point3F & p1 = mShape->getTranslation(*th->getSequence(),th->mKeyNum1,j);
const Point3F & p2 = mShape->getTranslation(*th->getSequence(),th->mKeyNum2,j);
TSTransform::interpolate(p1,p2,th->mKeyPos,&smNodeCurrentTranslations[nodeIndex]);
smTranslationThreads[nodeIndex] = th;
}
tranBeenSet.set(nodeIndex);
@ -222,7 +222,7 @@ void TSShapeInstance::animateNodes(S32 ss)
for (i=firstBlend; i<mThreadList.size(); i++)
{
TSThread * th = mThreadList[i];
if (th->blendDisabled)
if (th->mBlendDisabled)
continue;
handleBlendSequence(th,a,b);
@ -235,7 +235,7 @@ void TSShapeInstance::animateNodes(S32 ss)
// multiply transforms...
for (i=a; i<b; i++)
{
S32 parentIdx = mShape->nodes[i].parentIndex;
S32 parentIdx = mShape->mNodes[i].parentIndex;
if (parentIdx < 0)
mNodeTransforms[i] = smNodeLocalTransforms[i];
else
@ -248,12 +248,12 @@ void TSShapeInstance::handleDefaultScale(S32 a, S32 b, TSIntegerSet & scaleBeenS
// set default scale values (i.e., identity) and do any initialization
// relating to animated scale (since scale normally not animated)
smScaleThreads.setSize(mShape->nodes.size());
smScaleThreads.setSize(mShape->mNodes.size());
scaleBeenSet.takeAway(mCallbackNodes);
scaleBeenSet.takeAway(mHandsOffNodes);
if (animatesUniformScale())
{
smNodeCurrentUniformScales.setSize(mShape->nodes.size());
smNodeCurrentUniformScales.setSize(mShape->mNodes.size());
for (S32 i=a; i<b; i++)
if (scaleBeenSet.test(i))
{
@ -263,7 +263,7 @@ void TSShapeInstance::handleDefaultScale(S32 a, S32 b, TSIntegerSet & scaleBeenS
}
else if (animatesAlignedScale())
{
smNodeCurrentAlignedScales.setSize(mShape->nodes.size());
smNodeCurrentAlignedScales.setSize(mShape->mNodes.size());
for (S32 i=a; i<b; i++)
if (scaleBeenSet.test(i))
{
@ -273,7 +273,7 @@ void TSShapeInstance::handleDefaultScale(S32 a, S32 b, TSIntegerSet & scaleBeenS
}
else
{
smNodeCurrentArbitraryScales.setSize(mShape->nodes.size());
smNodeCurrentArbitraryScales.setSize(mShape->mNodes.size());
for (S32 i=a; i<b; i++)
if (scaleBeenSet.test(i))
{
@ -330,7 +330,7 @@ void TSShapeInstance::handleTransitionNodes(S32 a, S32 b)
if (nodeIndex<a)
continue;
TSThread * thread = smRotationThreads[nodeIndex];
thread = thread && thread->transitionData.inTransition ? thread : NULL;
thread = thread && thread->mTransitionData.inTransition ? thread : NULL;
if (!thread)
{
// if not controlled by a sequence in transition then there must be
@ -338,7 +338,7 @@ void TSShapeInstance::handleTransitionNodes(S32 a, S32 b)
// transition now...use that thread to control interpolation
for (S32 i=0; i<mTransitionThreads.size(); i++)
{
if (mTransitionThreads[i]->transitionData.oldRotationNodes.test(nodeIndex) || mTransitionThreads[i]->getSequence()->rotationMatters.test(nodeIndex))
if (mTransitionThreads[i]->mTransitionData.oldRotationNodes.test(nodeIndex) || mTransitionThreads[i]->getSequence()->rotationMatters.test(nodeIndex))
{
thread = mTransitionThreads[i];
break;
@ -347,7 +347,7 @@ void TSShapeInstance::handleTransitionNodes(S32 a, S32 b)
AssertFatal(thread!=NULL,"TSShapeInstance::handleRotTransitionNodes (rotation)");
}
QuatF tmpQ;
TSTransform::interpolate(mNodeReferenceRotations[nodeIndex].getQuatF(&tmpQ),smNodeCurrentRotations[nodeIndex],thread->transitionData.pos,&smNodeCurrentRotations[nodeIndex]);
TSTransform::interpolate(mNodeReferenceRotations[nodeIndex].getQuatF(&tmpQ),smNodeCurrentRotations[nodeIndex],thread->mTransitionData.pos,&smNodeCurrentRotations[nodeIndex]);
}
// then translation
@ -356,7 +356,7 @@ void TSShapeInstance::handleTransitionNodes(S32 a, S32 b)
for (nodeIndex=start; nodeIndex<end; mTransitionTranslationNodes.next(nodeIndex))
{
TSThread * thread = smTranslationThreads[nodeIndex];
thread = thread && thread->transitionData.inTransition ? thread : NULL;
thread = thread && thread->mTransitionData.inTransition ? thread : NULL;
if (!thread)
{
// if not controlled by a sequence in transition then there must be
@ -364,7 +364,7 @@ void TSShapeInstance::handleTransitionNodes(S32 a, S32 b)
// transition now...use that thread to control interpolation
for (S32 i=0; i<mTransitionThreads.size(); i++)
{
if (mTransitionThreads[i]->transitionData.oldTranslationNodes.test(nodeIndex) || mTransitionThreads[i]->getSequence()->translationMatters.test(nodeIndex))
if (mTransitionThreads[i]->mTransitionData.oldTranslationNodes.test(nodeIndex) || mTransitionThreads[i]->getSequence()->translationMatters.test(nodeIndex))
{
thread = mTransitionThreads[i];
break;
@ -375,7 +375,7 @@ void TSShapeInstance::handleTransitionNodes(S32 a, S32 b)
Point3F & p = smNodeCurrentTranslations[nodeIndex];
Point3F & p1 = mNodeReferenceTranslations[nodeIndex];
Point3F & p2 = p;
F32 k = thread->transitionData.pos;
F32 k = thread->mTransitionData.pos;
p.x = p1.x + k * (p2.x-p1.x);
p.y = p1.y + k * (p2.y-p1.y);
p.z = p1.z + k * (p2.z-p1.z);
@ -389,7 +389,7 @@ void TSShapeInstance::handleTransitionNodes(S32 a, S32 b)
for (nodeIndex=start; nodeIndex<end; mTransitionScaleNodes.next(nodeIndex))
{
TSThread * thread = smScaleThreads[nodeIndex];
thread = thread && thread->transitionData.inTransition ? thread : NULL;
thread = thread && thread->mTransitionData.inTransition ? thread : NULL;
if (!thread)
{
// if not controlled by a sequence in transition then there must be
@ -397,7 +397,7 @@ void TSShapeInstance::handleTransitionNodes(S32 a, S32 b)
// transition now...use that thread to control interpolation
for (S32 i=0; i<mTransitionThreads.size(); i++)
{
if (mTransitionThreads[i]->transitionData.oldScaleNodes.test(nodeIndex) || mTransitionThreads[i]->getSequence()->scaleMatters.test(nodeIndex))
if (mTransitionThreads[i]->mTransitionData.oldScaleNodes.test(nodeIndex) || mTransitionThreads[i]->getSequence()->scaleMatters.test(nodeIndex))
{
thread = mTransitionThreads[i];
break;
@ -406,14 +406,14 @@ void TSShapeInstance::handleTransitionNodes(S32 a, S32 b)
AssertFatal(thread!=NULL,"TSShapeInstance::handleTransitionNodes (scale).");
}
if (animatesUniformScale())
smNodeCurrentUniformScales[nodeIndex] += thread->transitionData.pos * (mNodeReferenceUniformScales[nodeIndex]-smNodeCurrentUniformScales[nodeIndex]);
smNodeCurrentUniformScales[nodeIndex] += thread->mTransitionData.pos * (mNodeReferenceUniformScales[nodeIndex]-smNodeCurrentUniformScales[nodeIndex]);
else if (animatesAlignedScale())
TSTransform::interpolate(mNodeReferenceScaleFactors[nodeIndex],smNodeCurrentAlignedScales[nodeIndex],thread->transitionData.pos,&smNodeCurrentAlignedScales[nodeIndex]);
TSTransform::interpolate(mNodeReferenceScaleFactors[nodeIndex],smNodeCurrentAlignedScales[nodeIndex],thread->mTransitionData.pos,&smNodeCurrentAlignedScales[nodeIndex]);
else
{
QuatF q;
TSTransform::interpolate(mNodeReferenceScaleFactors[nodeIndex],smNodeCurrentArbitraryScales[nodeIndex].mScale,thread->transitionData.pos,&smNodeCurrentArbitraryScales[nodeIndex].mScale);
TSTransform::interpolate(mNodeReferenceArbitraryScaleRots[nodeIndex].getQuatF(&q),smNodeCurrentArbitraryScales[nodeIndex].mRotate,thread->transitionData.pos,&smNodeCurrentArbitraryScales[nodeIndex].mRotate);
TSTransform::interpolate(mNodeReferenceScaleFactors[nodeIndex],smNodeCurrentArbitraryScales[nodeIndex].mScale,thread->mTransitionData.pos,&smNodeCurrentArbitraryScales[nodeIndex].mScale);
TSTransform::interpolate(mNodeReferenceArbitraryScaleRots[nodeIndex].getQuatF(&q),smNodeCurrentArbitraryScales[nodeIndex].mRotate,thread->mTransitionData.pos,&smNodeCurrentArbitraryScales[nodeIndex].mRotate);
}
}
}
@ -498,26 +498,26 @@ void TSShapeInstance::handleAnimatedScale(TSThread * thread, S32 a, S32 b, TSInt
case 4: // uniform -> aligned
case 8: // uniform -> arbitrary
{
F32 s1 = mShape->getUniformScale(*thread->getSequence(),thread->keyNum1,j);
F32 s2 = mShape->getUniformScale(*thread->getSequence(),thread->keyNum2,j);
uniformScale = TSTransform::interpolate(s1,s2,thread->keyPos);
F32 s1 = mShape->getUniformScale(*thread->getSequence(),thread->mKeyNum1,j);
F32 s2 = mShape->getUniformScale(*thread->getSequence(),thread->mKeyNum2,j);
uniformScale = TSTransform::interpolate(s1,s2,thread->mKeyPos);
alignedScale.set(uniformScale,uniformScale,uniformScale);
break;
}
case 5: // aligned -> aligned
case 9: // aligned -> arbitrary
{
const Point3F & s1 = mShape->getAlignedScale(*thread->getSequence(),thread->keyNum1,j);
const Point3F & s2 = mShape->getAlignedScale(*thread->getSequence(),thread->keyNum2,j);
TSTransform::interpolate(s1,s2,thread->keyPos,&alignedScale);
const Point3F & s1 = mShape->getAlignedScale(*thread->getSequence(),thread->mKeyNum1,j);
const Point3F & s2 = mShape->getAlignedScale(*thread->getSequence(),thread->mKeyNum2,j);
TSTransform::interpolate(s1,s2,thread->mKeyPos,&alignedScale);
break;
}
case 10: // arbitrary -> arbitary
{
TSScale s1,s2;
mShape->getArbitraryScale(*thread->getSequence(),thread->keyNum1,j,&s1);
mShape->getArbitraryScale(*thread->getSequence(),thread->keyNum2,j,&s2);
TSTransform::interpolate(s1,s2,thread->keyPos,&arbitraryScale);
mShape->getArbitraryScale(*thread->getSequence(),thread->mKeyNum1,j,&s1);
mShape->getArbitraryScale(*thread->getSequence(),thread->mKeyNum2,j,&s2);
TSTransform::interpolate(s1,s2,thread->mKeyPos,&arbitraryScale);
break;
}
default: AssertFatal(0,"TSShapeInstance::handleAnimatedScale"); break;
@ -556,10 +556,10 @@ void TSShapeInstance::handleAnimatedScale(TSThread * thread, S32 a, S32 b, TSInt
void TSShapeInstance::handleMaskedPositionNode(TSThread * th, S32 nodeIndex, S32 offset)
{
const Point3F & p1 = mShape->getTranslation(*th->getSequence(),th->keyNum1,offset);
const Point3F & p2 = mShape->getTranslation(*th->getSequence(),th->keyNum2,offset);
const Point3F & p1 = mShape->getTranslation(*th->getSequence(),th->mKeyNum1,offset);
const Point3F & p2 = mShape->getTranslation(*th->getSequence(),th->mKeyNum2,offset);
Point3F p;
TSTransform::interpolate(p1,p2,th->keyPos,&p);
TSTransform::interpolate(p1,p2,th->mKeyPos,&p);
if (!mMaskPosXNodes.test(nodeIndex))
smNodeCurrentTranslations[nodeIndex].x = p.x;
@ -600,20 +600,20 @@ void TSShapeInstance::handleBlendSequence(TSThread * thread, S32 a, S32 b)
if (thread->getSequence()->rotationMatters.test(nodeIndex))
{
QuatF q1,q2;
mShape->getRotation(*thread->getSequence(),thread->keyNum1,jrot,&q1);
mShape->getRotation(*thread->getSequence(),thread->keyNum2,jrot,&q2);
mShape->getRotation(*thread->getSequence(),thread->mKeyNum1,jrot,&q1);
mShape->getRotation(*thread->getSequence(),thread->mKeyNum2,jrot,&q2);
QuatF quat;
TSTransform::interpolate(q1,q2,thread->keyPos,&quat);
TSTransform::interpolate(q1,q2,thread->mKeyPos,&quat);
TSTransform::setMatrix(quat,&mat);
jrot++;
}
if (thread->getSequence()->translationMatters.test(nodeIndex))
{
const Point3F & p1 = mShape->getTranslation(*thread->getSequence(),thread->keyNum1,jtrans);
const Point3F & p2 = mShape->getTranslation(*thread->getSequence(),thread->keyNum2,jtrans);
const Point3F & p1 = mShape->getTranslation(*thread->getSequence(),thread->mKeyNum1,jtrans);
const Point3F & p2 = mShape->getTranslation(*thread->getSequence(),thread->mKeyNum2,jtrans);
Point3F p;
TSTransform::interpolate(p1,p2,thread->keyPos,&p);
TSTransform::interpolate(p1,p2,thread->mKeyPos,&p);
mat.setColumn(3,p);
jtrans++;
}
@ -622,26 +622,26 @@ void TSShapeInstance::handleBlendSequence(TSThread * thread, S32 a, S32 b)
{
if (thread->getSequence()->animatesUniformScale())
{
F32 s1 = mShape->getUniformScale(*thread->getSequence(),thread->keyNum1,jscale);
F32 s2 = mShape->getUniformScale(*thread->getSequence(),thread->keyNum2,jscale);
F32 scale = TSTransform::interpolate(s1,s2,thread->keyPos);
F32 s1 = mShape->getUniformScale(*thread->getSequence(),thread->mKeyNum1,jscale);
F32 s2 = mShape->getUniformScale(*thread->getSequence(),thread->mKeyNum2,jscale);
F32 scale = TSTransform::interpolate(s1,s2,thread->mKeyPos);
TSTransform::applyScale(scale,&mat);
}
else if (animatesAlignedScale())
{
Point3F s1 = mShape->getAlignedScale(*thread->getSequence(),thread->keyNum1,jscale);
Point3F s2 = mShape->getAlignedScale(*thread->getSequence(),thread->keyNum2,jscale);
Point3F s1 = mShape->getAlignedScale(*thread->getSequence(),thread->mKeyNum1,jscale);
Point3F s2 = mShape->getAlignedScale(*thread->getSequence(),thread->mKeyNum2,jscale);
Point3F scale;
TSTransform::interpolate(s1,s2,thread->keyPos,&scale);
TSTransform::interpolate(s1,s2,thread->mKeyPos,&scale);
TSTransform::applyScale(scale,&mat);
}
else
{
TSScale s1,s2;
mShape->getArbitraryScale(*thread->getSequence(),thread->keyNum1,jscale,&s1);
mShape->getArbitraryScale(*thread->getSequence(),thread->keyNum2,jscale,&s2);
mShape->getArbitraryScale(*thread->getSequence(),thread->mKeyNum1,jscale,&s1);
mShape->getArbitraryScale(*thread->getSequence(),thread->mKeyNum2,jscale,&s2);
TSScale scale;
TSTransform::interpolate(s1,s2,thread->keyPos,&scale);
TSTransform::interpolate(s1,s2,thread->mKeyPos,&scale);
TSTransform::applyScale(scale,&mat);
}
jscale++;
@ -672,12 +672,12 @@ void TSShapeInstance::animateVisibility(S32 ss)
beenSet.takeAway(mThreadList[i]->getSequence()->visMatters);
// set defaults
S32 a = mShape->subShapeFirstObject[ss];
S32 b = a + mShape->subShapeNumObjects[ss];
S32 a = mShape->mSubShapeFirstObject[ss];
S32 b = a + mShape->mSubShapeNumObjects[ss];
for (i=a; i<b; i++)
{
if (beenSet.test(i))
mMeshObjects[i].visible = mShape->objectStates[i].vis;
mMeshObjects[i].visible = mShape->mObjectStates[i].vis;
}
// go through each thread and set visibility on those objects that
@ -704,14 +704,14 @@ void TSShapeInstance::animateVisibility(S32 ss)
{
if (!beenSet.test(objectIndex) && th->getSequence()->visMatters.test(objectIndex))
{
F32 state1 = mShape->getObjectState(*th->getSequence(),th->keyNum1,j).vis;
F32 state2 = mShape->getObjectState(*th->getSequence(),th->keyNum2,j).vis;
F32 state1 = mShape->getObjectState(*th->getSequence(),th->mKeyNum1,j).vis;
F32 state2 = mShape->getObjectState(*th->getSequence(),th->mKeyNum2,j).vis;
if ((state1-state2) * (state1-state2) > 0.99f)
// goes from 0 to 1 -- discreet jump
mMeshObjects[objectIndex].visible = th->keyPos<0.5f ? state1 : state2;
mMeshObjects[objectIndex].visible = th->mKeyPos<0.5f ? state1 : state2;
else
// interpolate between keyframes when visibility change is gradual
mMeshObjects[objectIndex].visible = (1.0f-th->keyPos) * state1 + th->keyPos * state2;
mMeshObjects[objectIndex].visible = (1.0f-th->mKeyPos) * state1 + th->mKeyPos * state2;
// record change so that later threads don't over-write us...
beenSet.set(objectIndex);
@ -735,11 +735,11 @@ void TSShapeInstance::animateFrame(S32 ss)
beenSet.takeAway(mThreadList[i]->getSequence()->frameMatters);
// set defaults
S32 a = mShape->subShapeFirstObject[ss];
S32 b = a + mShape->subShapeNumObjects[ss];
S32 a = mShape->mSubShapeFirstObject[ss];
S32 b = a + mShape->mSubShapeNumObjects[ss];
for (i=a; i<b; i++)
if (beenSet.test(i))
mMeshObjects[i].frame = mShape->objectStates[i].frameIndex;
mMeshObjects[i].frame = mShape->mObjectStates[i].frameIndex;
// go through each thread and set frame on those objects that
// are not set yet and are controlled by that thread
@ -765,7 +765,7 @@ void TSShapeInstance::animateFrame(S32 ss)
{
if (!beenSet.test(objectIndex) && th->getSequence()->frameMatters.test(objectIndex))
{
S32 key = (th->keyPos<0.5f) ? th->keyNum1 : th->keyNum2;
S32 key = (th->mKeyPos<0.5f) ? th->mKeyNum1 : th->mKeyNum2;
mMeshObjects[objectIndex].frame = mShape->getObjectState(*th->getSequence(),key,j).frameIndex;
// record change so that later threads don't over-write us...
@ -790,11 +790,11 @@ void TSShapeInstance::animateMatFrame(S32 ss)
beenSet.takeAway(mThreadList[i]->getSequence()->matFrameMatters);
// set defaults
S32 a = mShape->subShapeFirstObject[ss];
S32 b = a + mShape->subShapeNumObjects[ss];
S32 a = mShape->mSubShapeFirstObject[ss];
S32 b = a + mShape->mSubShapeNumObjects[ss];
for (i=a; i<b; i++)
if (beenSet.test(i))
mMeshObjects[i].matFrame = mShape->objectStates[i].matFrameIndex;
mMeshObjects[i].matFrame = mShape->mObjectStates[i].matFrameIndex;
// go through each thread and set matFrame on those objects that
// are not set yet and are controlled by that thread
@ -820,7 +820,7 @@ void TSShapeInstance::animateMatFrame(S32 ss)
{
if (!beenSet.test(objectIndex) && th->getSequence()->matFrameMatters.test(objectIndex))
{
S32 key = (th->keyPos<0.5f) ? th->keyNum1 : th->keyNum2;
S32 key = (th->mKeyPos<0.5f) ? th->mKeyNum1 : th->mKeyNum2;
mMeshObjects[objectIndex].matFrame = mShape->getObjectState(*th->getSequence(),key,j).matFrameIndex;
// record change so that later threads don't over-write us...
@ -842,7 +842,7 @@ void TSShapeInstance::animate(S32 dl)
// nothing to do
return;
S32 ss = mShape->details[dl].subShapeNum;
S32 ss = mShape->mDetails[dl].subShapeNum;
// this is a billboard detail...
if (ss<0)
@ -878,7 +878,7 @@ void TSShapeInstance::animateNodeSubtrees(bool forceFull)
// force transforms to animate
setDirty(TransformDirty);
for (S32 i=0; i<mShape->subShapeNumNodes.size(); i++)
for (S32 i=0; i<mShape->mSubShapeNumNodes.size(); i++)
{
if (mDirtyFlags[i] & TransformDirty)
{
@ -896,7 +896,7 @@ void TSShapeInstance::animateSubtrees(bool forceFull)
// force full animate
setDirty(AllDirtyMask);
for (S32 i=0; i<mShape->subShapeNumNodes.size(); i++)
for (S32 i=0; i<mShape->mSubShapeNumNodes.size(); i++)
{
if (mDirtyFlags[i] & TransformDirty)
{
@ -909,7 +909,7 @@ void TSShapeInstance::animateSubtrees(bool forceFull)
void TSShapeInstance::addPath(TSThread *gt, F32 start, F32 end, MatrixF *mat)
{
// never get here while in transition...
AssertFatal(!gt->transitionData.inTransition,"TSShapeInstance::addPath");
AssertFatal(!gt->mTransitionData.inTransition,"TSShapeInstance::addPath");
if (!mat)
mat = &mGroundTransform;
@ -932,7 +932,7 @@ bool TSShapeInstance::initGround()
for (S32 i=0; i<mThreadList.size(); i++)
{
TSThread * th = mThreadList[i];
if (!th->transitionData.inTransition && th->getSequence()->numGroundFrames>0)
if (!th->mTransitionData.inTransition && th->getSequence()->numGroundFrames>0)
{
mGroundThread = th;
return true;
@ -950,9 +950,9 @@ void TSShapeInstance::animateGround()
if (!mGroundThread && !initGround())
return;
S32 & loop = mGroundThread->path.loop;
F32 & start = mGroundThread->path.start;
F32 & end = mGroundThread->path.end;
S32 & loop = mGroundThread->mPath.loop;
F32 & start = mGroundThread->mPath.start;
F32 & end = mGroundThread->mPath.end;
// accumulate path transform
if (loop>0)
@ -980,7 +980,7 @@ void TSShapeInstance::deltaGround(TSThread * thread, F32 start, F32 end, MatrixF
mat = &mGroundTransform;
mat->identity();
if (thread->transitionData.inTransition)
if (thread->mTransitionData.inTransition)
return;
F32 invDuration = 1.0f / thread->getDuration();
@ -994,7 +994,7 @@ void TSShapeInstance::deltaGround(TSThread * thread, F32 start, F32 end, MatrixF
void TSShapeInstance::deltaGround1(TSThread * thread, F32 start, F32 end, MatrixF& mat)
{
mat.identity();
if (thread->transitionData.inTransition)
if (thread->mTransitionData.inTransition)
return;
addPath(thread, start, end, &mat);
}

View file

@ -52,10 +52,10 @@ bool TSShapeInstance::buildPolyList(AbstractPolyList * polyList, S32 dl)
if (dl==-1)
return false;
AssertFatal(dl>=0 && dl<mShape->details.size(),"TSShapeInstance::buildPolyList");
AssertFatal(dl>=0 && dl<mShape->mDetails.size(),"TSShapeInstance::buildPolyList");
// get subshape and object detail
const TSDetail * detail = &mShape->details[dl];
const TSDetail * detail = &mShape->mDetails[dl];
S32 ss = detail->subShapeNum;
S32 od = detail->objectDetailNum;
@ -67,8 +67,8 @@ bool TSShapeInstance::buildPolyList(AbstractPolyList * polyList, S32 dl)
bool emitted = false;
U32 surfaceKey = 0;
S32 start = mShape->subShapeFirstObject[ss];
S32 end = mShape->subShapeNumObjects[ss] + start;
S32 start = mShape->mSubShapeFirstObject[ss];
S32 end = mShape->mSubShapeNumObjects[ss] + start;
if (start<end)
{
MatrixF initialMat;
@ -124,10 +124,10 @@ bool TSShapeInstance::getFeatures(const MatrixF& mat, const Point3F& n, ConvexFe
if (dl==-1)
return false;
AssertFatal(dl>=0 && dl<mShape->details.size(),"TSShapeInstance::buildPolyList");
AssertFatal(dl>=0 && dl<mShape->mDetails.size(),"TSShapeInstance::buildPolyList");
// get subshape and object detail
const TSDetail * detail = &mShape->details[dl];
const TSDetail * detail = &mShape->mDetails[dl];
S32 ss = detail->subShapeNum;
S32 od = detail->objectDetailNum;
@ -135,8 +135,8 @@ bool TSShapeInstance::getFeatures(const MatrixF& mat, const Point3F& n, ConvexFe
bool emitted = false;
U32 surfaceKey = 0;
S32 start = mShape->subShapeFirstObject[ss];
S32 end = mShape->subShapeNumObjects[ss] + start;
S32 start = mShape->mSubShapeFirstObject[ss];
S32 end = mShape->mSubShapeNumObjects[ss] + start;
if (start<end)
{
MatrixF final;
@ -168,10 +168,10 @@ bool TSShapeInstance::castRay(const Point3F & a, const Point3F & b, RayInfo * ra
if (dl==-1)
return false;
AssertFatal(dl>=0 && dl<mShape->details.size(),"TSShapeInstance::castRay");
AssertFatal(dl>=0 && dl<mShape->mDetails.size(),"TSShapeInstance::castRay");
// get subshape and object detail
const TSDetail * detail = &mShape->details[dl];
const TSDetail * detail = &mShape->mDetails[dl];
S32 ss = detail->subShapeNum;
S32 od = detail->objectDetailNum;
@ -179,8 +179,8 @@ bool TSShapeInstance::castRay(const Point3F & a, const Point3F & b, RayInfo * ra
if ( ss < 0 )
return false;
S32 start = mShape->subShapeFirstObject[ss];
S32 end = mShape->subShapeNumObjects[ss] + start;
S32 start = mShape->mSubShapeFirstObject[ss];
S32 end = mShape->mSubShapeNumObjects[ss] + start;
RayInfo saveRay;
saveRay.t = 1.0f;
const MatrixF * saveMat = NULL;
@ -255,18 +255,18 @@ bool TSShapeInstance::castRayRendered(const Point3F & a, const Point3F & b, RayI
if (dl==-1)
return false;
AssertFatal(dl>=0 && dl<mShape->details.size(),"TSShapeInstance::castRayRendered");
AssertFatal(dl>=0 && dl<mShape->mDetails.size(),"TSShapeInstance::castRayRendered");
// get subshape and object detail
const TSDetail * detail = &mShape->details[dl];
const TSDetail * detail = &mShape->mDetails[dl];
S32 ss = detail->subShapeNum;
S32 od = detail->objectDetailNum;
if ( ss == -1 )
return false;
S32 start = mShape->subShapeFirstObject[ss];
S32 end = mShape->subShapeNumObjects[ss] + start;
S32 start = mShape->mSubShapeFirstObject[ss];
S32 end = mShape->mSubShapeNumObjects[ss] + start;
RayInfo saveRay;
saveRay.t = 1.0f;
const MatrixF * saveMat = NULL;
@ -339,15 +339,15 @@ Point3F TSShapeInstance::support(const Point3F & v, S32 dl)
{
// if dl==-1, nothing to do
AssertFatal(dl != -1, "Error, should never try to collide with a non-existant detail level!");
AssertFatal(dl>=0 && dl<mShape->details.size(),"TSShapeInstance::support");
AssertFatal(dl>=0 && dl<mShape->mDetails.size(),"TSShapeInstance::support");
// get subshape and object detail
const TSDetail * detail = &mShape->details[dl];
const TSDetail * detail = &mShape->mDetails[dl];
S32 ss = detail->subShapeNum;
S32 od = detail->objectDetailNum;
S32 start = mShape->subShapeFirstObject[ss];
S32 end = mShape->subShapeNumObjects[ss] + start;
S32 start = mShape->mSubShapeFirstObject[ss];
S32 end = mShape->mSubShapeNumObjects[ss] + start;
F32 currMaxDP = -1e9f;
Point3F currSupport = Point3F(0, 0, 0);
@ -404,22 +404,22 @@ void TSShapeInstance::computeBounds(S32 dl, Box3F & bounds)
if (dl==-1)
return;
AssertFatal(dl>=0 && dl<mShape->details.size(),"TSShapeInstance::computeBounds");
AssertFatal(dl>=0 && dl<mShape->mDetails.size(),"TSShapeInstance::computeBounds");
// get subshape and object detail
const TSDetail * detail = &mShape->details[dl];
const TSDetail * detail = &mShape->mDetails[dl];
S32 ss = detail->subShapeNum;
S32 od = detail->objectDetailNum;
// use shape bounds for imposter details
if (ss < 0)
{
bounds = mShape->bounds;
bounds = mShape->mBounds;
return;
}
S32 start = mShape->subShapeFirstObject[ss];
S32 end = mShape->subShapeNumObjects[ss] + start;
S32 start = mShape->mSubShapeFirstObject[ss];
S32 end = mShape->mSubShapeNumObjects[ss] + start;
// run through objects and updating bounds as we go
bounds.minExtents.set( 10E30f, 10E30f, 10E30f);
@ -587,10 +587,10 @@ bool TSShapeInstance::buildPolyListOpcode( S32 dl, AbstractPolyList *polyList, c
if (dl==-1)
return false;
AssertFatal(dl>=0 && dl<mShape->details.size(),"TSShapeInstance::buildPolyListOpcode");
AssertFatal(dl>=0 && dl<mShape->mDetails.size(),"TSShapeInstance::buildPolyListOpcode");
// get subshape and object detail
const TSDetail * detail = &mShape->details[dl];
const TSDetail * detail = &mShape->mDetails[dl];
S32 ss = detail->subShapeNum;
if ( ss < 0 )
return false;
@ -600,8 +600,8 @@ bool TSShapeInstance::buildPolyListOpcode( S32 dl, AbstractPolyList *polyList, c
// nothing emitted yet...
bool emitted = false;
S32 start = mShape->subShapeFirstObject[ss];
S32 end = mShape->subShapeNumObjects[ss] + start;
S32 start = mShape->mSubShapeFirstObject[ss];
S32 end = mShape->mSubShapeNumObjects[ss] + start;
if (start<end)
{
MatrixF initialMat;
@ -670,12 +670,12 @@ bool TSShapeInstance::castRayOpcode( S32 dl, const Point3F & startPos, const Poi
if (dl==-1)
return false;
AssertFatal(dl>=0 && dl<mShape->details.size(),"TSShapeInstance::castRayOpcode");
AssertFatal(dl>=0 && dl<mShape->mDetails.size(),"TSShapeInstance::castRayOpcode");
info->t = 100.f;
// get subshape and object detail
const TSDetail * detail = &mShape->details[dl];
const TSDetail * detail = &mShape->mDetails[dl];
S32 ss = detail->subShapeNum;
if ( ss < 0 )
return false;
@ -686,8 +686,8 @@ bool TSShapeInstance::castRayOpcode( S32 dl, const Point3F & startPos, const Poi
bool emitted = false;
const MatrixF* saveMat = NULL;
S32 start = mShape->subShapeFirstObject[ss];
S32 end = mShape->subShapeNumObjects[ss] + start;
S32 start = mShape->mSubShapeFirstObject[ss];
S32 end = mShape->mSubShapeNumObjects[ss] + start;
if (start<end)
{
MatrixF mat;
@ -742,18 +742,18 @@ bool TSShapeInstance::castRayOpcode( S32 dl, const Point3F & startPos, const Poi
bool TSShapeInstance::buildConvexOpcode( const MatrixF &objMat, const Point3F &objScale, S32 dl, const Box3F &bounds, Convex *c, Convex *list )
{
AssertFatal(dl>=0 && dl<mShape->details.size(),"TSShapeInstance::buildConvexOpcode");
AssertFatal(dl>=0 && dl<mShape->mDetails.size(),"TSShapeInstance::buildConvexOpcode");
// get subshape and object detail
const TSDetail * detail = &mShape->details[dl];
const TSDetail * detail = &mShape->mDetails[dl];
S32 ss = detail->subShapeNum;
S32 od = detail->objectDetailNum;
// nothing emitted yet...
bool emitted = false;
S32 start = mShape->subShapeFirstObject[ss];
S32 end = mShape->subShapeNumObjects[ss] + start;
S32 start = mShape->mSubShapeFirstObject[ss];
S32 end = mShape->mSubShapeNumObjects[ss] + start;
if (start<end)
{
MatrixF initialMat = objMat;
@ -823,10 +823,10 @@ void TSShape::findColDetails( bool useVisibleMesh, Vector<S32> *outDetails, Vect
U32 highestDetail = -1;
F32 highestSize = -F32_MAX;
for ( U32 i = 0; i < details.size(); i++ )
for ( U32 i = 0; i < mDetails.size(); i++ )
{
// Make sure we skip any details that shouldn't be rendered
if ( details[i].size < 0 )
if ( mDetails[i].size < 0 )
continue;
/*
@ -838,10 +838,10 @@ void TSShape::findColDetails( bool useVisibleMesh, Vector<S32> *outDetails, Vect
*/
// Otherwise test against the current highest size
if ( details[i].size > highestSize )
if ( mDetails[i].size > highestSize )
{
highestDetail = i;
highestSize = details[i].size;
highestSize = mDetails[i].size;
}
}
@ -861,9 +861,9 @@ void TSShape::findColDetails( bool useVisibleMesh, Vector<S32> *outDetails, Vect
//
// The LOS (light of sight) details are used for raycasts.
for ( U32 i = 0; i < details.size(); i++ )
for ( U32 i = 0; i < mDetails.size(); i++ )
{
const String &name = names[ details[i].nameIndex ];
const String &name = mNames[ mDetails[i].nameIndex ];
if ( !dStrStartsWith( name, "Collision" ) )
continue;
@ -906,9 +906,9 @@ void TSShape::findColDetails( bool useVisibleMesh, Vector<S32> *outDetails, Vect
// Snag any "unmatched" LOS details and put
// them at the end of the list.
for ( U32 i = 0; i < details.size(); i++ )
for ( U32 i = 0; i < mDetails.size(); i++ )
{
const String &name = names[ details[i].nameIndex ];
const String &name = mNames[ mDetails[i].nameIndex ];
if ( !dStrStartsWith( name, "LOS" ) )
continue;
@ -954,7 +954,7 @@ PhysicsCollision* TSShape::_buildColShapes( bool useVisibleMesh, const Point3F &
// visible detail levels.
// A negative subshape on the detail means we don't have geometry.
const TSShape::Detail &detail = details[0];
const TSShape::Detail &detail = mDetails[0];
if ( detail.subShapeNum < 0 )
return NULL;
@ -964,16 +964,16 @@ PhysicsCollision* TSShape::_buildColShapes( bool useVisibleMesh, const Point3F &
polyList.setTransform( &MatrixF::Identity, scale );
// Create the collision meshes.
S32 start = subShapeFirstObject[ detail.subShapeNum ];
S32 end = start + subShapeNumObjects[ detail.subShapeNum ];
S32 start = mSubShapeFirstObject[ detail.subShapeNum ];
S32 end = start + mSubShapeNumObjects[ detail.subShapeNum ];
for ( S32 o=start; o < end; o++ )
{
const TSShape::Object &object = objects[o];
const TSShape::Object &object = mObjects[o];
if ( detail.objectDetailNum >= object.numMeshes )
continue;
// No mesh or no verts.... nothing to do.
TSMesh *mesh = meshes[ object.startMeshIndex + detail.objectDetailNum ];
TSMesh *mesh = mMeshes[ object.startMeshIndex + detail.objectDetailNum ];
if ( !mesh || mesh->mNumVerts == 0 )
continue;
@ -1013,31 +1013,31 @@ PhysicsCollision* TSShape::_buildColShapes( bool useVisibleMesh, const Point3F &
//
// TODO: We need to support LOS collision for physics.
//
for ( U32 i = 0; i < details.size(); i++ )
for ( U32 i = 0; i < mDetails.size(); i++ )
{
const TSShape::Detail &detail = details[i];
const String &name = names[detail.nameIndex];
const TSShape::Detail &detail = mDetails[i];
const String &name = mNames[detail.nameIndex];
// Is this a valid collision detail.
if ( !dStrStartsWith( name, "Collision" ) || detail.subShapeNum < 0 )
continue;
// Now go thru the meshes for this detail.
S32 start = subShapeFirstObject[ detail.subShapeNum ];
S32 end = start + subShapeNumObjects[ detail.subShapeNum ];
S32 start = mSubShapeFirstObject[ detail.subShapeNum ];
S32 end = start + mSubShapeNumObjects[ detail.subShapeNum ];
if ( start >= end )
continue;
for ( S32 o=start; o < end; o++ )
{
const TSShape::Object &object = objects[o];
const String &meshName = names[ object.nameIndex ];
const TSShape::Object &object = mObjects[o];
const String &meshName = mNames[ object.nameIndex ];
if ( object.numMeshes <= detail.objectDetailNum )
continue;
// No mesh, a flat bounds, or no verts.... nothing to do.
TSMesh *mesh = meshes[ object.startMeshIndex + detail.objectDetailNum ];
TSMesh *mesh = mMeshes[ object.startMeshIndex + detail.objectDetailNum ];
if ( !mesh || mesh->getBounds().isEmpty() || mesh->mNumVerts == 0 )
continue;
@ -1280,10 +1280,10 @@ bool TSMesh::buildConvexOpcode( const MatrixF &meshToObjectMat, const Box3F &nod
if( chunkc->getObject() != TSStaticPolysoupConvex::smCurObject )
continue;
if( chunkc->mesh != this )
if( chunkc->mMesh != this )
continue;
if( chunkc->idx != curIdx )
if( chunkc->mIdx != curIdx )
continue;
// A match! Don't need to add it.
@ -1315,18 +1315,18 @@ bool TSMesh::buildConvexOpcode( const MatrixF &meshToObjectMat, const Box3F &nod
list->registerObject( cp );
convex->addToWorkingList( cp );
cp->mesh = this;
cp->idx = curIdx;
cp->mMesh = this;
cp->mIdx = curIdx;
cp->mObject = TSStaticPolysoupConvex::smCurObject;
cp->normal = p;
cp->verts[0] = a;
cp->verts[1] = b;
cp->verts[2] = c;
cp->verts[3] = peak;
cp->mNormal = p;
cp->mVerts[0] = a;
cp->mVerts[1] = b;
cp->mVerts[2] = c;
cp->mVerts[3] = peak;
// Update the bounding box.
Box3F &bounds = cp->box;
Box3F &bounds = cp->mBox;
bounds.minExtents.set( F32_MAX, F32_MAX, F32_MAX );
bounds.maxExtents.set( -F32_MAX, -F32_MAX, -F32_MAX );
@ -1364,9 +1364,9 @@ void TSMesh::prepOpcodeCollision()
// Figure out how many triangles we have...
U32 triCount = 0;
const U32 base = 0;
for ( U32 i = 0; i < primitives.size(); i++ )
for ( U32 i = 0; i < mPrimitives.size(); i++ )
{
TSDrawPrimitive & draw = primitives[i];
TSDrawPrimitive & draw = mPrimitives[i];
const U32 start = draw.start;
AssertFatal( draw.matIndex & TSDrawPrimitive::Indexed,"TSMesh::buildPolyList (1)" );
@ -1377,16 +1377,16 @@ void TSMesh::prepOpcodeCollision()
else
{
// Have to walk the tristrip to get a count... may have degenerates
U32 idx0 = base + indices[start + 0];
U32 idx0 = base + mIndices[start + 0];
U32 idx1;
U32 idx2 = base + indices[start + 1];
U32 idx2 = base + mIndices[start + 1];
U32 * nextIdx = &idx1;
for ( S32 j = 2; j < draw.numElements; j++ )
{
*nextIdx = idx2;
// nextIdx = (j%2)==0 ? &idx0 : &idx1;
nextIdx = (U32*) ( (dsize_t)nextIdx ^ (dsize_t)&idx0 ^ (dsize_t)&idx1);
idx2 = base + indices[start + j];
idx2 = base + mIndices[start + j];
if ( idx0 == idx1 || idx0 == idx2 || idx1 == idx2 )
continue;
@ -1396,7 +1396,7 @@ void TSMesh::prepOpcodeCollision()
}
// Just do the first trilist for now.
mi->SetNbVertices( mVertexData.isReady() ? mNumVerts : verts.size() );
mi->SetNbVertices( mVertexData.isReady() ? mNumVerts : mVerts.size() );
mi->SetNbTriangles( triCount );
// Stuff everything into appropriate arrays.
@ -1407,9 +1407,9 @@ void TSMesh::prepOpcodeCollision()
mOpPoints = pts;
// add the polys...
for ( U32 i = 0; i < primitives.size(); i++ )
for ( U32 i = 0; i < mPrimitives.size(); i++ )
{
TSDrawPrimitive & draw = primitives[i];
TSDrawPrimitive & draw = mPrimitives[i];
const U32 start = draw.start;
AssertFatal( draw.matIndex & TSDrawPrimitive::Indexed,"TSMesh::buildPolyList (1)" );
@ -1421,9 +1421,9 @@ void TSMesh::prepOpcodeCollision()
{
for ( S32 j = 0; j < draw.numElements; )
{
curIts->mVRef[2] = base + indices[start + j + 0];
curIts->mVRef[1] = base + indices[start + j + 1];
curIts->mVRef[0] = base + indices[start + j + 2];
curIts->mVRef[2] = base + mIndices[start + j + 0];
curIts->mVRef[1] = base + mIndices[start + j + 1];
curIts->mVRef[0] = base + mIndices[start + j + 2];
curIts->mMatIdx = matIndex;
curIts++;
@ -1434,16 +1434,16 @@ void TSMesh::prepOpcodeCollision()
{
AssertFatal( (draw.matIndex & TSDrawPrimitive::TypeMask) == TSDrawPrimitive::Strip,"TSMesh::buildPolyList (2)" );
U32 idx0 = base + indices[start + 0];
U32 idx0 = base + mIndices[start + 0];
U32 idx1;
U32 idx2 = base + indices[start + 1];
U32 idx2 = base + mIndices[start + 1];
U32 * nextIdx = &idx1;
for ( S32 j = 2; j < draw.numElements; j++ )
{
*nextIdx = idx2;
// nextIdx = (j%2)==0 ? &idx0 : &idx1;
nextIdx = (U32*) ( (dsize_t)nextIdx ^ (dsize_t)&idx0 ^ (dsize_t)&idx1);
idx2 = base + indices[start + j];
idx2 = base + mIndices[start + j];
if ( idx0 == idx1 || idx0 == idx2 || idx1 == idx2 )
continue;
@ -1462,7 +1462,7 @@ void TSMesh::prepOpcodeCollision()
if( mVertexData.isReady() )
pts[i].Set( mVertexData[i].vert().x, mVertexData[i].vert().y, mVertexData[i].vert().z );
else
pts[i].Set( verts[i].x, verts[i].y, verts[i].z );
pts[i].Set( mVerts[i].x, mVerts[i].y, mVerts[i].z );
mi->SetPointers( its, pts );

View file

@ -50,7 +50,7 @@ void TSShapeInstance::dumpNode(Stream & stream ,S32 level, S32 nodeIndex, Vector
space[level*3] = '\0';
const char *nodeName = "";
const TSShape::Node & node = mShape->nodes[nodeIndex];
const TSShape::Node & node = mShape->mNodes[nodeIndex];
if (node.nameIndex != -1)
nodeName = mShape->getName(node.nameIndex);
dumpLine(avar("%s%s", space, nodeName));
@ -93,7 +93,7 @@ void TSShapeInstance::dumpNode(Stream & stream ,S32 level, S32 nodeIndex, Vector
for (S32 k=0; k<obj->object->numMeshes; k++)
{
S32 f = obj->object->startMeshIndex;
if (mShape->meshes[f+k])
if (mShape->mMeshes[f+k])
dumpLine(avar(" %i",detailSizes[k]));
}
@ -108,9 +108,9 @@ void TSShapeInstance::dumpNode(Stream & stream ,S32 level, S32 nodeIndex, Vector
}
// search for children
for (S32 k=nodeIndex+1; k<mShape->nodes.size(); k++)
for (S32 k=nodeIndex+1; k<mShape->mNodes.size(); k++)
{
if (mShape->nodes[k].parentIndex == nodeIndex)
if (mShape->mNodes[k].parentIndex == nodeIndex)
// this is our child
dumpNode(stream, level+1, k, detailSizes);
}
@ -126,9 +126,9 @@ void TSShapeInstance::dump(Stream & stream)
dumpLine("\r\n Details:\r\n");
for (i=0; i<mShape->details.size(); i++)
for (i=0; i<mShape->mDetails.size(); i++)
{
const TSDetail & detail = mShape->details[i];
const TSDetail & detail = mShape->mDetails[i];
name = mShape->getName(detail.nameIndex);
ss = detail.subShapeNum;
od = detail.objectDetailNum;
@ -145,23 +145,23 @@ void TSShapeInstance::dump(Stream & stream)
dumpLine("\r\n Subtrees:\r\n");
for (i=0; i<mShape->subShapeFirstNode.size(); i++)
for (i=0; i<mShape->mSubShapeFirstNode.size(); i++)
{
S32 a = mShape->subShapeFirstNode[i];
S32 b = a + mShape->subShapeNumNodes[i];
S32 a = mShape->mSubShapeFirstNode[i];
S32 b = a + mShape->mSubShapeNumNodes[i];
dumpLine(avar(" Subtree %i\r\n",i));
// compute detail sizes for each subshape
Vector<S32> detailSizes;
for (S32 l=0;l<mShape->details.size(); l++)
for (S32 l=0;l<mShape->mDetails.size(); l++)
{
if ((mShape->details[l].subShapeNum==i) || (mShape->details[l].subShapeNum==-1))
detailSizes.push_back((S32)mShape->details[l].size);
if ((mShape->mDetails[l].subShapeNum==i) || (mShape->mDetails[l].subShapeNum==-1))
detailSizes.push_back((S32)mShape->mDetails[l].size);
}
for (j=a; j<b; j++)
{
const TSNode & node = mShape->nodes[j];
const TSNode & node = mShape->mNodes[j];
// if the node has a parent, it'll get dumped via the parent
if (node.parentIndex<0)
dumpNode(stream,3,j,detailSizes);
@ -169,22 +169,22 @@ void TSShapeInstance::dump(Stream & stream)
}
bool foundSkin = false;
for (i=0; i<mShape->objects.size(); i++)
for (i=0; i<mShape->mObjects.size(); i++)
{
if (mShape->objects[i].nodeIndex<0) // must be a skin
if (mShape->mObjects[i].nodeIndex<0) // must be a skin
{
if (!foundSkin)
dumpLine("\r\n Skins:\r\n");
foundSkin=true;
const char * skinName = "";
S32 nameIndex = mShape->objects[i].nameIndex;
S32 nameIndex = mShape->mObjects[i].nameIndex;
if (nameIndex>=0)
skinName = mShape->getName(nameIndex);
dumpLine(avar(" Skin %s with following details: ",skinName));
for (S32 num=0; num<mShape->objects[i].numMeshes; num++)
for (S32 num=0; num<mShape->mObjects[i].numMeshes; num++)
{
if (mShape->meshes[mShape->objects[i].startMeshIndex + num])
dumpLine(avar(" %i",(S32)mShape->details[num].size));
if (mShape->mMeshes[mShape->mObjects[i].startMeshIndex + num])
dumpLine(avar(" %i",(S32)mShape->mDetails[num].size));
}
dumpLine("\r\n");
}
@ -193,19 +193,19 @@ void TSShapeInstance::dump(Stream & stream)
dumpLine("\r\n");
dumpLine("\r\n Sequences:\r\n");
for (i = 0; i < mShape->sequences.size(); i++)
for (i = 0; i < mShape->mSequences.size(); i++)
{
const char *name = "(none)";
if (mShape->sequences[i].nameIndex != -1)
name = mShape->getName(mShape->sequences[i].nameIndex);
if (mShape->mSequences[i].nameIndex != -1)
name = mShape->getName(mShape->mSequences[i].nameIndex);
dumpLine(avar(" %3d: %s%s%s\r\n", i, name,
mShape->sequences[i].isCyclic() ? " (cyclic)" : "",
mShape->sequences[i].isBlend() ? " (blend)" : ""));
mShape->mSequences[i].isCyclic() ? " (cyclic)" : "",
mShape->mSequences[i].isBlend() ? " (blend)" : ""));
}
if (mShape->materialList)
if (mShape->mMaterialList)
{
TSMaterialList * ml = mShape->materialList;
TSMaterialList * ml = mShape->mMaterialList;
dumpLine("\r\n Material list:\r\n");
for (i=0; i<(S32)ml->size(); i++)
{

View file

@ -82,8 +82,8 @@ TSLastDetail::TSLastDetail( TSShape *shape,
mDl = dl;
mDim = getMax( dim, (S32)32 );
mRadius = mShape->radius;
mCenter = mShape->center;
mRadius = mShape->mRadius;
mCenter = mShape->mCenter;
mCachePath = cachePath;

File diff suppressed because it is too large Load diff

View file

@ -105,7 +105,7 @@ class TSMesh
struct TSMeshVertexArray;
protected:
U32 meshType;
U32 mMeshType;
Box3F mBounds;
Point3F mCenter;
F32 mRadius;
@ -140,17 +140,17 @@ class TSMesh
FlagMask = Billboard|BillboardZAxis|HasDetailTexture|UseEncodedNormals
};
U32 getMeshType() const { return meshType & TypeMask; }
void setFlags(U32 flag) { meshType |= flag; }
void clearFlags(U32 flag) { meshType &= ~flag; }
U32 getFlags( U32 flag = 0xFFFFFFFF ) const { return meshType & flag; }
U32 getMeshType() const { return mMeshType & TypeMask; }
void setFlags(U32 flag) { mMeshType |= flag; }
void clearFlags(U32 flag) { mMeshType &= ~flag; }
U32 getFlags( U32 flag = 0xFFFFFFFF ) const { return mMeshType & flag; }
const Point3F* getNormals( S32 firstVert );
S32 parentMesh; ///< index into shapes mesh list
S32 numFrames;
S32 numMatFrames;
S32 vertsPerFrame;
S32 mParentMesh; ///< index into shapes mesh list
S32 mNumFrames;
S32 mNumMatFrames;
S32 mVertsPerFrame;
/// @name Aligned Vertex Data
/// @{
@ -244,34 +244,34 @@ class TSMesh
FreeableVector<T>& operator=(const FreeableVector<T>& p) { Vector<T>::operator=(p); return *this; }
};
FreeableVector<Point3F> verts;
FreeableVector<Point3F> norms;
FreeableVector<Point2F> tverts;
FreeableVector<Point4F> tangents;
FreeableVector<Point3F> mVerts;
FreeableVector<Point3F> mNorms;
FreeableVector<Point2F> mTVerts;
FreeableVector<Point4F> mTangents;
// Optional second texture uvs.
FreeableVector<Point2F> tverts2;
FreeableVector<Point2F> mTVerts2;
// Optional vertex colors data.
FreeableVector<ColorI> colors;
FreeableVector<ColorI> mColors;
/// @}
Vector<TSDrawPrimitive> primitives;
Vector<U8> encodedNorms;
Vector<U32> indices;
Vector<TSDrawPrimitive> mPrimitives;
Vector<U8> mEncodedNorms;
Vector<U32> mIndices;
/// billboard data
Point3F billboardAxis;
Point3F mBillboardAxis;
/// @name Convex Hull Data
/// Convex hulls are convex (no angles >= 180º) meshes used for collision
/// @{
Vector<Point3F> planeNormals;
Vector<F32> planeConstants;
Vector<U32> planeMaterials;
S32 planesPerFrame;
U32 mergeBufferStart;
Vector<Point3F> mPlaneNormals;
Vector<F32> mPlaneConstants;
Vector<U32> mPlaneMaterials;
S32 mPlanesPerFrame;
U32 mMergeBufferStart;
/// @}
/// @name Render Methods
@ -501,13 +501,13 @@ public:
typedef TSMesh Parent;
/// Structure containing data needed to batch skinning
BatchData batchData;
bool batchDataInitialized;
BatchData mBatchData;
bool mBatchDataInitialized;
/// vectors that define the vertex, weight, bone tuples
Vector<F32> weight;
Vector<S32> boneIndex;
Vector<S32> vertexIndex;
Vector<F32> mWeight;
Vector<S32> mBoneIndex;
Vector<S32> mVertexIndex;
/// set verts and normals...
void updateSkin( const Vector<MatrixF> &transforms, TSVertexBufferHandle &instanceVB, GFXPrimitiveBufferHandle &instancePB );

View file

@ -204,18 +204,18 @@ void MeshFit::initSourceGeometry( const String& target )
{
// Add all geometry in the highest detail level
S32 dl = 0;
S32 ss = mShape->details[dl].subShapeNum;
S32 ss = mShape->mDetails[dl].subShapeNum;
if ( ss < 0 )
return;
S32 od = mShape->details[dl].objectDetailNum;
S32 start = mShape->subShapeFirstObject[ss];
S32 end = start + mShape->subShapeNumObjects[ss];
S32 od = mShape->mDetails[dl].objectDetailNum;
S32 start = mShape->mSubShapeFirstObject[ss];
S32 end = start + mShape->mSubShapeNumObjects[ss];
for ( S32 i = start; i < end; i++ )
{
const TSShape::Object &obj = mShape->objects[i];
const TSMesh* mesh = ( od < obj.numMeshes ) ? mShape->meshes[obj.startMeshIndex + od] : NULL;
const TSShape::Object &obj = mShape->mObjects[i];
const TSMesh* mesh = ( od < obj.numMeshes ) ? mShape->mMeshes[obj.startMeshIndex + od] : NULL;
if ( mesh )
addSourceMesh( obj, mesh );
}
@ -227,10 +227,10 @@ void MeshFit::initSourceGeometry( const String& target )
if ( objIndex == -1 )
return;
const TSShape::Object &obj = mShape->objects[objIndex];
const TSShape::Object &obj = mShape->mObjects[objIndex];
for ( S32 i = 0; i < obj.numMeshes; i++ )
{
const TSMesh* mesh = mShape->meshes[obj.startMeshIndex + i];
const TSMesh* mesh = mShape->mMeshes[obj.startMeshIndex + i];
if ( mesh )
{
addSourceMesh( obj, mesh );
@ -246,24 +246,24 @@ void MeshFit::addSourceMesh( const TSShape::Object& obj, const TSMesh* mesh )
{
// Add indices
S32 indicesBase = mIndices.size();
for ( S32 i = 0; i < mesh->primitives.size(); i++ )
for ( S32 i = 0; i < mesh->mPrimitives.size(); i++ )
{
const TSDrawPrimitive& draw = mesh->primitives[i];
const TSDrawPrimitive& draw = mesh->mPrimitives[i];
if ( (draw.matIndex & TSDrawPrimitive::TypeMask) == TSDrawPrimitive::Triangles )
{
mIndices.merge( &mesh->indices[draw.start], draw.numElements );
mIndices.merge( &mesh->mIndices[draw.start], draw.numElements );
}
else
{
U32 idx0 = mesh->indices[draw.start + 0];
U32 idx0 = mesh->mIndices[draw.start + 0];
U32 idx1;
U32 idx2 = mesh->indices[draw.start + 1];
U32 idx2 = mesh->mIndices[draw.start + 1];
U32 *nextIdx = &idx1;
for ( S32 j = 2; j < draw.numElements; j++ )
{
*nextIdx = idx2;
nextIdx = (U32*) ( (dsize_t)nextIdx ^ (dsize_t)&idx0 ^ (dsize_t)&idx1);
idx2 = mesh->indices[draw.start + j];
idx2 = mesh->mIndices[draw.start + j];
if ( idx0 == idx1 || idx0 == idx2 || idx1 == idx2 )
continue;
@ -290,9 +290,9 @@ void MeshFit::addSourceMesh( const TSShape::Object& obj, const TSMesh* mesh )
}
else
{
count = mesh->verts.size();
count = mesh->mVerts.size();
stride = sizeof(Point3F);
pVert = (U8*)mesh->verts.address();
pVert = (U8*)mesh->mVerts.address();
}
MatrixF objMat;
@ -310,82 +310,82 @@ TSMesh* MeshFit::initMeshFromFile( const String& filename ) const
{
// Open the source shape file and make a copy of the mesh
Resource<TSShape> hShape = ResourceManager::get().load(filename);
if (!bool(hShape) || !((TSShape*)hShape)->meshes.size())
if (!bool(hShape) || !((TSShape*)hShape)->mMeshes.size())
{
Con::errorf("TSShape::createMesh: Could not load source mesh from %s", filename.c_str());
return NULL;
}
TSMesh* srcMesh = ((TSShape*)hShape)->meshes[0];
TSMesh* srcMesh = ((TSShape*)hShape)->mMeshes[0];
return mShape->copyMesh( srcMesh );
}
TSMesh* MeshFit::createTriMesh( F32* verts, S32 numVerts, U32* indices, S32 numTris ) const
{
TSMesh* mesh = mShape->copyMesh( NULL );
mesh->numFrames = 1;
mesh->numMatFrames = 1;
mesh->vertsPerFrame = numVerts;
mesh->mNumFrames = 1;
mesh->mNumMatFrames = 1;
mesh->mVertsPerFrame = numVerts;
mesh->setFlags(0);
mesh->mHasColor = false;
mesh->mHasTVert2 = false;
mesh->mNumVerts = numVerts;
mesh->indices.reserve( numTris * 3 );
mesh->mIndices.reserve( numTris * 3 );
for ( S32 i = 0; i < numTris; i++ )
{
mesh->indices.push_back( indices[i*3 + 0] );
mesh->indices.push_back( indices[i*3 + 2] );
mesh->indices.push_back( indices[i*3 + 1] );
mesh->mIndices.push_back( indices[i*3 + 0] );
mesh->mIndices.push_back( indices[i*3 + 2] );
mesh->mIndices.push_back( indices[i*3 + 1] );
}
mesh->verts.set( verts, numVerts );
mesh->mVerts.set( verts, numVerts );
// Compute mesh normals
mesh->norms.setSize( mesh->verts.size() );
for (S32 iNorm = 0; iNorm < mesh->norms.size(); iNorm++)
mesh->norms[iNorm] = Point3F::Zero;
mesh->mNorms.setSize( mesh->mVerts.size() );
for (S32 iNorm = 0; iNorm < mesh->mNorms.size(); iNorm++)
mesh->mNorms[iNorm] = Point3F::Zero;
// Sum triangle normals for each vertex
for (S32 iInd = 0; iInd < mesh->indices.size(); iInd += 3)
for (S32 iInd = 0; iInd < mesh->mIndices.size(); iInd += 3)
{
// Compute the normal for this triangle
S32 idx0 = mesh->indices[iInd + 0];
S32 idx1 = mesh->indices[iInd + 1];
S32 idx2 = mesh->indices[iInd + 2];
S32 idx0 = mesh->mIndices[iInd + 0];
S32 idx1 = mesh->mIndices[iInd + 1];
S32 idx2 = mesh->mIndices[iInd + 2];
const Point3F& v0 = mesh->verts[idx0];
const Point3F& v1 = mesh->verts[idx1];
const Point3F& v2 = mesh->verts[idx2];
const Point3F& v0 = mesh->mVerts[idx0];
const Point3F& v1 = mesh->mVerts[idx1];
const Point3F& v2 = mesh->mVerts[idx2];
Point3F n;
mCross(v2 - v0, v1 - v0, &n);
n.normalize(); // remove this to use 'weighted' normals (large triangles will have more effect)
mesh->norms[idx0] += n;
mesh->norms[idx1] += n;
mesh->norms[idx2] += n;
mesh->mNorms[idx0] += n;
mesh->mNorms[idx1] += n;
mesh->mNorms[idx2] += n;
}
// Normalize the vertex normals (this takes care of averaging the triangle normals)
for (S32 iNorm = 0; iNorm < mesh->norms.size(); iNorm++)
mesh->norms[iNorm].normalize();
for (S32 iNorm = 0; iNorm < mesh->mNorms.size(); iNorm++)
mesh->mNorms[iNorm].normalize();
// Set some dummy UVs
mesh->tverts.setSize( numVerts );
for ( S32 j = 0; j < mesh->tverts.size(); j++ )
mesh->tverts[j].set( 0, 0 );
mesh->mTVerts.setSize( numVerts );
for ( S32 j = 0; j < mesh->mTVerts.size(); j++ )
mesh->mTVerts[j].set( 0, 0 );
// Add a single triangle-list primitive
mesh->primitives.increment();
mesh->primitives.last().start = 0;
mesh->primitives.last().numElements = mesh->indices.size();
mesh->primitives.last().matIndex = TSDrawPrimitive::Triangles |
mesh->mPrimitives.increment();
mesh->mPrimitives.last().start = 0;
mesh->mPrimitives.last().numElements = mesh->mIndices.size();
mesh->mPrimitives.last().matIndex = TSDrawPrimitive::Triangles |
TSDrawPrimitive::Indexed |
TSDrawPrimitive::NoMaterial;
mesh->createTangents( mesh->verts, mesh->norms );
mesh->encodedNorms.set( NULL,0 );
mesh->createTangents( mesh->mVerts, mesh->mNorms );
mesh->mEncodedNorms.set( NULL,0 );
return mesh;
}
@ -792,10 +792,10 @@ DefineTSShapeConstructorMethod( addPrimitive, bool, ( const char* meshName, cons
}
else
{
for (S32 i = 0; i < mesh->verts.size(); i++)
for (S32 i = 0; i < mesh->mVerts.size(); i++)
{
Point3F v(mesh->verts[i]);
mat.mulP( v, &mesh->verts[i] );
Point3F v(mesh->mVerts[i]);
mat.mulP( v, &mesh->mVerts[i] );
}
}

View file

@ -97,9 +97,9 @@ void TSPartInstance::updateBounds()
void TSPartInstance::breakShape(TSShapeInstance * shape, S32 subShape, Vector<TSPartInstance*> & partList, F32 * probShatter, F32 * probBreak, S32 probDepth)
{
AssertFatal(subShape>=0 && subShape<shape->mShape->subShapeFirstNode.size(),"TSPartInstance::breakShape: subShape out of range.");
AssertFatal(subShape>=0 && subShape<shape->mShape->mSubShapeFirstNode.size(),"TSPartInstance::breakShape: subShape out of range.");
S32 start = shape->mShape->subShapeFirstNode[subShape];
S32 start = shape->mShape->mSubShapeFirstNode[subShape];
TSPartInstance::breakShape(shape, NULL, start, partList, probShatter, probBreak, probDepth);
@ -120,7 +120,7 @@ void TSPartInstance::breakShape(TSShapeInstance * shape, TSPartInstance * curren
{
AssertFatal( !probDepth || (probShatter && probBreak),"TSPartInstance::breakShape: probabilities improperly specified.");
const TSShape::Node * node = &shape->mShape->nodes[currentNode];
const TSShape::Node * node = &shape->mShape->mNodes[currentNode];
S32 object = node->firstObject;
S32 child = node->firstChild;
@ -155,14 +155,14 @@ void TSPartInstance::breakShape(TSShapeInstance * shape, TSPartInstance * curren
{
partList.increment();
partList.last() = new TSPartInstance(shape,object);
object = shape->mShape->objects[object].nextSibling;
object = shape->mShape->mObjects[object].nextSibling;
}
// iterate through the child nodes, call ourselves on each one with currentPart = NULL
while (child>=0)
{
TSPartInstance::breakShape(shape,NULL,child,partList,probShatter,probBreak,probDepth);
child = shape->mShape->nodes[child].nextSibling;
child = shape->mShape->mNodes[child].nextSibling;
}
return;
@ -184,14 +184,14 @@ void TSPartInstance::breakShape(TSShapeInstance * shape, TSPartInstance * curren
while (object>=0)
{
currentPart->addObject(object);
object = shape->mShape->objects[object].nextSibling;
object = shape->mShape->mObjects[object].nextSibling;
}
// iterate through child nodes, call ourselves on each one with currentPart as is
while (child>=0)
{
TSPartInstance::breakShape(shape,currentPart,child,partList,probShatter,probBreak,probDepth);
child = shape->mShape->nodes[child].nextSibling;
child = shape->mShape->mNodes[child].nextSibling;
}
}
@ -334,7 +334,7 @@ F32 TSPartInstance::getDetailSize(S32 dl) const
else if (mSizeCutoffs && dl<mNumDetails)
return mSizeCutoffs[dl];
else if (!mSizeCutoffs && dl<=mSourceShape->getShape()->mSmallestVisibleDL)
return mSourceShape->getShape()->details[dl].size;
return mSourceShape->getShape()->mDetails[dl].size;
else return 0;
}

File diff suppressed because it is too large Load diff

View file

@ -274,25 +274,25 @@ class TSShape
/// @name Shape Vector Data
/// @{
Vector<Node> nodes;
Vector<Object> objects;
Vector<ObjectState> objectStates;
Vector<S32> subShapeFirstNode;
Vector<S32> subShapeFirstObject;
Vector<S32> detailFirstSkin;
Vector<S32> subShapeNumNodes;
Vector<S32> subShapeNumObjects;
Vector<Detail> details;
Vector<Quat16> defaultRotations;
Vector<Point3F> defaultTranslations;
Vector<Node> mNodes;
Vector<Object> mObjects;
Vector<ObjectState> mObjectStates;
Vector<S32> mSubShapeFirstNode;
Vector<S32> mSubShapeFirstObject;
Vector<S32> mDetailFirstSkin;
Vector<S32> mSubShapeNumNodes;
Vector<S32> mSubShapeNumObjects;
Vector<Detail> mDetails;
Vector<Quat16> mDefaultRotations;
Vector<Point3F> mDefaultTranslations;
/// @}
/// These are set up at load time, but memory is allocated along with loaded data
/// @{
Vector<S32> subShapeFirstTranslucentObject;
Vector<TSMesh*> meshes;
Vector<S32> mSubShapeFirstTranslucentObject;
Vector<TSMesh*> mMeshes;
/// @}
@ -306,39 +306,39 @@ class TSShape
/// - intraDL is at 0 when if shape were any farther away we'd be at dl+1
/// @{
Vector<F32> alphaIn;
Vector<F32> alphaOut
Vector<F32> mAlphaIn;
Vector<F32> mAlphaOut
;
/// @}
/// @name Resizeable vectors
/// @{
Vector<Sequence> sequences;
Vector<Quat16> nodeRotations;
Vector<Point3F> nodeTranslations;
Vector<F32> nodeUniformScales;
Vector<Point3F> nodeAlignedScales;
Vector<Quat16> nodeArbitraryScaleRots;
Vector<Point3F> nodeArbitraryScaleFactors;
Vector<Quat16> groundRotations;
Vector<Point3F> groundTranslations;
Vector<Trigger> triggers;
Vector<TSLastDetail*> billboardDetails;
Vector<ConvexHullAccelerator*> detailCollisionAccelerators;
Vector<String> names;
Vector<Sequence> mSequences;
Vector<Quat16> mNodeRotations;
Vector<Point3F> mNodeTranslations;
Vector<F32> mNodeUniformScales;
Vector<Point3F> mNodeAlignedScales;
Vector<Quat16> mNodeArbitraryScaleRots;
Vector<Point3F> mNodeArbitraryScaleFactors;
Vector<Quat16> mGroundRotations;
Vector<Point3F> mGroundTranslations;
Vector<Trigger> mTriggers;
Vector<TSLastDetail*> mBillboardDetails;
Vector<ConvexHullAccelerator*> mDetailCollisionAccelerators;
Vector<String> mNames;
/// @}
TSMaterialList * materialList;
TSMaterialList * mMaterialList;
/// @name Bounding
/// @{
F32 radius;
F32 tubeRadius;
Point3F center;
Box3F bounds;
F32 mRadius;
F32 mTubeRadius;
Point3F mCenter;
Box3F mBounds;
/// @}
@ -348,7 +348,7 @@ class TSShape
S32 mSmallestVisibleDL; ///< @see mSmallestVisibleSize
S32 mReadVersion; ///< File version that this shape was read from.
U32 mFlags; ///< hasTranslucancy
U32 data; ///< User-defined data storage.
U32 mData; ///< User-defined data storage.
/// If enabled detail selection will use the
/// legacy screen error method for lod.
@ -659,34 +659,34 @@ class TSShape
inline QuatF & TSShape::getRotation(const Sequence & seq, S32 keyframeNum, S32 rotNum, QuatF * quat) const
{
return nodeRotations[seq.baseRotation + rotNum*seq.numKeyframes + keyframeNum].getQuatF(quat);
return mNodeRotations[seq.baseRotation + rotNum*seq.numKeyframes + keyframeNum].getQuatF(quat);
}
inline const Point3F & TSShape::getTranslation(const Sequence & seq, S32 keyframeNum, S32 tranNum) const
{
return nodeTranslations[seq.baseTranslation + tranNum*seq.numKeyframes + keyframeNum];
return mNodeTranslations[seq.baseTranslation + tranNum*seq.numKeyframes + keyframeNum];
}
inline F32 TSShape::getUniformScale(const Sequence & seq, S32 keyframeNum, S32 scaleNum) const
{
return nodeUniformScales[seq.baseScale + scaleNum*seq.numKeyframes + keyframeNum];
return mNodeUniformScales[seq.baseScale + scaleNum*seq.numKeyframes + keyframeNum];
}
inline const Point3F & TSShape::getAlignedScale(const Sequence & seq, S32 keyframeNum, S32 scaleNum) const
{
return nodeAlignedScales[seq.baseScale + scaleNum*seq.numKeyframes + keyframeNum];
return mNodeAlignedScales[seq.baseScale + scaleNum*seq.numKeyframes + keyframeNum];
}
inline TSScale & TSShape::getArbitraryScale(const Sequence & seq, S32 keyframeNum, S32 scaleNum, TSScale * scale) const
{
nodeArbitraryScaleRots[seq.baseScale + scaleNum*seq.numKeyframes + keyframeNum].getQuatF(&scale->mRotate);
scale->mScale = nodeArbitraryScaleFactors[seq.baseScale + scaleNum*seq.numKeyframes + keyframeNum];
mNodeArbitraryScaleRots[seq.baseScale + scaleNum*seq.numKeyframes + keyframeNum].getQuatF(&scale->mRotate);
scale->mScale = mNodeArbitraryScaleFactors[seq.baseScale + scaleNum*seq.numKeyframes + keyframeNum];
return *scale;
}
inline const TSShape::ObjectState & TSShape::getObjectState(const Sequence & seq, S32 keyframeNum, S32 objectNum) const
{
return objectStates[seq.baseObjectState + objectNum*seq.numKeyframes + keyframeNum];
return mObjectStates[seq.baseObjectState + objectNum*seq.numKeyframes + keyframeNum];
}
#endif

View file

@ -159,7 +159,7 @@ void TSShapeConstructor::initPersistFields()
endGroup( "Media" );
addGroup( "Collada" );
addField( "upAxis", TYPEID< domUpAxisType >(), Offset(mOptions.upAxis, TSShapeConstructor),
addField( "upAxis", TYPEID< domUpAxisType >(), Offset(mOptions.mUpAxis, TSShapeConstructor),
"Override the <up_axis> element in the COLLADA (.dae) file. No effect for DTS files.\n"
"Set to one of the following values:\n"
"<dl><dt>X_AXIS</dt><dd>Positive X points up. Model will be rotated into Torque's coordinate system (Z up).</dd>"
@ -167,7 +167,7 @@ void TSShapeConstructor::initPersistFields()
"<dt>Z_AXIS</dt><dd>Positive Z points up. No rotation will be applied to the model.</dd>"
"<dt>DEFAULT</dt><dd>The default value. Use the value in the .dae file (defaults to Z_AXIS if the <up_axis> element is not present).</dd></dl>" );
addField( "unit", TypeF32, Offset(mOptions.unit, TSShapeConstructor),
addField( "unit", TypeF32, Offset(mOptions.mUnit, TSShapeConstructor),
"Override the <unit> element in the COLLADA (.dae) file. No effect for DTS files.\n"
"COLLADA (.dae) files usually contain a <unit> element that indicates the "
"'real world' units that the model is described in. It means you can work "
@ -182,7 +182,7 @@ void TSShapeConstructor::initPersistFields()
"Omit the field or set to -1 to use the value in the .dae file (1.0 if the "
"<unit> element is not present)" );
addField( "lodType", TYPEID< ColladaUtils::ImportOptions::eLodType >(), Offset(mOptions.lodType, TSShapeConstructor),
addField( "lodType", TYPEID< ColladaUtils::ImportOptions::eLodType >(), Offset(mOptions.mLodType, TSShapeConstructor),
"Control how the COLLADA (.dae) importer interprets LOD in the model. No effect for DTS files.\n"
"Set to one of the following values:\n"
"<dl><dt>DetectDTS</dt><dd>The default value. Instructs the importer to search for a 'baseXXX->startXXX' node hierarchy at the root level. If found, the importer acts as if ''TrailingNumber'' was set. Otherwise, all geometry is imported at a single detail size.</dd>"
@ -190,16 +190,16 @@ void TSShapeConstructor::initPersistFields()
"<dt>TrailingNumber</dt><dd>Numbers at the end of geometry node's name are interpreted as the detail size (similar to DTS exporting). Geometry instances with the same base name but different trailing number are grouped into the same object.</dd>"
"<dt>DEFAULT</dt><dd>The default value. Use the value in the .dae file (defaults to Z_AXIS if the <up_axis> element is not present).</dd></dl>" );
addField( "singleDetailSize", TypeS32, Offset(mOptions.singleDetailSize, TSShapeConstructor),
addField( "singleDetailSize", TypeS32, Offset(mOptions.mSingleDetailSize, TSShapeConstructor),
"Sets the detail size when lodType is set to SingleSize. No effect otherwise, and no effect for DTS files.\n"
"@see lodType" );
addField( "matNamePrefix", TypeRealString, Offset(mOptions.matNamePrefix, TSShapeConstructor),
addField( "matNamePrefix", TypeRealString, Offset(mOptions.mMatNamePrefix, TSShapeConstructor),
"Prefix to apply to all material map names in the COLLADA (.dae) file. No effect for DTS files.\n"
"This field is useful to avoid material name clashes for exporters that generate generic material "
"names like \"texture0\" or \"material1\"." );
addField( "alwaysImport", TypeRealString, Offset(mOptions.alwaysImport, TSShapeConstructor),
addField( "alwaysImport", TypeRealString, Offset(mOptions.mAlwaysImport, TSShapeConstructor),
"TAB separated patterns of nodes to import even if in neverImport list. No effect for DTS files.\n"
"Torque allows unwanted nodes in COLLADA (.dae) files to to be ignored "
"during import. This field contains a TAB separated list of patterns to "
@ -215,7 +215,7 @@ void TSShapeConstructor::initPersistFields()
"}\n"
"@endtsexample" );
addField( "neverImport", TypeRealString, Offset(mOptions.neverImport, TSShapeConstructor),
addField( "neverImport", TypeRealString, Offset(mOptions.mNeverImport, TSShapeConstructor),
"TAB separated patterns of nodes to ignore on loading. No effect for DTS files.\n"
"Torque allows unwanted nodes in COLLADA (.dae) files to to be ignored "
"during import. This field contains a TAB separated list of patterns to "
@ -223,7 +223,7 @@ void TSShapeConstructor::initPersistFields()
"not be imported (unless it matches the alwaysImport list.\n"
"@see alwaysImport" );
addField( "alwaysImportMesh", TypeRealString, Offset(mOptions.alwaysImportMesh, TSShapeConstructor),
addField( "alwaysImportMesh", TypeRealString, Offset(mOptions.mAlwaysImportMesh, TSShapeConstructor),
"TAB separated patterns of meshes to import even if in neverImportMesh list. No effect for DTS files.\n"
"Torque allows unwanted meshes in COLLADA (.dae) files to to be ignored "
"during import. This field contains a TAB separated list of patterns to "
@ -239,7 +239,7 @@ void TSShapeConstructor::initPersistFields()
"}\n"
"@endtsexample" );
addField( "neverImportMesh", TypeRealString, Offset(mOptions.neverImportMesh, TSShapeConstructor),
addField( "neverImportMesh", TypeRealString, Offset(mOptions.mNeverImportMesh, TSShapeConstructor),
"TAB separated patterns of meshes to ignore on loading. No effect for DTS files.\n"
"Torque allows unwanted meshes in COLLADA (.dae) files to to be ignored "
"during import. This field contains a TAB separated list of patterns to "
@ -247,21 +247,21 @@ void TSShapeConstructor::initPersistFields()
"not be imported (unless it matches the alwaysImportMesh list.\n"
"@see alwaysImportMesh" );
addField( "ignoreNodeScale", TypeBool, Offset(mOptions.ignoreNodeScale, TSShapeConstructor),
addField( "ignoreNodeScale", TypeBool, Offset(mOptions.mIgnoreNodeScale, TSShapeConstructor),
"Ignore <scale> elements inside COLLADA <node>s. No effect for DTS files.\n"
"This field is a workaround for certain exporters that generate bad node "
"scaling, and is not usually required." );
addField( "adjustCenter", TypeBool, Offset(mOptions.adjustCenter, TSShapeConstructor),
addField( "adjustCenter", TypeBool, Offset(mOptions.mAdjustCenter, TSShapeConstructor),
"Translate COLLADA model on import so the origin is at the center. No effect for DTS files." );
addField( "adjustFloor", TypeBool, Offset(mOptions.adjustFloor, TSShapeConstructor),
addField( "adjustFloor", TypeBool, Offset(mOptions.mAdjustFloor, TSShapeConstructor),
"Translate COLLADA model on import so origin is at the (Z axis) bottom of the model. No effect for DTS files.\n"
"This can be used along with adjustCenter to have the origin at the "
"center of the bottom of the model.\n"
"@see adjustCenter" );
addField( "forceUpdateMaterials", TypeBool, Offset(mOptions.forceUpdateMaterials, TSShapeConstructor),
addField( "forceUpdateMaterials", TypeBool, Offset(mOptions.mForceUpdateMaterials, TSShapeConstructor),
"Forces update of the materials.cs file in the same folder as the COLLADA "
"(.dae) file, even if Materials already exist. No effect for DTS files.\n"
"Normally only Materials that are not already defined are written to materials.cs." );
@ -482,7 +482,7 @@ bool TSShapeConstructor::writeField(StringTableEntry fieldname, const char *valu
return ret; \
} \
} \
TSShape::Node* var = var##Index < 0 ? NULL : &(mShape->nodes[var##Index]); \
TSShape::Node* var = var##Index < 0 ? NULL : &(mShape->mNodes[var##Index]); \
TORQUE_UNUSED(var##Index); \
TORQUE_UNUSED(var)
@ -495,7 +495,7 @@ bool TSShapeConstructor::writeField(StringTableEntry fieldname, const char *valu
"node '%s'", name); \
return ret; \
} \
TSShape::Node* var = &(mShape->nodes[var##Index]); \
TSShape::Node* var = &(mShape->mNodes[var##Index]); \
TORQUE_UNUSED(var##Index); \
TORQUE_UNUSED(var)
@ -508,7 +508,7 @@ bool TSShapeConstructor::writeField(StringTableEntry fieldname, const char *valu
"object '%s'", name); \
return ret; \
} \
TSShape::Object* var = &(mShape->objects[var##Index]); \
TSShape::Object* var = &(mShape->mObjects[var##Index]); \
TORQUE_UNUSED(var##Index); \
TORQUE_UNUSED(var)
@ -531,7 +531,7 @@ bool TSShapeConstructor::writeField(StringTableEntry fieldname, const char *valu
"sequence named '%s'", name); \
return ret; \
} \
TSShape::Sequence* var = &(mShape->sequences[var##Index]); \
TSShape::Sequence* var = &(mShape->mSequences[var##Index]); \
TORQUE_UNUSED(var##Index); \
TORQUE_UNUSED(var);
@ -695,7 +695,7 @@ DefineTSShapeConstructorMethod( getNodeCount, S32, (),,
"%count = %this.getNodeCount();\n"
"@endtsexample\n" )
{
return mShape->nodes.size();
return mShape->mNodes.size();
}}
DefineTSShapeConstructorMethod( getNodeIndex, S32, ( const char* name ),,
@ -723,8 +723,8 @@ DefineTSShapeConstructorMethod( getNodeName, const char*, ( S32 index ),,
" echo(%i SPC %this.getNodeName(%i));\n"
"@endtsexample\n" )
{
CHECK_INDEX_IN_RANGE( getNodeName, index, mShape->nodes.size(), "" );
return mShape->getName( mShape->nodes[index].nameIndex );
CHECK_INDEX_IN_RANGE( getNodeName, index, mShape->mNodes.size(), "" );
return mShape->getName( mShape->mNodes[index].nameIndex );
}}
DefineTSShapeConstructorMethod( getNodeParentName, const char*, ( const char* name ),,
@ -742,7 +742,7 @@ DefineTSShapeConstructorMethod( getNodeParentName, const char*, ( const char* na
if ( node->parentIndex < 0 )
return "";
else
return mShape->getName( mShape->nodes[node->parentIndex].nameIndex );
return mShape->getName( mShape->mNodes[node->parentIndex].nameIndex );
}}
DefineTSShapeConstructorMethod( setNodeParent, bool, ( const char* name, const char* parentName ),,
@ -814,7 +814,7 @@ DefineTSShapeConstructorMethod( getNodeChildName, const char*, ( const char* nam
mShape->getNodeChildren( nodeIndex, nodeChildren );
CHECK_INDEX_IN_RANGE( getNodeChildName, index, nodeChildren.size(), "" );
return mShape->getName( mShape->nodes[nodeChildren[index]].nameIndex );
return mShape->getName( mShape->mNodes[nodeChildren[index]].nameIndex );
}}
DefineTSShapeConstructorMethod( getNodeObjectCount, S32, ( const char* name ),,
@ -852,7 +852,7 @@ DefineTSShapeConstructorMethod( getNodeObjectName, const char*, ( const char* na
mShape->getNodeObjects( nodeIndex, nodeObjects );
CHECK_INDEX_IN_RANGE( getNodeObjectName, index, nodeObjects.size(), "" );
return mShape->getName( mShape->objects[nodeObjects[index]].nameIndex );
return mShape->getName( mShape->mObjects[nodeObjects[index]].nameIndex );
}}
DefineTSShapeConstructorMethod( getNodeTransform, TransformF, ( const char* name, bool isWorld ), ( false ),
@ -884,8 +884,8 @@ DefineTSShapeConstructorMethod( getNodeTransform, TransformF, ( const char* name
else
{
// Local transform
pos = mShape->defaultTranslations[nodeIndex];
const Quat16& q16 = mShape->defaultRotations[nodeIndex];
pos = mShape->mDefaultTranslations[nodeIndex];
const Quat16& q16 = mShape->mDefaultRotations[nodeIndex];
aa.set( q16.getQuatF() );
}
@ -1067,7 +1067,7 @@ DefineTSShapeConstructorMethod( getObjectCount, S32, (),, (), 0,
"%count = %this.getObjectCount();\n"
"@endtsexample\n" )
{
return mShape->objects.size();
return mShape->mObjects.size();
}}
DefineTSShapeConstructorMethod( getObjectName, const char*, ( S32 index ),,
@ -1082,9 +1082,9 @@ DefineTSShapeConstructorMethod( getObjectName, const char*, ( S32 index ),,
" echo( %i SPC %this.getObjectName( %i ) );\n"
"@endtsexample\n" )
{
CHECK_INDEX_IN_RANGE( getObjectName, index, mShape->objects.size(), "" );
CHECK_INDEX_IN_RANGE( getObjectName, index, mShape->mObjects.size(), "" );
return mShape->getName( mShape->objects[index].nameIndex );
return mShape->getName( mShape->mObjects[index].nameIndex );
}}
DefineTSShapeConstructorMethod( getObjectIndex, S32, ( const char* name ),,
@ -1113,7 +1113,7 @@ DefineTSShapeConstructorMethod( getObjectNode, const char*, ( const char* name )
if ( obj->nodeIndex < 0 )
return "";
else
return mShape->getName( mShape->nodes[obj->nodeIndex].nameIndex );
return mShape->getName( mShape->mNodes[obj->nodeIndex].nameIndex );
}}
DefineTSShapeConstructorMethod( setObjectNode, bool, ( const char* objName, const char* nodeName ),,
@ -1218,7 +1218,7 @@ DefineTSShapeConstructorMethod( getMeshName, const char*, ( const char* name, S3
static const U32 bufSize = 256;
char* returnBuffer = Con::getReturnBuffer(bufSize);
dSprintf(returnBuffer, bufSize, "%s %d", name, (S32)mShape->details[objectDetails[index]].size);
dSprintf(returnBuffer, bufSize, "%s %d", name, (S32)mShape->mDetails[objectDetails[index]].size);
return returnBuffer;
}}
@ -1243,7 +1243,7 @@ DefineTSShapeConstructorMethod( getMeshSize, S32, ( const char* name, S32 index
CHECK_INDEX_IN_RANGE( getMeshName, index, objectDetails.size(), -1 );
return (S32)mShape->details[objectDetails[index]].size;
return (S32)mShape->mDetails[objectDetails[index]].size;
}}
DefineTSShapeConstructorMethod( setMeshSize, bool, ( const char* name, S32 size ),,
@ -1327,9 +1327,9 @@ DefineTSShapeConstructorMethod( getMeshMaterial, const char*, ( const char* name
GET_MESH( getMeshMaterial, mesh, name, "" );
// Return the name of the first material attached to this mesh
S32 matIndex = mesh->primitives[0].matIndex & TSDrawPrimitive::MaterialMask;
if ((matIndex >= 0) && (matIndex < mShape->materialList->size()))
return mShape->materialList->getMaterialName( matIndex );
S32 matIndex = mesh->mPrimitives[0].matIndex & TSDrawPrimitive::MaterialMask;
if ((matIndex >= 0) && (matIndex < mShape->mMaterialList->size()))
return mShape->mMaterialList->getMaterialName( matIndex );
else
return "";
}}
@ -1351,23 +1351,23 @@ DefineTSShapeConstructorMethod( setMeshMaterial, bool, ( const char* meshName, c
// Check if this material is already in the shape
S32 matIndex;
for ( matIndex = 0; matIndex < mShape->materialList->size(); matIndex++ )
for ( matIndex = 0; matIndex < mShape->mMaterialList->size(); matIndex++ )
{
if ( dStrEqual( matName, mShape->materialList->getMaterialName( matIndex ) ) )
if ( dStrEqual( matName, mShape->mMaterialList->getMaterialName( matIndex ) ) )
break;
}
if ( matIndex == mShape->materialList->size() )
if ( matIndex == mShape->mMaterialList->size() )
{
// Add a new material to the shape
U32 flags = TSMaterialList::S_Wrap | TSMaterialList::T_Wrap;
mShape->materialList->push_back( matName, flags );
mShape->mMaterialList->push_back( matName, flags );
}
// Set this material for all primitives in the mesh
for ( S32 i = 0; i < mesh->primitives.size(); i++ )
for ( S32 i = 0; i < mesh->mPrimitives.size(); i++ )
{
U32 matType = mesh->primitives[i].matIndex & ( TSDrawPrimitive::TypeMask | TSDrawPrimitive::Indexed );
mesh->primitives[i].matIndex = ( matType | matIndex );
U32 matType = mesh->mPrimitives[i].matIndex & ( TSDrawPrimitive::TypeMask | TSDrawPrimitive::Indexed );
mesh->mPrimitives[i].matIndex = ( matType | matIndex );
}
ADD_TO_CHANGE_SET();
@ -1432,7 +1432,7 @@ DefineTSShapeConstructorMethod( getBounds, Box3F, (),,
"Get the bounding box for the shape.\n"
"@return Bounding box \"minX minY minZ maxX maxY maxZ\"" )
{
return mShape->bounds;
return mShape->mBounds;
}}
DefineTSShapeConstructorMethod( setBounds, bool, ( Box3F bbox ),,
@ -1444,10 +1444,10 @@ DefineTSShapeConstructorMethod( setBounds, bool, ( Box3F bbox ),,
// Set shape bounds
TSShape* shape = mShape;
shape->bounds = bbox;
shape->bounds.getCenter( &shape->center );
shape->radius = ( shape->bounds.maxExtents - shape->center ).len();
shape->tubeRadius = shape->radius;
shape->mBounds = bbox;
shape->mBounds.getCenter( &shape->mCenter );
shape->mRadius = ( shape->mBounds.maxExtents - shape->mCenter ).len();
shape->mTubeRadius = shape->mRadius;
ADD_TO_CHANGE_SET();
return true;
@ -1459,7 +1459,7 @@ DefineTSShapeConstructorMethod( getDetailLevelCount, S32, (),, (), 0,
"Get the total number of detail levels in the shape.\n"
"@return the number of detail levels in the shape\n" )
{
return mShape->details.size();
return mShape->mDetails.size();
}}
DefineTSShapeConstructorMethod( getDetailLevelName, const char*, ( S32 index ),,
@ -1474,9 +1474,9 @@ DefineTSShapeConstructorMethod( getDetailLevelName, const char*, ( S32 index ),,
" echo( %i SPC %this.getDetailLevelName( %i ) );\n"
"@endtsexample\n" )
{
CHECK_INDEX_IN_RANGE( getDetailLevelName, index, mShape->details.size(), "" );
CHECK_INDEX_IN_RANGE( getDetailLevelName, index, mShape->mDetails.size(), "" );
return mShape->getName(mShape->details[index].nameIndex);
return mShape->getName(mShape->mDetails[index].nameIndex);
}}
DefineTSShapeConstructorMethod( getDetailLevelSize, S32, ( S32 index),,
@ -1491,9 +1491,9 @@ DefineTSShapeConstructorMethod( getDetailLevelSize, S32, ( S32 index),,
" echo( \"Detail\" @ %i @ \" has size \" @ %this.getDetailLevelSize( %i ) );\n"
"@endtsexample\n" )
{
CHECK_INDEX_IN_RANGE( getDetailLevelSize, index, mShape->details.size(), 0 );
CHECK_INDEX_IN_RANGE( getDetailLevelSize, index, mShape->mDetails.size(), 0 );
return (S32)mShape->details[index].size;
return (S32)mShape->mDetails[index].size;
}}
DefineTSShapeConstructorMethod( getDetailLevelIndex, S32, ( S32 size ),,
@ -1568,9 +1568,9 @@ DefineTSShapeConstructorMethod( getImposterDetailLevel, S32, (),, (), -1,
"@return imposter detail level index, or -1 if the shape does not use "
"imposters.\n\n" )
{
for ( S32 i = 0; i < mShape->details.size(); i++ )
for ( S32 i = 0; i < mShape->mDetails.size(); i++ )
{
if ( mShape->details[i].subShapeNum < 0 )
if ( mShape->mDetails[i].subShapeNum < 0 )
return i;
}
return -1;
@ -1598,10 +1598,10 @@ DefineTSShapeConstructorMethod( getImposterSettings, const char*, ( S32 index ),
" echo( \"Imposter settings: \" @ %this.getImposterSettings( %index ) );\n"
"@endtsexample\n" )
{
CHECK_INDEX_IN_RANGE( getImposterSettings, index, mShape->details.size(), "" );
CHECK_INDEX_IN_RANGE( getImposterSettings, index, mShape->mDetails.size(), "" );
// Return information about the detail level
const TSShape::Detail& det = mShape->details[index];
const TSShape::Detail& det = mShape->mDetails[index];
static const U32 bufSize = 512;
char* returnBuffer = Con::getReturnBuffer(bufSize);
@ -1672,7 +1672,7 @@ DefineTSShapeConstructorMethod( getSequenceCount, S32, (),, (), 0,
"Get the total number of sequences in the shape.\n"
"@return the number of sequences in the shape\n\n" )
{
return mShape->sequences.size();
return mShape->mSequences.size();
}}
DefineTSShapeConstructorMethod( getSequenceIndex, S32, ( const char* name),,
@ -1701,9 +1701,9 @@ DefineTSShapeConstructorMethod( getSequenceName, const char*, ( S32 index ),,
" echo( %i SPC %this.getSequenceName( %i ) );\n"
"@endtsexample\n" )
{
CHECK_INDEX_IN_RANGE( getSequenceName, index, mShape->sequences.size(), "" );
CHECK_INDEX_IN_RANGE( getSequenceName, index, mShape->mSequences.size(), "" );
return mShape->getName( mShape->sequences[index].nameIndex );
return mShape->getName( mShape->mSequences[index].nameIndex );
}}
DefineTSShapeConstructorMethod( getSequenceSource, const char*, ( const char* name ),,
@ -1792,12 +1792,12 @@ DefineTSShapeConstructorMethod( getSequenceGroundSpeed, const char*, ( const cha
Point3F trans(0,0,0), rot(0,0,0);
if ( seq->numGroundFrames > 0 )
{
const Point3F& p1 = mShape->groundTranslations[seq->firstGroundFrame];
const Point3F& p2 = mShape->groundTranslations[seq->firstGroundFrame + 1];
const Point3F& p1 = mShape->mGroundTranslations[seq->firstGroundFrame];
const Point3F& p2 = mShape->mGroundTranslations[seq->firstGroundFrame + 1];
trans = p2 - p1;
QuatF r1 = mShape->groundRotations[seq->firstGroundFrame].getQuatF();
QuatF r2 = mShape->groundRotations[seq->firstGroundFrame + 1].getQuatF();
QuatF r1 = mShape->mGroundRotations[seq->firstGroundFrame].getQuatF();
QuatF r2 = mShape->mGroundRotations[seq->firstGroundFrame + 1].getQuatF();
r2 -= r1;
MatrixF mat;
@ -2037,7 +2037,7 @@ DefineTSShapeConstructorMethod( getTrigger, const char*, ( const char* name, S32
CHECK_INDEX_IN_RANGE( getTrigger, index, seq->numTriggers, "" );
const TSShape::Trigger& trig = mShape->triggers[seq->firstTrigger + index];
const TSShape::Trigger& trig = mShape->mTriggers[seq->firstTrigger + index];
S32 frame = trig.pos * seq->numKeyframes;
S32 state = getBinLog2(trig.state & TSShape::Trigger::StateMask) + 1;
if (!(trig.state & TSShape::Trigger::StateOn))
@ -2144,9 +2144,9 @@ void TSShapeConstructor::ChangeSet::write(TSShape* shape, Stream& stream, const
// Remove all __backup__ sequences (used during Shape Editing)
if (shape)
{
for (S32 i = 0; i < shape->sequences.size(); i++)
for (S32 i = 0; i < shape->mSequences.size(); i++)
{
const char* seqName = shape->getName( shape->sequences[i].nameIndex );
const char* seqName = shape->getName( shape->mSequences[i].nameIndex );
if ( dStrStartsWith( seqName, "__backup__" ) )
{
Command cmd( "removeSequence" );

File diff suppressed because it is too large Load diff

View file

@ -175,7 +175,7 @@ void TSShapeInstance::buildInstanceData(TSShape * _shape, bool loadMaterials)
mScaleCurrentlyAnimated = false;
if(loadMaterials)
setMaterialList(mShape->materialList);
setMaterialList(mShape->mMaterialList);
// set up node data
initNodeTransforms();
@ -184,7 +184,7 @@ void TSShapeInstance::buildInstanceData(TSShape * _shape, bool loadMaterials)
initMeshObjects();
// set up subtree data
S32 ss = mShape->subShapeFirstNode.size(); // we have this many subtrees
S32 ss = mShape->mSubShapeFirstNode.size(); // we have this many subtrees
mDirtyFlags = new U32[ss];
mGroundThread = NULL;
@ -200,18 +200,18 @@ void TSShapeInstance::buildInstanceData(TSShape * _shape, bool loadMaterials)
void TSShapeInstance::initNodeTransforms()
{
// set up node data
S32 numNodes = mShape->nodes.size();
S32 numNodes = mShape->mNodes.size();
mNodeTransforms.setSize(numNodes);
}
void TSShapeInstance::initMeshObjects()
{
// add objects to trees
S32 numObjects = mShape->objects.size();
S32 numObjects = mShape->mObjects.size();
mMeshObjects.setSize(numObjects);
for (S32 i=0; i<numObjects; i++)
{
const TSObject * obj = &mShape->objects[i];
const TSObject * obj = &mShape->mObjects[i];
MeshObjectInstance * objInst = &mMeshObjects[i];
// hook up the object to it's node and transforms.
@ -220,7 +220,7 @@ void TSShapeInstance::initMeshObjects()
// set up list of meshes
if (obj->numMeshes)
objInst->meshList = &mShape->meshes[obj->startMeshIndex];
objInst->meshList = &mShape->mMeshes[obj->startMeshIndex];
else
objInst->meshList = NULL;
@ -327,7 +327,7 @@ void TSShapeInstance::renderDebugNormals( F32 normalScalar, S32 dl )
if ( dl < 0 )
return;
AssertFatal( dl >= 0 && dl < mShape->details.size(),
AssertFatal( dl >= 0 && dl < mShape->mDetails.size(),
"TSShapeInstance::renderDebugNormals() - Bad detail level!" );
static GFXStateBlockRef sb;
@ -343,13 +343,13 @@ void TSShapeInstance::renderDebugNormals( F32 normalScalar, S32 dl )
}
GFX->setStateBlock( sb );
const TSDetail *detail = &mShape->details[dl];
const TSDetail *detail = &mShape->mDetails[dl];
const S32 ss = detail->subShapeNum;
if ( ss < 0 )
return;
const S32 start = mShape->subShapeFirstObject[ss];
const S32 end = start + mShape->subShapeNumObjects[ss];
const S32 start = mShape->mSubShapeFirstObject[ss];
const S32 end = start + mShape->mSubShapeNumObjects[ss];
for ( S32 i = start; i < end; i++ )
{
@ -445,8 +445,8 @@ void TSShapeInstance::render( const TSRenderState &rdata )
// NOTE:
// intraDL is at 1 when if shape were any closer to us we'd be at dl-1,
// intraDL is at 0 when if shape were any farther away we'd be at dl+1
F32 alphaOut = mShape->alphaOut[mCurrentDetailLevel];
F32 alphaIn = mShape->alphaIn[mCurrentDetailLevel];
F32 alphaOut = mShape->mAlphaOut[mCurrentDetailLevel];
F32 alphaIn = mShape->mAlphaIn[mCurrentDetailLevel];
F32 saveAA = mAlphaAlways ? mAlphaAlwaysValue : 1.0f;
/// This first case is the single detail level render.
@ -458,7 +458,7 @@ void TSShapeInstance::render( const TSRenderState &rdata )
// alpha=1-(intraDl-alphaOut)/alphaIn
// first draw next detail level
if ( mCurrentDetailLevel + 1 < mShape->details.size() && mShape->details[ mCurrentDetailLevel + 1 ].size > 0.0f )
if ( mCurrentDetailLevel + 1 < mShape->mDetails.size() && mShape->mDetails[ mCurrentDetailLevel + 1 ].size > 0.0f )
{
setAlphaAlways( saveAA * ( alphaIn + alphaOut - mCurrentIntraDetailLevel ) / alphaIn );
render( rdata, mCurrentDetailLevel + 1, 0.0f );
@ -473,7 +473,7 @@ void TSShapeInstance::render( const TSRenderState &rdata )
// alpha = 1-intraDL/alphaOut
// first draw next detail level
if ( mCurrentDetailLevel + 1 < mShape->details.size() && mShape->details[ mCurrentDetailLevel + 1 ].size > 0.0f )
if ( mCurrentDetailLevel + 1 < mShape->mDetails.size() && mShape->mDetails[ mCurrentDetailLevel + 1 ].size > 0.0f )
render( rdata, mCurrentDetailLevel+1, 0.0f );
setAlphaAlways( saveAA * mCurrentIntraDetailLevel / alphaOut );
@ -488,7 +488,7 @@ void TSShapeInstance::setMeshForceHidden( const char *meshName, bool hidden )
for ( ; iter != mMeshObjects.end(); iter++ )
{
S32 nameIndex = iter->object->nameIndex;
const char *name = mShape->names[ nameIndex ];
const char *name = mShape->mNames[ nameIndex ];
if ( dStrcmp( meshName, name ) == 0 )
{
@ -508,11 +508,11 @@ void TSShapeInstance::setMeshForceHidden( S32 meshIndex, bool hidden )
void TSShapeInstance::render( const TSRenderState &rdata, S32 dl, F32 intraDL )
{
AssertFatal( dl >= 0 && dl < mShape->details.size(),"TSShapeInstance::render" );
AssertFatal( dl >= 0 && dl < mShape->mDetails.size(),"TSShapeInstance::render" );
S32 i;
const TSDetail * detail = &mShape->details[dl];
const TSDetail * detail = &mShape->mDetails[dl];
S32 ss = detail->subShapeNum;
S32 od = detail->objectDetailNum;
@ -522,14 +522,14 @@ void TSShapeInstance::render( const TSRenderState &rdata, S32 dl, F32 intraDL )
PROFILE_SCOPE( TSShapeInstance_RenderBillboards );
if ( !rdata.isNoRenderTranslucent() && ( TSLastDetail::smCanShadow || !rdata.getSceneState()->isShadowPass() ) )
mShape->billboardDetails[ dl ]->render( rdata, mAlphaAlways ? mAlphaAlwaysValue : 1.0f );
mShape->mBillboardDetails[ dl ]->render( rdata, mAlphaAlways ? mAlphaAlwaysValue : 1.0f );
return;
}
// run through the meshes
S32 start = rdata.isNoRenderNonTranslucent() ? mShape->subShapeFirstTranslucentObject[ss] : mShape->subShapeFirstObject[ss];
S32 end = rdata.isNoRenderTranslucent() ? mShape->subShapeFirstTranslucentObject[ss] : mShape->subShapeFirstObject[ss] + mShape->subShapeNumObjects[ss];
S32 start = rdata.isNoRenderNonTranslucent() ? mShape->mSubShapeFirstTranslucentObject[ss] : mShape->mSubShapeFirstObject[ss];
S32 end = rdata.isNoRenderTranslucent() ? mShape->mSubShapeFirstTranslucentObject[ss] : mShape->mSubShapeFirstObject[ss] + mShape->mSubShapeNumObjects[ss];
for (i=start; i<end; i++)
{
// following line is handy for debugging, to see what part of the shape that it is rendering
@ -612,7 +612,7 @@ S32 TSShapeInstance::setDetailFromDistance( const SceneRenderState *state, F32 s
// We're inlining SceneRenderState::projectRadius here to
// skip the unnessasary divide by zero protection.
F32 pixelRadius = ( mShape->radius / scaledDistance ) * state->getWorldToScreenScale().y * pixelScale;
F32 pixelRadius = ( mShape->mRadius / scaledDistance ) * state->getWorldToScreenScale().y * pixelScale;
F32 pixelSize = pixelRadius * smDetailAdjust;
if ( pixelSize < smSmallestVisiblePixelSize ) {
@ -670,7 +670,7 @@ S32 TSShapeInstance::setDetailFromScreenError( F32 errorTolerance )
if ( mShape->mSmallestVisibleDL < 0 )
prevErr = 0.0f;
else
prevErr = 10.0f * mShape->details[mShape->mSmallestVisibleDL].averageError * 20.0f;
prevErr = 10.0f * mShape->mDetails[mShape->mSmallestVisibleDL].averageError * 20.0f;
if ( mShape->mSmallestVisibleDL < 0 || prevErr < errorTolerance )
{
// draw last detail
@ -687,7 +687,7 @@ S32 TSShapeInstance::setDetailFromScreenError( F32 errorTolerance )
// we use the next highest detail (higher error)
for (S32 i = mShape->mSmallestVisibleDL; i >= 0; i-- )
{
F32 err0 = 10.0f * mShape->details[i].averageError;
F32 err0 = 10.0f * mShape->mDetails[i].averageError;
if ( err0 < errorTolerance )
{
// ok, stop here
@ -775,10 +775,10 @@ void TSShapeInstance::prepCollision()
PROFILE_SCOPE( TSShapeInstance_PrepCollision );
// Iterate over all our meshes and call prepCollision on them...
for(S32 i=0; i<mShape->meshes.size(); i++)
for(S32 i=0; i<mShape->mMeshes.size(); i++)
{
if(mShape->meshes[i])
mShape->meshes[i]->prepOpcodeCollision();
if(mShape->mMeshes[i])
mShape->mMeshes[i]->prepOpcodeCollision();
}
}

View file

@ -531,7 +531,7 @@ protected:
void deltaGround1(TSThread *, F32 start, F32 end, MatrixF& mat);
/// @}
U32 getNumDetails() const { return mShape ? mShape->details.size() : 0; }
U32 getNumDetails() const { return mShape ? mShape->mDetails.size() : 0; }
S32 getCurrentDetail() const { return mCurrentDetailLevel; }
@ -702,20 +702,20 @@ class TSThread
{
friend class TSShapeInstance;
S32 priority;
S32 mPriority;
TSShapeInstance * mShapeInstance; ///< Instance of the shape that this thread animates
S32 sequence; ///< Sequence this thread will perform
F32 pos;
S32 mSequence; ///< Sequence this thread will perform
F32 mPos;
F32 timeScale; ///< How fast to play through the sequence
F32 mTimeScale; ///< How fast to play through the sequence
S32 keyNum1; ///< Keyframe at or before current position
S32 keyNum2; ///< Keyframe at or after current position
F32 keyPos;
S32 mKeyNum1; ///< Keyframe at or before current position
S32 mKeyNum2; ///< Keyframe at or after current position
F32 mKeyPos;
bool blendDisabled; ///< Blend with other sequences?
bool mBlendDisabled; ///< Blend with other sequences?
/// if in transition...
struct TransitionData
@ -732,15 +732,15 @@ class TSThread
TSIntegerSet oldScaleNodes; ///< nodes controlled by this thread pre-transition
U32 oldSequence; ///< sequence that was set before transition began
F32 oldPos; ///< position of sequence before transition began
} transitionData;
} mTransitionData;
struct
{
F32 start;
F32 end;
S32 loop;
} path;
bool makePath;
} mPath;
bool mMakePath;
/// given a position on the thread, choose correct keyframes
/// slight difference between one-shot and cyclic sequences -- see comments below for details
@ -789,10 +789,10 @@ class TSThread
public:
TSShapeInstance * getShapeInstance() { return mShapeInstance; }
bool hasSequence() const { return sequence >= 0; }
U32 getSeqIndex() const { return sequence; }
const TSSequence* getSequence() const { return &(mShapeInstance->mShape->sequences[sequence]); }
const String& getSequenceName() const { return mShapeInstance->mShape->getSequenceName(sequence); }
bool hasSequence() const { return mSequence >= 0; }
U32 getSeqIndex() const { return mSequence; }
const TSSequence* getSequence() const { return &(mShapeInstance->mShape->mSequences[mSequence]); }
const String& getSequenceName() const { return mShapeInstance->mShape->getSequenceName(mSequence); }
S32 operator<(const TSThread &) const;
};

View file

@ -33,12 +33,12 @@ void TSShape::fixupOldSkins(S32 numMeshes, S32 numSkins, S32 numDetails, S32 * d
{
#if !defined(TORQUE_MAX_LIB)
// this method not necessary in exporter, and a couple lines won't compile for exporter
if (!objects.address() || !meshes.address() || !numSkins)
if (!mObjects.address() || !mMeshes.address() || !numSkins)
// not ready for this yet, will catch it on the next pass
return;
S32 numObjects = objects.size();
TSObject * newObjects = objects.address() + objects.size();
TSSkinMesh ** skins = (TSSkinMesh**)&meshes[numMeshes];
S32 numObjects = mObjects.size();
TSObject * newObjects = mObjects.address() + mObjects.size();
TSSkinMesh ** skins = (TSSkinMesh**)&mMeshes[numMeshes];
Vector<TSSkinMesh*> skinsCopy;
// Note: newObjects has as much free space as we need, so we just need to keep track of the
// number of objects we use and then update objects.size
@ -52,7 +52,7 @@ void TSShape::fixupOldSkins(S32 numMeshes, S32 numSkins, S32 numDetails, S32 * d
while (skinsUsed<numSkins-emptySkins)
{
TSObject & object = newObjects[numSkinObjects++];
objects.increment();
mObjects.increment();
object.nameIndex = 0; // no name
object.numMeshes = 0;
object.startMeshIndex = numMeshes + skinsCopy.size();
@ -92,29 +92,29 @@ void TSShape::fixupOldSkins(S32 numMeshes, S32 numSkins, S32 numDetails, S32 * d
// if no meshes, don't need object
if (!object.numMeshes)
{
objects.decrement();
mObjects.decrement();
numSkinObjects--;
}
}
dMemcpy(skins,skinsCopy.address(),skinsCopy.size()*sizeof(TSSkinMesh*));
if (subShapeFirstObject.size()==1)
if (mSubShapeFirstObject.size()==1)
// as long as only one subshape, we'll now be rendered
subShapeNumObjects[0] += numSkinObjects;
mSubShapeNumObjects[0] += numSkinObjects;
// now for something ugly -- we've added somoe objects to hold the skins...
// now we have to add default states for those objects
// we also have to increment base states on all the sequences that are loaded
dMemmove(objectStates.address()+numObjects+numSkinObjects,objectStates.address()+numObjects,(objectStates.size()-numObjects)*sizeof(ObjectState));
dMemmove(mObjectStates.address()+numObjects+numSkinObjects,mObjectStates.address()+numObjects,(mObjectStates.size()-numObjects)*sizeof(ObjectState));
for (i=numObjects; i<numObjects+numSkinObjects; i++)
{
objectStates[i].vis=1.0f;
objectStates[i].frameIndex=0;
objectStates[i].matFrameIndex=0;
mObjectStates[i].vis=1.0f;
mObjectStates[i].frameIndex=0;
mObjectStates[i].matFrameIndex=0;
}
for (i=0;i<sequences.size();i++)
for (i=0;i<mSequences.size();i++)
{
sequences[i].baseObjectState += numSkinObjects;
mSequences[i].baseObjectState += numSkinObjects;
}
#endif
}
@ -197,10 +197,10 @@ void TSShape::exportSequences(Stream * s)
// write node names
// -- this is how we will map imported sequence nodes to shape nodes
sz = nodes.size();
sz = mNodes.size();
s->write(sz);
for (i=0;i<nodes.size();i++)
writeName(s,nodes[i].nameIndex);
for (i=0;i<mNodes.size();i++)
writeName(s,mNodes[i].nameIndex);
// legacy write -- write zero objects, don't pretend to support object export anymore
s->write(0);
@ -208,71 +208,71 @@ void TSShape::exportSequences(Stream * s)
// on import, we will need to adjust keyframe data based on number of
// nodes/objects in this shape...number of nodes can be inferred from
// above, but number of objects cannot be. Write that quantity here:
s->write(objects.size());
s->write(mObjects.size());
// write node states -- skip default node states
s->write(nodeRotations.size());
for (i=0;i<nodeRotations.size();i++)
s->write(mNodeRotations.size());
for (i=0;i<mNodeRotations.size();i++)
{
s->write(nodeRotations[i].x);
s->write(nodeRotations[i].y);
s->write(nodeRotations[i].z);
s->write(nodeRotations[i].w);
s->write(mNodeRotations[i].x);
s->write(mNodeRotations[i].y);
s->write(mNodeRotations[i].z);
s->write(mNodeRotations[i].w);
}
s->write(nodeTranslations.size());
for (i=0;i<nodeTranslations.size(); i++)
s->write(mNodeTranslations.size());
for (i=0;i<mNodeTranslations.size(); i++)
{
s->write(nodeTranslations[i].x);
s->write(nodeTranslations[i].y);
s->write(nodeTranslations[i].z);
s->write(mNodeTranslations[i].x);
s->write(mNodeTranslations[i].y);
s->write(mNodeTranslations[i].z);
}
s->write(nodeUniformScales.size());
for (i=0;i<nodeUniformScales.size();i++)
s->write(nodeUniformScales[i]);
s->write(nodeAlignedScales.size());
for (i=0;i<nodeAlignedScales.size();i++)
s->write(mNodeUniformScales.size());
for (i=0;i<mNodeUniformScales.size();i++)
s->write(mNodeUniformScales[i]);
s->write(mNodeAlignedScales.size());
for (i=0;i<mNodeAlignedScales.size();i++)
{
s->write(nodeAlignedScales[i].x);
s->write(nodeAlignedScales[i].y);
s->write(nodeAlignedScales[i].z);
s->write(mNodeAlignedScales[i].x);
s->write(mNodeAlignedScales[i].y);
s->write(mNodeAlignedScales[i].z);
}
s->write(nodeArbitraryScaleRots.size());
for (i=0;i<nodeArbitraryScaleRots.size();i++)
s->write(mNodeArbitraryScaleRots.size());
for (i=0;i<mNodeArbitraryScaleRots.size();i++)
{
s->write(nodeArbitraryScaleRots[i].x);
s->write(nodeArbitraryScaleRots[i].y);
s->write(nodeArbitraryScaleRots[i].z);
s->write(nodeArbitraryScaleRots[i].w);
s->write(mNodeArbitraryScaleRots[i].x);
s->write(mNodeArbitraryScaleRots[i].y);
s->write(mNodeArbitraryScaleRots[i].z);
s->write(mNodeArbitraryScaleRots[i].w);
}
for (i=0;i<nodeArbitraryScaleFactors.size();i++)
for (i=0;i<mNodeArbitraryScaleFactors.size();i++)
{
s->write(nodeArbitraryScaleFactors[i].x);
s->write(nodeArbitraryScaleFactors[i].y);
s->write(nodeArbitraryScaleFactors[i].z);
s->write(mNodeArbitraryScaleFactors[i].x);
s->write(mNodeArbitraryScaleFactors[i].y);
s->write(mNodeArbitraryScaleFactors[i].z);
}
s->write(groundTranslations.size());
for (i=0;i<groundTranslations.size();i++)
s->write(mGroundTranslations.size());
for (i=0;i<mGroundTranslations.size();i++)
{
s->write(groundTranslations[i].x);
s->write(groundTranslations[i].y);
s->write(groundTranslations[i].z);
s->write(mGroundTranslations[i].x);
s->write(mGroundTranslations[i].y);
s->write(mGroundTranslations[i].z);
}
for (i=0;i<groundRotations.size();i++)
for (i=0;i<mGroundRotations.size();i++)
{
s->write(groundRotations[i].x);
s->write(groundRotations[i].y);
s->write(groundRotations[i].z);
s->write(groundRotations[i].w);
s->write(mGroundRotations[i].x);
s->write(mGroundRotations[i].y);
s->write(mGroundRotations[i].z);
s->write(mGroundRotations[i].w);
}
// write object states -- legacy..no object states
s->write((S32)0);
// write sequences
s->write(sequences.size());
for (i=0;i<sequences.size();i++)
s->write(mSequences.size());
for (i=0;i<mSequences.size();i++)
{
Sequence & seq = sequences[i];
Sequence & seq = mSequences[i];
// first write sequence name
writeName(s,seq.nameIndex);
@ -282,11 +282,11 @@ void TSShape::exportSequences(Stream * s)
}
// write out all the triggers...
s->write(triggers.size());
for (i=0; i<triggers.size(); i++)
s->write(mTriggers.size());
for (i=0; i<mTriggers.size(); i++)
{
s->write(triggers[i].state);
s->write(triggers[i].pos);
s->write(mTriggers[i].state);
s->write(mTriggers[i].pos);
}
}
@ -303,9 +303,9 @@ void TSShape::exportSequence(Stream * s, const TSShape::Sequence& seq, bool save
s->write(smVersion);
// write node names
s->write( nodes.size() );
for ( S32 i = 0; i < nodes.size(); i++ )
writeName( s, nodes[i].nameIndex );
s->write( mNodes.size() );
for ( S32 i = 0; i < mNodes.size(); i++ )
writeName( s, mNodes[i].nameIndex );
// legacy write -- write zero objects, don't pretend to support object export anymore
s->write( (S32)0 );
@ -313,26 +313,26 @@ void TSShape::exportSequence(Stream * s, const TSShape::Sequence& seq, bool save
// on import, we will need to adjust keyframe data based on number of
// nodes/objects in this shape...number of nodes can be inferred from
// above, but number of objects cannot be. Write that quantity here:
s->write( objects.size() );
s->write( mObjects.size() );
// write node states -- skip default node states
S32 count = seq.rotationMatters.count() * seq.numKeyframes;
s->write( count );
for ( S32 i = seq.baseRotation; i < seq.baseRotation + count; i++ )
{
s->write( nodeRotations[i].x );
s->write( nodeRotations[i].y );
s->write( nodeRotations[i].z );
s->write( nodeRotations[i].w );
s->write( mNodeRotations[i].x );
s->write( mNodeRotations[i].y );
s->write( mNodeRotations[i].z );
s->write( mNodeRotations[i].w );
}
count = seq.translationMatters.count() * seq.numKeyframes;
s->write( count );
for ( S32 i = seq.baseTranslation; i < seq.baseTranslation + count; i++ )
{
s->write( nodeTranslations[i].x );
s->write( nodeTranslations[i].y );
s->write( nodeTranslations[i].z );
s->write( mNodeTranslations[i].x );
s->write( mNodeTranslations[i].y );
s->write( mNodeTranslations[i].z );
}
count = seq.scaleMatters.count() * seq.numKeyframes;
@ -340,7 +340,7 @@ void TSShape::exportSequence(Stream * s, const TSShape::Sequence& seq, bool save
{
s->write( count );
for ( S32 i = seq.baseScale; i < seq.baseScale + count; i++ )
s->write( nodeUniformScales[i] );
s->write( mNodeUniformScales[i] );
}
else
s->write( (S32)0 );
@ -350,9 +350,9 @@ void TSShape::exportSequence(Stream * s, const TSShape::Sequence& seq, bool save
s->write( count );
for ( S32 i = seq.baseScale; i < seq.baseScale + count; i++ )
{
s->write( nodeAlignedScales[i].x );
s->write( nodeAlignedScales[i].y );
s->write( nodeAlignedScales[i].z );
s->write( mNodeAlignedScales[i].x );
s->write( mNodeAlignedScales[i].y );
s->write( mNodeAlignedScales[i].z );
}
}
else
@ -363,16 +363,16 @@ void TSShape::exportSequence(Stream * s, const TSShape::Sequence& seq, bool save
s->write( count );
for ( S32 i = seq.baseScale; i < seq.baseScale + count; i++ )
{
s->write( nodeArbitraryScaleRots[i].x );
s->write( nodeArbitraryScaleRots[i].y );
s->write( nodeArbitraryScaleRots[i].z );
s->write( nodeArbitraryScaleRots[i].w );
s->write( mNodeArbitraryScaleRots[i].x );
s->write( mNodeArbitraryScaleRots[i].y );
s->write( mNodeArbitraryScaleRots[i].z );
s->write( mNodeArbitraryScaleRots[i].w );
}
for ( S32 i = seq.baseScale; i < seq.baseScale + count; i++ )
{
s->write( nodeArbitraryScaleFactors[i].x );
s->write( nodeArbitraryScaleFactors[i].y );
s->write( nodeArbitraryScaleFactors[i].z );
s->write( mNodeArbitraryScaleFactors[i].x );
s->write( mNodeArbitraryScaleFactors[i].y );
s->write( mNodeArbitraryScaleFactors[i].z );
}
}
else
@ -381,16 +381,16 @@ void TSShape::exportSequence(Stream * s, const TSShape::Sequence& seq, bool save
s->write( seq.numGroundFrames );
for ( S32 i = seq.firstGroundFrame; i < seq.firstGroundFrame + seq.numGroundFrames; i++ )
{
s->write( groundTranslations[i].x );
s->write( groundTranslations[i].y );
s->write( groundTranslations[i].z );
s->write( mGroundTranslations[i].x );
s->write( mGroundTranslations[i].y );
s->write( mGroundTranslations[i].z );
}
for ( S32 i = seq.firstGroundFrame; i < seq.firstGroundFrame + seq.numGroundFrames; i++ )
{
s->write( groundRotations[i].x );
s->write( groundRotations[i].y );
s->write( groundRotations[i].z );
s->write( groundRotations[i].w );
s->write( mGroundRotations[i].x );
s->write( mGroundRotations[i].y );
s->write( mGroundRotations[i].z );
s->write( mGroundRotations[i].w );
}
// write object states -- legacy..no object states
@ -417,8 +417,8 @@ void TSShape::exportSequence(Stream * s, const TSShape::Sequence& seq, bool save
s->write( seq.numTriggers );
for ( S32 i = seq.firstTrigger; i < seq.firstTrigger + seq.numTriggers; i++ )
{
s->write( triggers[i].state );
s->write( triggers[i].pos );
s->write( mTriggers[i].state );
s->write( mTriggers[i].pos );
}
smVersion = currentVersion;
@ -460,7 +460,7 @@ bool TSShape::importSequences(Stream * s, const String& sequencePath)
for (i=0;i<sz;i++)
{
U32 startSize = names.size();
U32 startSize = mNames.size();
S32 nameIndex = readName(s,true);
nodeMap[i] = findNode(nameIndex);
@ -468,12 +468,12 @@ bool TSShape::importSequences(Stream * s, const String& sequencePath)
if (nodeMap[i] < 0)
{
// node found in sequence but not shape => remove the added node name
if (names.size() != startSize)
if (mNames.size() != startSize)
{
names.decrement();
mNames.decrement();
if (names.size() != startSize)
Con::errorf(ConsoleLogEntry::General, "TSShape::importSequence: failed to remove unused node correctly for dsq %s.", names[nameIndex].c_str(), sequencePath.c_str());
if (mNames.size() != startSize)
Con::errorf(ConsoleLogEntry::General, "TSShape::importSequence: failed to remove unused node correctly for dsq %s.", mNames[nameIndex].c_str(), sequencePath.c_str());
}
}
}
@ -487,9 +487,9 @@ bool TSShape::importSequences(Stream * s, const String& sequencePath)
s->read(&oldShapeNumObjects);
// adjust all the new keyframes
S32 adjNodeRots = smReadVersion<22 ? nodeRotations.size() - nodeMap.size() : nodeRotations.size();
S32 adjNodeTrans = smReadVersion<22 ? nodeTranslations.size() - nodeMap.size() : nodeTranslations.size();
S32 adjGroundStates = smReadVersion<22 ? 0 : groundTranslations.size(); // groundTrans==groundRot
S32 adjNodeRots = smReadVersion<22 ? mNodeRotations.size() - nodeMap.size() : mNodeRotations.size();
S32 adjNodeTrans = smReadVersion<22 ? mNodeTranslations.size() - nodeMap.size() : mNodeTranslations.size();
S32 adjGroundStates = smReadVersion<22 ? 0 : mGroundTranslations.size(); // groundTrans==groundRot
// Read the node states into temporary vectors, then use the
// nodeMap to discard unused transforms and map others to our nodes
@ -551,21 +551,21 @@ bool TSShape::importSequences(Stream * s, const String& sequencePath)
// ground transforms can be read directly into the shape (none will be
// discarded)
s->read(&sz);
S32 oldSz = groundTranslations.size();
groundTranslations.setSize(sz+oldSz);
S32 oldSz = mGroundTranslations.size();
mGroundTranslations.setSize(sz+oldSz);
for (i=oldSz;i<sz+oldSz;i++)
{
s->read(&groundTranslations[i].x);
s->read(&groundTranslations[i].y);
s->read(&groundTranslations[i].z);
s->read(&mGroundTranslations[i].x);
s->read(&mGroundTranslations[i].y);
s->read(&mGroundTranslations[i].z);
}
groundRotations.setSize(sz+oldSz);
mGroundRotations.setSize(sz+oldSz);
for (i=oldSz;i<sz+oldSz;i++)
{
s->read(&groundRotations[i].x);
s->read(&groundRotations[i].y);
s->read(&groundRotations[i].z);
s->read(&groundRotations[i].w);
s->read(&mGroundRotations[i].x);
s->read(&mGroundRotations[i].y);
s->read(&mGroundRotations[i].z);
s->read(&mGroundRotations[i].w);
}
}
else
@ -590,28 +590,28 @@ bool TSShape::importSequences(Stream * s, const String& sequencePath)
// read sequences
s->read(&sz);
S32 startSeqNum = sequences.size();
S32 startSeqNum = mSequences.size();
for (i=0;i<sz;i++)
{
sequences.increment();
Sequence & seq = sequences.last();
mSequences.increment();
Sequence & seq = mSequences.last();
// read name
seq.nameIndex = readName(s,true);
// read the rest of the sequence
seq.read(s,false);
seq.baseRotation = nodeRotations.size();
seq.baseTranslation = nodeTranslations.size();
seq.baseRotation = mNodeRotations.size();
seq.baseTranslation = mNodeTranslations.size();
if (smReadVersion > 21)
{
if (seq.animatesUniformScale())
seq.baseScale = nodeUniformScales.size();
seq.baseScale = mNodeUniformScales.size();
else if (seq.animatesAlignedScale())
seq.baseScale = nodeAlignedScales.size();
seq.baseScale = mNodeAlignedScales.size();
else if (seq.animatesArbitraryScale())
seq.baseScale = nodeArbitraryScaleFactors.size();
seq.baseScale = mNodeArbitraryScaleFactors.size();
}
// remap the node matters arrays
@ -633,18 +633,18 @@ bool TSShape::importSequences(Stream * s, const String& sequencePath)
}
// resize node transform arrays
nodeTranslations.increment(newTransMembership.count() * seq.numKeyframes);
nodeRotations.increment(newRotMembership.count() * seq.numKeyframes);
mNodeTranslations.increment(newTransMembership.count() * seq.numKeyframes);
mNodeRotations.increment(newRotMembership.count() * seq.numKeyframes);
if (seq.flags & TSShape::ArbitraryScale)
{
S32 scaleCount = newScaleMembership.count() * seq.numKeyframes;
nodeArbitraryScaleRots.increment(scaleCount);
nodeArbitraryScaleFactors.increment(scaleCount);
mNodeArbitraryScaleRots.increment(scaleCount);
mNodeArbitraryScaleFactors.increment(scaleCount);
}
else if (seq.flags & TSShape::AlignedScale)
nodeAlignedScales.increment(newScaleMembership.count() * seq.numKeyframes);
mNodeAlignedScales.increment(newScaleMembership.count() * seq.numKeyframes);
else
nodeUniformScales.increment(newScaleMembership.count() * seq.numKeyframes);
mNodeUniformScales.increment(newScaleMembership.count() * seq.numKeyframes);
// remap node transforms from temporary arrays
for (S32 j = 0; j < nodeMap.size(); j++)
@ -656,13 +656,13 @@ bool TSShape::importSequences(Stream * s, const String& sequencePath)
{
S32 src = seq.numKeyframes * seq.translationMatters.count(j);
S32 dest = seq.baseTranslation + seq.numKeyframes * newTransMembership.count(nodeMap[j]);
dCopyArray(&nodeTranslations[dest], &seqTranslations[src], seq.numKeyframes);
dCopyArray(&mNodeTranslations[dest], &seqTranslations[src], seq.numKeyframes);
}
if (newRotMembership.test(nodeMap[j]))
{
S32 src = seq.numKeyframes * seq.rotationMatters.count(j);
S32 dest = seq.baseRotation + seq.numKeyframes * newRotMembership.count(nodeMap[j]);
dCopyArray(&nodeRotations[dest], &seqRotations[src], seq.numKeyframes);
dCopyArray(&mNodeRotations[dest], &seqRotations[src], seq.numKeyframes);
}
if (newScaleMembership.test(nodeMap[j]))
{
@ -670,13 +670,13 @@ bool TSShape::importSequences(Stream * s, const String& sequencePath)
S32 dest = seq.baseScale + seq.numKeyframes * newScaleMembership.count(nodeMap[j]);
if (seq.flags & TSShape::ArbitraryScale)
{
dCopyArray(&nodeArbitraryScaleRots[dest], &seqArbitraryScaleRots[src], seq.numKeyframes);
dCopyArray(&nodeArbitraryScaleFactors[dest], &seqArbitraryScaleFactors[src], seq.numKeyframes);
dCopyArray(&mNodeArbitraryScaleRots[dest], &seqArbitraryScaleRots[src], seq.numKeyframes);
dCopyArray(&mNodeArbitraryScaleFactors[dest], &seqArbitraryScaleFactors[src], seq.numKeyframes);
}
else if (seq.flags & TSShape::AlignedScale)
dCopyArray(&nodeAlignedScales[dest], &seqAlignedScales[src], seq.numKeyframes);
dCopyArray(&mNodeAlignedScales[dest], &seqAlignedScales[src], seq.numKeyframes);
else
dCopyArray(&nodeUniformScales[dest], &seqUniformScales[src], seq.numKeyframes);
dCopyArray(&mNodeUniformScales[dest], &seqUniformScales[src], seq.numKeyframes);
}
}
@ -685,7 +685,7 @@ bool TSShape::importSequences(Stream * s, const String& sequencePath)
seq.scaleMatters = newScaleMembership;
// adjust trigger numbers...we'll read triggers after sequences...
seq.firstTrigger += triggers.size();
seq.firstTrigger += mTriggers.size();
// finally, adjust ground transform's nodes states
seq.firstGroundFrame += adjGroundStates;
@ -693,30 +693,30 @@ bool TSShape::importSequences(Stream * s, const String& sequencePath)
if (smReadVersion<22)
{
for (i=startSeqNum; i<sequences.size(); i++)
for (i=startSeqNum; i<mSequences.size(); i++)
{
// move ground transform data to ground vectors
Sequence & seq = sequences[i];
S32 oldSz = groundTranslations.size();
groundTranslations.setSize(oldSz+seq.numGroundFrames);
groundRotations.setSize(oldSz+seq.numGroundFrames);
Sequence & seq = mSequences[i];
S32 oldSz = mGroundTranslations.size();
mGroundTranslations.setSize(oldSz+seq.numGroundFrames);
mGroundRotations.setSize(oldSz+seq.numGroundFrames);
for (S32 j=0;j<seq.numGroundFrames;j++)
{
groundTranslations[j+oldSz] = nodeTranslations[seq.firstGroundFrame+adjNodeTrans+j];
groundRotations[j+oldSz] = nodeRotations[seq.firstGroundFrame+adjNodeRots+j];
mGroundTranslations[j+oldSz] = mNodeTranslations[seq.firstGroundFrame+adjNodeTrans+j];
mGroundRotations[j+oldSz] = mNodeRotations[seq.firstGroundFrame+adjNodeRots+j];
}
seq.firstGroundFrame = oldSz;
}
}
// add the new triggers
S32 oldSz = triggers.size();
S32 oldSz = mTriggers.size();
s->read(&sz);
triggers.setSize(oldSz+sz);
mTriggers.setSize(oldSz+sz);
for (S32 i=0; i<sz;i++)
{
s->read(&triggers[i+oldSz].state);
s->read(&triggers[i+oldSz].pos);
s->read(&mTriggers[i+oldSz].state);
s->read(&mTriggers[i+oldSz].pos);
}
if (smInitOnRead)
@ -846,7 +846,7 @@ void TSShape::writeName(Stream * s, S32 nameIndex)
{
const char * name = "";
if (nameIndex>=0)
name = names[nameIndex];
name = mNames[nameIndex];
S32 sz = (S32)dStrlen(name);
s->write(sz);
if (sz)
@ -876,9 +876,9 @@ S32 TSShape::readName(Stream * s, bool addName)
if (nameIndex<0 && addName)
{
nameIndex = names.size();
names.increment();
names.last() = buffer;
nameIndex = mNames.size();
mNames.increment();
mNames.last() = buffer;
}
}

View file

@ -80,16 +80,16 @@ bool TSSortedMesh::buildConvexHull()
S32 TSSortedMesh::getNumPolys()
{
S32 count = 0;
S32 cIdx = !clusters.size() ? -1 : 0;
S32 cIdx = !mClusters.size() ? -1 : 0;
while (cIdx>=0)
{
Cluster & cluster = clusters[cIdx];
Cluster & cluster = mClusters[cIdx];
for (S32 i=cluster.startPrimitive; i<cluster.endPrimitive; i++)
{
if (primitives[i].matIndex & TSDrawPrimitive::Triangles)
count += primitives[i].numElements / 3;
if (mPrimitives[i].matIndex & TSDrawPrimitive::Triangles)
count += mPrimitives[i].numElements / 3;
else
count += primitives[i].numElements - 2;
count += mPrimitives[i].numElements - 2;
}
cIdx = cluster.frontCluster; // always use frontCluster...we assume about the same no matter what
}
@ -117,25 +117,25 @@ void TSSortedMesh::assemble(bool skip)
S32 numClusters = tsalloc.get32();
S32 * ptr32 = tsalloc.copyToShape32(numClusters*8);
clusters.set(ptr32,numClusters);
mClusters.set(ptr32,numClusters);
S32 sz = tsalloc.get32();
ptr32 = tsalloc.copyToShape32(sz);
startCluster.set(ptr32,sz);
mStartCluster.set(ptr32,sz);
sz = tsalloc.get32();
ptr32 = tsalloc.copyToShape32(sz);
firstVerts.set(ptr32,sz);
mFirstVerts.set(ptr32,sz);
sz = tsalloc.get32();
ptr32 = tsalloc.copyToShape32(sz);
numVerts.set(ptr32,sz);
mNumVerts.set(ptr32,sz);
sz = tsalloc.get32();
ptr32 = tsalloc.copyToShape32(sz);
firstTVerts.set(ptr32,sz);
mFirstTVerts.set(ptr32,sz);
alwaysWriteDepth = tsalloc.get32()!=0;
mAlwaysWriteDepth = tsalloc.get32()!=0;
tsalloc.checkGuard();
}
@ -144,22 +144,22 @@ void TSSortedMesh::disassemble()
{
TSMesh::disassemble();
tsalloc.set32(clusters.size());
tsalloc.copyToBuffer32((S32*)clusters.address(),clusters.size()*8);
tsalloc.set32(mClusters.size());
tsalloc.copyToBuffer32((S32*)mClusters.address(),mClusters.size()*8);
tsalloc.set32(startCluster.size());
tsalloc.copyToBuffer32((S32*)startCluster.address(),startCluster.size());
tsalloc.set32(mStartCluster.size());
tsalloc.copyToBuffer32((S32*)mStartCluster.address(),mStartCluster.size());
tsalloc.set32(firstVerts.size());
tsalloc.copyToBuffer32((S32*)firstVerts.address(),firstVerts.size());
tsalloc.set32(mFirstVerts.size());
tsalloc.copyToBuffer32((S32*)mFirstVerts.address(),mFirstVerts.size());
tsalloc.set32(numVerts.size());
tsalloc.copyToBuffer32((S32*)numVerts.address(),numVerts.size());
tsalloc.set32(mNumVerts.size());
tsalloc.copyToBuffer32((S32*)mNumVerts.address(),mNumVerts.size());
tsalloc.set32(firstTVerts.size());
tsalloc.copyToBuffer32((S32*)firstTVerts.address(),firstTVerts.size());
tsalloc.set32(mFirstTVerts.size());
tsalloc.copyToBuffer32((S32*)mFirstTVerts.address(),mFirstTVerts.size());
tsalloc.set32(alwaysWriteDepth ? 1 : 0);
tsalloc.set32(mAlwaysWriteDepth ? 1 : 0);
tsalloc.setGuard();
}

View file

@ -48,14 +48,14 @@ public:
///< if frontCluster==backCluster, no plane to test against...
};
Vector<Cluster> clusters; ///< All of the clusters of primitives to be drawn
Vector<S32> startCluster; ///< indexed by frame number
Vector<S32> firstVerts; ///< indexed by frame number
Vector<S32> numVerts; ///< indexed by frame number
Vector<S32> firstTVerts; ///< indexed by frame number or matFrame number, depending on which one animates (never both)
Vector<Cluster> mClusters; ///< All of the clusters of primitives to be drawn
Vector<S32> mStartCluster; ///< indexed by frame number
Vector<S32> mFirstVerts; ///< indexed by frame number
Vector<S32> mNumVerts; ///< indexed by frame number
Vector<S32> mFirstTVerts; ///< indexed by frame number or matFrame number, depending on which one animates (never both)
/// sometimes, we want to write the depth value to the frame buffer even when object is translucent
bool alwaysWriteDepth;
bool mAlwaysWriteDepth;
// render methods..
void render(S32 frame, S32 matFrame, TSMaterialList *);
@ -71,7 +71,7 @@ public:
void disassemble();
TSSortedMesh() {
meshType = SortedMeshType;
mMeshType = SortedMeshType;
}
};

View file

@ -139,8 +139,8 @@ void TSThread::getGround(F32 t, MatrixF * pMat)
// assumed to be ident. and not found in the list.
if (frame)
{
p1 = &mShapeInstance->mShape->groundTranslations[getSequence()->firstGroundFrame + frame - 1];
q1 = &mShapeInstance->mShape->groundRotations[getSequence()->firstGroundFrame + frame - 1].getQuatF(&rot1);
p1 = &mShapeInstance->mShape->mGroundTranslations[getSequence()->firstGroundFrame + frame - 1];
q1 = &mShapeInstance->mShape->mGroundRotations[getSequence()->firstGroundFrame + frame - 1].getQuatF(&rot1);
}
else
{
@ -149,8 +149,8 @@ void TSThread::getGround(F32 t, MatrixF * pMat)
}
// similar to above, ground keyframe number 'frame+1' is actually offset by 'frame'
p2 = &mShapeInstance->mShape->groundTranslations[getSequence()->firstGroundFrame + frame];
q2 = &mShapeInstance->mShape->groundRotations[getSequence()->firstGroundFrame + frame].getQuatF(&rot2);
p2 = &mShapeInstance->mShape->mGroundTranslations[getSequence()->firstGroundFrame + frame];
q2 = &mShapeInstance->mShape->mGroundRotations[getSequence()->firstGroundFrame + frame].getQuatF(&rot2);
QuatF q;
Point3F p;
@ -163,24 +163,24 @@ void TSThread::setSequence(S32 seq, F32 toPos)
{
const TSShape * shape = mShapeInstance->mShape;
AssertFatal(shape && shape->sequences.size()>seq && toPos>=0.0f && toPos<=1.0f,
AssertFatal(shape && shape->mSequences.size()>seq && toPos>=0.0f && toPos<=1.0f,
"TSThread::setSequence: invalid shape handle, sequence number, or position.");
mShapeInstance->clearTransition(this);
sequence = seq;
priority = getSequence()->priority;
pos = toPos;
makePath = getSequence()->makePath();
path.start = path.end = 0;
path.loop = 0;
mSequence = seq;
mPriority = getSequence()->priority;
mPos = toPos;
mMakePath = getSequence()->makePath();
mPath.start = mPath.end = 0;
mPath.loop = 0;
// 1.0f doesn't exist on cyclic sequences
if (pos>0.9999f && getSequence()->isCyclic())
pos = 0.9999f;
if (mPos>0.9999f && getSequence()->isCyclic())
mPos = 0.9999f;
// select keyframes
selectKeyframes(pos,getSequence(),&keyNum1,&keyNum2,&keyPos);
selectKeyframes(mPos,getSequence(),&mKeyNum1,&mKeyNum2,&mKeyPos);
}
void TSThread::transitionToSequence(S32 seq, F32 toPos, F32 duration, bool continuePlay)
@ -192,49 +192,49 @@ void TSThread::transitionToSequence(S32 seq, F32 toPos, F32 duration, bool conti
// of the transition is interpolated. If we start to transtion from A to B,
// but before reaching B we transtion to C, we interpolate all nodes controlled
// by A, B, or C to their new position.
if (transitionData.inTransition)
if (mTransitionData.inTransition)
{
transitionData.oldRotationNodes.overlap(getSequence()->rotationMatters);
transitionData.oldTranslationNodes.overlap(getSequence()->translationMatters);
transitionData.oldScaleNodes.overlap(getSequence()->scaleMatters);
mTransitionData.oldRotationNodes.overlap(getSequence()->rotationMatters);
mTransitionData.oldTranslationNodes.overlap(getSequence()->translationMatters);
mTransitionData.oldScaleNodes.overlap(getSequence()->scaleMatters);
}
else
{
transitionData.oldRotationNodes = getSequence()->rotationMatters;
transitionData.oldTranslationNodes = getSequence()->translationMatters;
transitionData.oldScaleNodes = getSequence()->scaleMatters;
mTransitionData.oldRotationNodes = getSequence()->rotationMatters;
mTransitionData.oldTranslationNodes = getSequence()->translationMatters;
mTransitionData.oldScaleNodes = getSequence()->scaleMatters;
}
// set time characteristics of transition
transitionData.oldSequence = sequence;
transitionData.oldPos = pos;
transitionData.duration = duration;
transitionData.pos = 0.0f;
transitionData.direction = timeScale>0.0f ? 1.0f : -1.0f;
transitionData.targetScale = continuePlay ? 1.0f : 0.0f;
mTransitionData.oldSequence = mSequence;
mTransitionData.oldPos = mPos;
mTransitionData.duration = duration;
mTransitionData.pos = 0.0f;
mTransitionData.direction = mTimeScale>0.0f ? 1.0f : -1.0f;
mTransitionData.targetScale = continuePlay ? 1.0f : 0.0f;
// in transition...
transitionData.inTransition = true;
mTransitionData.inTransition = true;
// set target sequence data
sequence = seq;
priority = getSequence()->priority;
pos = toPos;
makePath = getSequence()->makePath();
path.start = path.end = 0;
path.loop = 0;
mSequence = seq;
mPriority = getSequence()->priority;
mPos = toPos;
mMakePath = getSequence()->makePath();
mPath.start = mPath.end = 0;
mPath.loop = 0;
// 1.0f doesn't exist on cyclic sequences
if (pos>0.9999f && getSequence()->isCyclic())
pos = 0.9999f;
if (mPos>0.9999f && getSequence()->isCyclic())
mPos = 0.9999f;
// select keyframes
selectKeyframes(pos,getSequence(),&keyNum1,&keyNum2,&keyPos);
selectKeyframes(mPos,getSequence(),&mKeyNum1,&mKeyNum2,&mKeyPos);
}
bool TSThread::isInTransition()
{
return transitionData.inTransition;
return mTransitionData.inTransition;
}
void TSThread::animateTriggers()
@ -242,30 +242,30 @@ void TSThread::animateTriggers()
if (!getSequence()->numTriggers)
return;
switch (path.loop)
switch (mPath.loop)
{
case -1 :
activateTriggers(path.start,0);
activateTriggers(1,path.end);
activateTriggers(mPath.start,0);
activateTriggers(1,mPath.end);
break;
case 0 :
activateTriggers(path.start,path.end);
activateTriggers(mPath.start,mPath.end);
break;
case 1 :
activateTriggers(path.start,1);
activateTriggers(0,path.end);
activateTriggers(mPath.start,1);
activateTriggers(0,mPath.end);
break;
default:
{
if (path.loop>0)
if (mPath.loop>0)
{
activateTriggers(path.end,1);
activateTriggers(0,path.end);
activateTriggers(mPath.end,1);
activateTriggers(0,mPath.end);
}
else
{
activateTriggers(path.end,0);
activateTriggers(1,path.end);
activateTriggers(mPath.end,0);
activateTriggers(1,mPath.end);
}
}
}
@ -287,12 +287,12 @@ void TSThread::activateTriggers(F32 a, F32 b)
for (i=firstTrigger; i<numTriggers+firstTrigger; i++)
{
// is a between this trigger and previous one...
if (a>lastPos && a<=shape->triggers[i].pos)
if (a>lastPos && a<=shape->mTriggers[i].pos)
aIndex = i;
// is b between this trigger and previous one...
if (b>lastPos && b<=shape->triggers[i].pos)
if (b>lastPos && b<=shape->mTriggers[i].pos)
bIndex = i;
lastPos = shape->triggers[i].pos;
lastPos = shape->mTriggers[i].pos;
}
// activate triggers between aIndex and bIndex (depends on direction)
@ -300,7 +300,7 @@ void TSThread::activateTriggers(F32 a, F32 b)
{
for (i=aIndex; i<bIndex; i++)
{
U32 state = shape->triggers[i].state;
U32 state = shape->mTriggers[i].state;
bool on = (state & TSShape::Trigger::StateOn)!=0;
mShapeInstance->setTriggerStateBit(state & TSShape::Trigger::StateMask, on);
}
@ -309,7 +309,7 @@ void TSThread::activateTriggers(F32 a, F32 b)
{
for (i=aIndex-1; i>=bIndex; i--)
{
U32 state = shape->triggers[i].state;
U32 state = shape->mTriggers[i].state;
bool on = (state & TSShape::Trigger::StateOn)!=0;
if (state & TSShape::Trigger::InvertOnReverse)
on = !on;
@ -320,32 +320,32 @@ void TSThread::activateTriggers(F32 a, F32 b)
F32 TSThread::getPos()
{
return transitionData.inTransition ? transitionData.pos : pos;
return mTransitionData.inTransition ? mTransitionData.pos : mPos;
}
F32 TSThread::getTime()
{
return transitionData.inTransition ? transitionData.pos * transitionData.duration : pos * getSequence()->duration;
return mTransitionData.inTransition ? mTransitionData.pos * mTransitionData.duration : mPos * getSequence()->duration;
}
F32 TSThread::getDuration()
{
return transitionData.inTransition ? transitionData.duration : getSequence()->duration;
return mTransitionData.inTransition ? mTransitionData.duration : getSequence()->duration;
}
F32 TSThread::getScaledDuration()
{
return getDuration() / mFabs(timeScale);
return getDuration() / mFabs(mTimeScale);
}
F32 TSThread::getTimeScale()
{
return timeScale;
return mTimeScale;
}
void TSThread::setTimeScale(F32 ts)
{
timeScale = ts;
mTimeScale = ts;
}
void TSThread::advancePos(F32 delta)
@ -353,76 +353,76 @@ void TSThread::advancePos(F32 delta)
if (mFabs(delta)>0.00001f)
{
// make dirty what this thread changes
U32 dirtyFlags = getSequence()->dirtyFlags | (transitionData.inTransition ? TSShapeInstance::TransformDirty : 0);
for (S32 i=0; i<mShapeInstance->getShape()->subShapeFirstNode.size(); i++)
U32 dirtyFlags = getSequence()->dirtyFlags | (mTransitionData.inTransition ? TSShapeInstance::TransformDirty : 0);
for (S32 i=0; i<mShapeInstance->getShape()->mSubShapeFirstNode.size(); i++)
mShapeInstance->mDirtyFlags[i] |= dirtyFlags;
}
if (transitionData.inTransition)
if (mTransitionData.inTransition)
{
transitionData.pos += transitionData.direction * delta;
if (transitionData.pos<0 || transitionData.pos>=1.0f)
mTransitionData.pos += mTransitionData.direction * delta;
if (mTransitionData.pos<0 || mTransitionData.pos>=1.0f)
{
mShapeInstance->clearTransition(this);
if (transitionData.pos<0.0f)
if (mTransitionData.pos<0.0f)
// return to old sequence
mShapeInstance->setSequence(this,transitionData.oldSequence,transitionData.oldPos);
mShapeInstance->setSequence(this,mTransitionData.oldSequence,mTransitionData.oldPos);
}
// re-adjust delta to be correct time-wise
delta *= transitionData.targetScale * transitionData.duration / getSequence()->duration;
delta *= mTransitionData.targetScale * mTransitionData.duration / getSequence()->duration;
}
// even if we are in a transition, keep playing the sequence
if (makePath)
if (mMakePath)
{
path.start = pos;
pos += delta;
mPath.start = mPos;
mPos += delta;
if (!getSequence()->isCyclic())
{
pos = mClampF(pos , 0.0f, 1.0f);
path.loop = 0;
mPos = mClampF(mPos , 0.0f, 1.0f);
mPath.loop = 0;
}
else
{
path.loop = (S32)pos;
if (pos < 0.0f)
path.loop--;
pos -= path.loop;
mPath.loop = (S32)mPos;
if (mPos < 0.0f)
mPath.loop--;
mPos -= mPath.loop;
// following necessary because of floating point roundoff errors
if (pos < 0.0f) pos += 1.0f;
if (pos >= 1.0f) pos -= 1.0f;
if (mPos < 0.0f) mPos += 1.0f;
if (mPos >= 1.0f) mPos -= 1.0f;
}
path.end = pos;
mPath.end = mPos;
animateTriggers(); // do this automatically...no need for user to call it
AssertFatal(pos>=0.0f && pos<=1.0f,"TSThread::advancePos (1)");
AssertFatal(!getSequence()->isCyclic() || pos<1.0f,"TSThread::advancePos (2)");
AssertFatal(mPos>=0.0f && mPos<=1.0f,"TSThread::advancePos (1)");
AssertFatal(!getSequence()->isCyclic() || mPos<1.0f,"TSThread::advancePos (2)");
}
else
{
pos += delta;
mPos += delta;
if (!getSequence()->isCyclic())
pos = mClampF(pos, 0.0f, 1.0f);
mPos = mClampF(mPos, 0.0f, 1.0f);
else
{
pos -= S32(pos);
mPos -= S32(mPos);
// following necessary because of floating point roundoff errors
if (pos < 0.0f) pos += 1.0f;
if (pos >= 1.0f) pos -= 1.0f;
if (mPos < 0.0f) mPos += 1.0f;
if (mPos >= 1.0f) mPos -= 1.0f;
}
AssertFatal(pos>=0.0f && pos<=1.0f,"TSThread::advancePos (3)");
AssertFatal(!getSequence()->isCyclic() || pos<1.0f,"TSThread::advancePos (4)");
AssertFatal(mPos>=0.0f && mPos<=1.0f,"TSThread::advancePos (3)");
AssertFatal(!getSequence()->isCyclic() || mPos<1.0f,"TSThread::advancePos (4)");
}
// select keyframes
selectKeyframes(pos,getSequence(),&keyNum1,&keyNum2,&keyPos);
selectKeyframes(mPos,getSequence(),&mKeyNum1,&mKeyNum2,&mKeyPos);
}
void TSThread::advanceTime(F32 delta)
{
advancePos(timeScale * delta / getDuration());
advancePos(mTimeScale * delta / getDuration());
}
void TSThread::setPos(F32 pos)
@ -432,40 +432,40 @@ void TSThread::setPos(F32 pos)
void TSThread::setTime(F32 time)
{
setPos(timeScale * time/getDuration());
setPos(mTimeScale * time/getDuration());
}
S32 TSThread::getKeyframeCount()
{
AssertFatal(!transitionData.inTransition,"TSThread::getKeyframeCount: not while in transition");
AssertFatal(!mTransitionData.inTransition,"TSThread::getKeyframeCount: not while in transition");
return getSequence()->numKeyframes + 1;
}
S32 TSThread::getKeyframeNumber()
{
AssertFatal(!transitionData.inTransition,"TSThread::getKeyframeNumber: not while in transition");
AssertFatal(!mTransitionData.inTransition,"TSThread::getKeyframeNumber: not while in transition");
return keyNum1;
return mKeyNum1;
}
void TSThread::setKeyframeNumber(S32 kf)
{
AssertFatal(kf>=0 && kf<= getSequence()->numKeyframes,
"TSThread::setKeyframeNumber: invalid frame specified.");
AssertFatal(!transitionData.inTransition,"TSThread::setKeyframeNumber: not while in transition");
AssertFatal(!mTransitionData.inTransition,"TSThread::setKeyframeNumber: not while in transition");
keyNum1 = keyNum2 = kf;
keyPos = 0;
pos = 0;
mKeyNum1 = mKeyNum2 = kf;
mKeyPos = 0;
mPos = 0;
}
TSThread::TSThread(TSShapeInstance * _shapeInst)
{
timeScale = 1.0f;
mTimeScale = 1.0f;
mShapeInstance = _shapeInst;
transitionData.inTransition = false;
blendDisabled = false;
mTransitionData.inTransition = false;
mBlendDisabled = false;
setSequence(0,0.0f);
}
@ -475,9 +475,9 @@ S32 TSThread::operator<(const TSThread & th2) const
{
// both blend or neither blend, sort based on priority only -- higher priority first
S32 ret = 0; // do it this way to (hopefully) take advantage of 'conditional move' assembly instruction
if (priority > th2.priority)
if (mPriority > th2.mPriority)
ret = -1;
if (th2.priority > priority)
if (th2.mPriority > mPriority)
ret = 1;
return ret;
}
@ -500,7 +500,7 @@ S32 TSThread::operator<(const TSThread & th2) const
TSThread * TSShapeInstance::addThread()
{
if (mShape->sequences.empty())
if (mShape->mSequences.empty())
return NULL;
mThreadList.increment();
@ -542,7 +542,7 @@ U32 TSShapeInstance::threadCount()
void TSShapeInstance::setSequence(TSThread * thread, S32 seq, F32 pos)
{
if ( (thread->transitionData.inTransition && mTransitionThreads.size()>1) || mTransitionThreads.size()>0)
if ( (thread->mTransitionData.inTransition && mTransitionThreads.size()>1) || mTransitionThreads.size()>0)
{
// if we have transitions, make sure transforms are up to date...
sortThreads();
@ -565,7 +565,7 @@ U32 TSShapeInstance::getSequence(TSThread * thread)
{
//AssertFatal( thread->sequence >= 0, "TSShapeInstance::getSequence: range error A");
//AssertFatal( thread->sequence < mShape->sequences.size(), "TSShapeInstance::getSequence: range error B");
return (U32)thread->sequence;
return (U32)thread->mSequence;
}
void TSShapeInstance::transitionToSequence(TSThread * thread, S32 seq, F32 pos, F32 duration, bool continuePlay)
@ -583,13 +583,13 @@ void TSShapeInstance::transitionToSequence(TSThread * thread, S32 seq, F32 pos,
else if (!mScaleCurrentlyAnimated && thread->getSequence()->animatesScale())
mScaleCurrentlyAnimated=true;
mTransitionRotationNodes.overlap(thread->transitionData.oldRotationNodes);
mTransitionRotationNodes.overlap(thread->mTransitionData.oldRotationNodes);
mTransitionRotationNodes.overlap(thread->getSequence()->rotationMatters);
mTransitionTranslationNodes.overlap(thread->transitionData.oldTranslationNodes);
mTransitionTranslationNodes.overlap(thread->mTransitionData.oldTranslationNodes);
mTransitionTranslationNodes.overlap(thread->getSequence()->translationMatters);
mTransitionScaleNodes.overlap(thread->transitionData.oldScaleNodes);
mTransitionScaleNodes.overlap(thread->mTransitionData.oldScaleNodes);
mTransitionScaleNodes.overlap(thread->getSequence()->scaleMatters);
// if we aren't already in the list of transition threads, add us now
@ -605,7 +605,7 @@ void TSShapeInstance::transitionToSequence(TSThread * thread, S32 seq, F32 pos,
void TSShapeInstance::clearTransition(TSThread * thread)
{
if (!thread->transitionData.inTransition)
if (!thread->mTransitionData.inTransition)
return;
// if other transitions are still playing,
@ -614,7 +614,7 @@ void TSShapeInstance::clearTransition(TSThread * thread)
animateNodeSubtrees();
// turn off transition...
thread->transitionData.inTransition = false;
thread->mTransitionData.inTransition = false;
// remove us from transition list
S32 i;
@ -632,13 +632,13 @@ void TSShapeInstance::clearTransition(TSThread * thread)
mTransitionScaleNodes.clearAll();
for (i=0; i<mTransitionThreads.size(); i++)
{
mTransitionRotationNodes.overlap(mTransitionThreads[i]->transitionData.oldRotationNodes);
mTransitionRotationNodes.overlap(mTransitionThreads[i]->mTransitionData.oldRotationNodes);
mTransitionRotationNodes.overlap(mTransitionThreads[i]->getSequence()->rotationMatters);
mTransitionTranslationNodes.overlap(mTransitionThreads[i]->transitionData.oldTranslationNodes);
mTransitionTranslationNodes.overlap(mTransitionThreads[i]->mTransitionData.oldTranslationNodes);
mTransitionTranslationNodes.overlap(mTransitionThreads[i]->getSequence()->translationMatters);
mTransitionScaleNodes.overlap(mTransitionThreads[i]->transitionData.oldScaleNodes);
mTransitionScaleNodes.overlap(mTransitionThreads[i]->mTransitionData.oldScaleNodes);
mTransitionScaleNodes.overlap(mTransitionThreads[i]->getSequence()->scaleMatters);
}
@ -656,9 +656,9 @@ void TSShapeInstance::updateTransitions()
updateTransitionNodeTransforms(transitionNodes);
S32 i;
mNodeReferenceRotations.setSize(mShape->nodes.size());
mNodeReferenceTranslations.setSize(mShape->nodes.size());
for (i=0; i<mShape->nodes.size(); i++)
mNodeReferenceRotations.setSize(mShape->mNodes.size());
mNodeReferenceTranslations.setSize(mShape->mNodes.size());
for (i=0; i<mShape->mNodes.size(); i++)
{
if (mTransitionRotationNodes.test(i))
mNodeReferenceRotations[i].set(smNodeCurrentRotations[i]);
@ -674,8 +674,8 @@ void TSShapeInstance::updateTransitions()
if (animatesUniformScale())
{
mNodeReferenceUniformScales.setSize(mShape->nodes.size());
for (i=0; i<mShape->nodes.size(); i++)
mNodeReferenceUniformScales.setSize(mShape->mNodes.size());
for (i=0; i<mShape->mNodes.size(); i++)
{
if (mTransitionScaleNodes.test(i))
mNodeReferenceUniformScales[i] = smNodeCurrentUniformScales[i];
@ -683,8 +683,8 @@ void TSShapeInstance::updateTransitions()
}
else if (animatesAlignedScale())
{
mNodeReferenceScaleFactors.setSize(mShape->nodes.size());
for (i=0; i<mShape->nodes.size(); i++)
mNodeReferenceScaleFactors.setSize(mShape->mNodes.size());
for (i=0; i<mShape->mNodes.size(); i++)
{
if (mTransitionScaleNodes.test(i))
mNodeReferenceScaleFactors[i] = smNodeCurrentAlignedScales[i];
@ -692,9 +692,9 @@ void TSShapeInstance::updateTransitions()
}
else
{
mNodeReferenceScaleFactors.setSize(mShape->nodes.size());
mNodeReferenceArbitraryScaleRots.setSize(mShape->nodes.size());
for (i=0; i<mShape->nodes.size(); i++)
mNodeReferenceScaleFactors.setSize(mShape->mNodes.size());
mNodeReferenceArbitraryScaleRots.setSize(mShape->mNodes.size());
for (i=0; i<mShape->mNodes.size(); i++)
{
if (mTransitionScaleNodes.test(i))
{
@ -709,10 +709,10 @@ void TSShapeInstance::updateTransitions()
for (i=0; i<mTransitionThreads.size(); i++)
{
TSThread * th = mTransitionThreads[i];
if (th->transitionData.inTransition)
if (th->mTransitionData.inTransition)
{
th->transitionData.duration *= 1.0f - th->transitionData.pos;
th->transitionData.pos = 0.0f;
th->mTransitionData.duration *= 1.0f - th->mTransitionData.pos;
th->mTransitionData.pos = 0.0f;
}
}
}
@ -728,22 +728,22 @@ void TSShapeInstance::checkScaleCurrentlyAnimated()
void TSShapeInstance::setBlendEnabled(TSThread * thread, bool blendOn)
{
thread->blendDisabled = !blendOn;
thread->mBlendDisabled = !blendOn;
}
bool TSShapeInstance::getBlendEnabled(TSThread * thread)
{
return !thread->blendDisabled;
return !thread->mBlendDisabled;
}
void TSShapeInstance::setPriority(TSThread * thread, F32 priority)
{
thread->priority = priority;
thread->mPriority = priority;
}
F32 TSShapeInstance::getPriority(TSThread * thread)
{
return thread->priority;
return thread->mPriority;
}
F32 TSShapeInstance::getTime(TSThread * thread)