Merge branch 'development' into EngineAPI-Refactor

This commit is contained in:
Areloch 2018-12-09 14:48:50 -06:00 committed by GitHub
commit 3a71c75596
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1937 changed files with 102332 additions and 70549 deletions

View file

@ -152,7 +152,7 @@ private:
// Add the input to the right place in the list (somewhere between start and end)
for (S32 i = start; i <= end; i++) {
const domInputLocalOffset* localOffset = daeSafeCast<domInputLocalOffset>(sortedInputs[i]);
localOffset = daeSafeCast<domInputLocalOffset>(sortedInputs[i]);
domUint set = localOffset ? localOffset->getSet() : 0xFFFFFFFF;
if (newSet < set) {
for (S32 j = i + 1; j <= end; j++)
@ -181,10 +181,10 @@ private:
const char* semantic = SourceTypeToSemantic( type );
for (S32 iInput = 0; iInput < vertices->getInput_array().getCount(); iInput++)
{
domInputLocal* input = vertices->getInput_array().get(iInput);
if (dStrEqual(input->getSemantic(), semantic))
domInputLocal* vInput = vertices->getInput_array().get(iInput);
if (dStrEqual(vInput->getSemantic(), semantic))
{
source = daeSafeCast<domSource>(findInputSource(input));
source = daeSafeCast<domSource>(findInputSource(vInput));
break;
}
}
@ -977,7 +977,7 @@ void ColladaAppMesh::lookupSkinData()
bool tooManyWeightsWarning = false;
for (S32 iVert = 0; iVert < vertsPerFrame; iVert++) {
const domUint* vcount = (domUint*)weights_vcount.getRaw(0);
const domInt* vindices = (domInt*)weights_v.getRaw(0);
vindices = (domInt*)weights_v.getRaw(0);
vindices += vindicesOffset[vertTuples[iVert].vertex];
S32 nonZeroWeightCount = 0;

View file

@ -120,9 +120,9 @@ static void processNode(GuiTreeViewCtrl* tree, domNode* node, S32 parentID, Scen
for (S32 i = 0; i < node->getInstance_node_array().getCount(); i++)
{
domInstance_node* instnode = node->getInstance_node_array()[i];
domNode* node = daeSafeCast<domNode>(instnode->getUrl().getElement());
if (node)
processNode(tree, node, nodeID, stats);
domNode* dNode = daeSafeCast<domNode>(instnode->getUrl().getElement());
if (dNode)
processNode(tree, dNode, nodeID, stats);
}
}

View file

@ -266,10 +266,10 @@ void AnimData::parseTargetString(const char* target, S32 fullCount, const char*
targetValueCount = 1;
}
}
else if (const char* p = dStrrchr(target, '.')) {
else if (const char* p2 = dStrrchr(target, '.')) {
// Check for named elements
for (S32 iElem = 0; elements[iElem][0] != 0; iElem++) {
if (!dStrcmp(p, elements[iElem])) {
if (!dStrcmp(p2, elements[iElem])) {
targetValueOffset = iElem;
targetValueCount = 1;
break;
@ -2948,7 +2948,7 @@ void ColladaUtils::ExportData::processData()
detailLevels.clear();
detailLevels.setSize(numDetailLevels);
for (U32 m = 0; m < meshData.size(); ++m)
for (U32 meshNum = 0; meshNum < meshData.size(); ++meshNum)
{
for (U32 i = 0; i < numDetailLevels; ++i)
{
@ -2967,7 +2967,7 @@ void ColladaUtils::ExportData::processData()
{
//walk backwards as needed to find our first valid detail level for this mesh. if we find none, just move on
S32 testDetailLevelSize = getDetailLevelSize(mdl);
detailLevelIdx = meshData[m].hasDetailLevel(testDetailLevelSize);
detailLevelIdx = meshData[meshNum].hasDetailLevel(testDetailLevelSize);
if (detailLevelIdx != -1)
break;
@ -2983,7 +2983,7 @@ void ColladaUtils::ExportData::processData()
{
//walk backwards as needed to find our first valid detail level for this mesh. if we find none, just move on
S32 testDetailLevelSize = getDetailLevelSize(mdl);
detailLevelIdx = meshData[m].hasDetailLevel(testDetailLevelSize);
detailLevelIdx = meshData[meshNum].hasDetailLevel(testDetailLevelSize);
if (detailLevelIdx != -1)
break;
@ -2994,13 +2994,13 @@ void ColladaUtils::ExportData::processData()
//If we found the detail level index, go ahead and build out the data for it
if (detailLevelIdx != -1)
{
curDetail->mesh.setTransform(&meshData[m].meshTransform, meshData[m].scale);
curDetail->mesh.setObject(meshData[m].originatingObject);
curDetail->mesh.setTransform(&meshData[meshNum].meshTransform, meshData[meshNum].scale);
curDetail->mesh.setObject(meshData[meshNum].originatingObject);
if (meshData[m].shapeInst != nullptr)
if (meshData[meshNum].shapeInst != nullptr)
{
if (!meshData[m].shapeInst->buildPolyList(&curDetail->mesh, detailLevelIdx))
if (!meshData[meshNum].shapeInst->buildPolyList(&curDetail->mesh, detailLevelIdx))
{
Con::errorf("TSStatic::buildExportPolyList - failed to build polylist for LOD %i", i);
continue;
@ -3009,10 +3009,10 @@ void ColladaUtils::ExportData::processData()
else
{
//special handling classes
ConvexShape* convexShp = dynamic_cast<ConvexShape*>(meshData[m].originatingObject);
ConvexShape* convexShp = dynamic_cast<ConvexShape*>(meshData[meshNum].originatingObject);
if (convexShp != nullptr)
{
if (!convexShp->buildPolyList(PLC_Export, &curDetail->mesh, meshData[m].originatingObject->getWorldBox(), meshData[m].originatingObject->getWorldSphere()))
if (!convexShp->buildPolyList(PLC_Export, &curDetail->mesh, meshData[meshNum].originatingObject->getWorldBox(), meshData[meshNum].originatingObject->getWorldSphere()))
{
Con::errorf("TSStatic::buildExportPolyList - failed to build ConvexShape polylist for LOD %i", i);
continue;
@ -3021,19 +3021,19 @@ void ColladaUtils::ExportData::processData()
}
//lastly, get material
for (U32 m = 0; m < curDetail->mesh.mMaterialList.size(); m++)
for (U32 matNum = 0; matNum < curDetail->mesh.mMaterialList.size(); matNum++)
{
S32 matIdx = hasMaterialInstance(curDetail->mesh.mMaterialList[m]);
S32 matIdx = hasMaterialInstance(curDetail->mesh.mMaterialList[matNum]);
if (matIdx == -1)
{
//cool, haven't already got this material, so lets store it out
materials.push_back(curDetail->mesh.mMaterialList[m]);
curDetail->materialRefList.insert(m, materials.size() - 1);
materials.push_back(curDetail->mesh.mMaterialList[matNum]);
curDetail->materialRefList.insert(matNum, materials.size() - 1);
}
else
{
curDetail->materialRefList.insert(m, matIdx);
curDetail->materialRefList.insert(matNum, matIdx);
}
}
}

View file

@ -147,13 +147,13 @@ 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 = points;
tsmesh->mNorms = normals;
tsmesh->mTverts = uvs;
tsmesh->mPrimitives = primitives;
tsmesh->mIndices = indices;
tsmesh->mColors = colors;
tsmesh->mTverts2 = uv2s;
// Finish initializing the shape
tsmesh->setFlags(flags);
@ -162,8 +162,8 @@ TSMesh* AppMesh::constructTSMesh()
tsmesh->numFrames = numFrames;
tsmesh->numMatFrames = numMatFrames;
tsmesh->vertsPerFrame = vertsPerFrame;
tsmesh->createTangents(tsmesh->verts, tsmesh->norms);
tsmesh->encodedNorms.set(NULL,0);
tsmesh->createTangents(tsmesh->mVerts, tsmesh->mNorms);
tsmesh->mEncodedNorms.set(NULL,0);
return tsmesh;
}

View file

@ -1172,7 +1172,7 @@ void TSShapeLoader::install()
{
TSMesh *mesh = shape->meshes[obj.startMeshIndex + iMesh];
if (mesh && !mesh->primitives.size())
if (mesh && !mesh->mPrimitives.size())
{
S32 oldMeshCount = obj.numMeshes;
destructInPlace(mesh);
@ -1220,13 +1220,13 @@ void TSShapeLoader::install()
}
}
computeBounds(shape->bounds);
if (!shape->bounds.isValidBox())
shape->bounds = Box3F(1.0f);
computeBounds(shape->mBounds);
if (!shape->mBounds.isValidBox())
shape->mBounds = Box3F(1.0f);
shape->bounds.getCenter(&shape->center);
shape->radius = (shape->bounds.maxExtents - shape->center).len();
shape->tubeRadius = shape->radius;
shape->mBounds.getCenter(&shape->center);
shape->mRadius = (shape->mBounds.maxExtents - shape->center).len();
shape->tubeRadius = shape->mRadius;
shape->init();
shape->finalizeEditable();

View file

@ -118,8 +118,6 @@ protected:
Vector<QuatF*> nodeScaleRotCache;
Vector<Point3F*> nodeScaleCache;
Point3F shapeOffset; ///< Offset used to translate the shape origin
//--------------------------------------------------------------------------
// Collect the nodes, objects and sequences for the scene

View file

@ -212,11 +212,11 @@ void TSShapeInstance::animateNodes(S32 ss)
for (i=0; i<mNodeCallbacks.size(); i++)
{
AssertFatal(mNodeCallbacks[i].callback, "No callback method defined");
S32 nodeIndex = mNodeCallbacks[i].nodeIndex;
if (nodeIndex>=start && nodeIndex<end)
S32 nodeIdx = mNodeCallbacks[i].nodeIndex;
if (nodeIdx >=start && nodeIdx<end)
{
mNodeCallbacks[i].callback->setNodeTransform(this, nodeIndex, smNodeLocalTransforms[nodeIndex]);
smNodeLocalTransformDirty.set(nodeIndex);
mNodeCallbacks[i].callback->setNodeTransform(this, nodeIdx, smNodeLocalTransforms[nodeIdx]);
smNodeLocalTransformDirty.set(nodeIdx);
}
}

View file

@ -414,7 +414,7 @@ void TSShapeInstance::computeBounds(S32 dl, Box3F & bounds)
// use shape bounds for imposter details
if (ss < 0)
{
bounds = mShape->bounds;
bounds = mShape->mBounds;
return;
}
@ -1044,6 +1044,9 @@ PhysicsCollision* TSShape::_buildColShapes( bool useVisibleMesh, const Point3F &
// We need the default mesh transform.
MatrixF localXfm;
getNodeWorldTransform( object.nodeIndex, &localXfm );
Point3F t = localXfm.getPosition();
t.convolve(scale);
localXfm.setPosition(t);
// We have some sort of collision shape... so allocate it.
if ( !colShape )
@ -1053,12 +1056,14 @@ PhysicsCollision* TSShape::_buildColShapes( bool useVisibleMesh, const Point3F &
if ( dStrStartsWith( meshName, "Colbox" ) )
{
// The bounds define the box extents directly.
Point3F halfWidth = mesh->getBounds().getExtents() * 0.5f;
Point3F halfWidth = mesh->getBounds().getExtents() * scale * 0.5f;
// Add the offset to the center of the bounds
// into the local space transform.
MatrixF centerXfm( true );
centerXfm.setPosition( mesh->getBounds().getCenter() );
Point3F t = mesh->getBounds().getCenter();
t.convolve(scale);
centerXfm.setPosition(t);
localXfm.mul( centerXfm );
colShape->addBox( halfWidth, localXfm );
@ -1066,12 +1071,15 @@ PhysicsCollision* TSShape::_buildColShapes( bool useVisibleMesh, const Point3F &
else if ( dStrStartsWith( meshName, "Colsphere" ) )
{
// Get a sphere inscribed to the bounds.
F32 radius = mesh->getBounds().len_min() * 0.5f;
Point3F extents = mesh->getBounds().getExtents() * scale;
F32 radius = extents.least() * 0.5f;
// Add the offset to the center of the bounds
// Add the offset to the center of the bounds
// into the local space transform.
MatrixF primXfm( true );
primXfm.setPosition( mesh->getBounds().getCenter() );
Point3F t = mesh->getBounds().getCenter();
t.convolve(scale);
primXfm.setPosition(t);
localXfm.mul( primXfm );
colShape->addSphere( radius, localXfm );
@ -1079,12 +1087,14 @@ PhysicsCollision* TSShape::_buildColShapes( bool useVisibleMesh, const Point3F &
else if ( dStrStartsWith( meshName, "Colcapsule" ) )
{
// Use the smallest extent as the radius for the capsule.
Point3F extents = mesh->getBounds().getExtents();
Point3F extents = mesh->getBounds().getExtents() * scale;
F32 radius = extents.least() * 0.5f;
// We need to center the capsule and align it to the Y axis.
MatrixF primXfm( true );
primXfm.setPosition( mesh->getBounds().getCenter() );
Point3F t = mesh->getBounds().getCenter();
t.convolve(scale);
primXfm.setPosition(t);
// Use the longest axis as the capsule height.
F32 height = -radius * 2.0f;
@ -1139,10 +1149,6 @@ PhysicsCollision* TSShape::_buildColShapes( bool useVisibleMesh, const Point3F &
VertexPolyList polyList;
MatrixF meshMat( localXfm );
Point3F t = meshMat.getPosition();
t.convolve( scale );
meshMat.setPosition( t );
polyList.setTransform( &MatrixF::Identity, scale );
mesh->buildPolyList( 0, &polyList, surfaceKey, NULL );
colShape->addConvex( polyList.getVertexList().address(),
@ -1364,9 +1370,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 +1383,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 +1402,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 +1413,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 +1427,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 +1440,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;
@ -1467,7 +1473,7 @@ void TSMesh::prepOpcodeCollision()
}
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 );
}
}
@ -1499,14 +1505,14 @@ static Point3F texGenAxis[18] =
};
bool TSMesh::castRayOpcode( const Point3F &s, const Point3F &e, RayInfo *info, TSMaterialList *materials )
bool TSMesh::castRayOpcode( const Point3F &start, const Point3F &end, RayInfo *info, TSMaterialList *materials )
{
Opcode::RayCollider ray;
Opcode::CollisionFaces cfs;
IceMaths::Point dir( e.x - s.x, e.y - s.y, e.z - s.z );
IceMaths::Point dir(end.x - start.x, end.y - start.y, end.z - start.z );
const F32 rayLen = dir.Magnitude();
IceMaths::Ray vec( Point(s.x, s.y, s.z), dir.Normalize() );
IceMaths::Ray vec( Point(start.x, start.y, start.z), dir.Normalize() );
ray.SetDestination( &cfs);
ray.SetFirstContact( false );

View file

@ -197,10 +197,10 @@ void TSShapeInstance::dump(Stream & stream)
dumpLine("\r\n Sequences:\r\n");
for (i = 0; i < mShape->sequences.size(); i++)
{
const char *name = "(none)";
const char *seqName = "(none)";
if (mShape->sequences[i].nameIndex != -1)
name = mShape->getName(mShape->sequences[i].nameIndex);
dumpLine(avar(" %3d: %s%s%s\r\n", i, name,
seqName = mShape->getName(mShape->sequences[i].nameIndex);
dumpLine(avar(" %3d: %s%s%s\r\n", i, seqName,
mShape->sequences[i].isCyclic() ? " (cyclic)" : "",
mShape->sequences[i].isBlend() ? " (blend)" : ""));
}
@ -212,9 +212,9 @@ void TSShapeInstance::dump(Stream & stream)
for (i=0; i<(S32)ml->size(); i++)
{
U32 flags = ml->getFlags(i);
const String& name = ml->getMaterialName(i);
const String& matName = ml->getMaterialName(i);
dumpLine(avar(
" material #%i: '%s'%s.", i, name.c_str(),
" material #%i: '%s'%s.", i, matName.c_str(),
flags & (TSMaterialList::S_Wrap|TSMaterialList::T_Wrap) ? "" : " not tiled")
);
if (flags & TSMaterialList::Translucent)

View file

@ -82,7 +82,7 @@ TSLastDetail::TSLastDetail( TSShape *shape,
mDl = dl;
mDim = getMax( dim, (S32)32 );
mRadius = mShape->radius;
mRadius = mShape->mRadius;
mCenter = mShape->center;
mCachePath = cachePath;
@ -420,24 +420,24 @@ void TSLastDetail::_update()
imposterCap->end();
Point2I texSize( destBmp.getWidth(mip), destBmp.getHeight(mip) );
Point2I atlasSize( destBmp.getWidth(mip), destBmp.getHeight(mip) );
// Ok... pack in bitmaps till we run out.
for ( S32 y=0; y+currDim <= texSize.y; )
for ( S32 y=0; y+currDim <= atlasSize.y; )
{
for ( S32 x=0; x+currDim <= texSize.x; )
for ( S32 x=0; x+currDim <= atlasSize.x; )
{
// Copy the next bitmap to the dest texture.
GBitmap* bmp = bitmaps.first();
GBitmap* cell = bitmaps.first();
bitmaps.pop_front();
destBmp.copyRect( bmp, RectI( 0, 0, currDim, currDim ), Point2I( x, y ), 0, mip );
delete bmp;
destBmp.copyRect(cell, RectI( 0, 0, currDim, currDim ), Point2I( x, y ), 0, mip );
delete cell;
// Copy the next normal to the dest texture.
GBitmap* normalmap = normalmaps.first();
GBitmap* cellNormalmap = normalmaps.first();
normalmaps.pop_front();
destNormal.copyRect( normalmap, RectI( 0, 0, currDim, currDim ), Point2I( x, y ), 0, mip );
delete normalmap;
destNormal.copyRect(cellNormalmap, RectI( 0, 0, currDim, currDim ), Point2I( x, y ), 0, mip );
delete cellNormalmap;
// Did we finish?
if ( bitmaps.empty() )

File diff suppressed because it is too large Load diff

View file

@ -251,7 +251,7 @@ public:
protected:
U32 meshType;
U32 mMeshType;
Box3F mBounds;
Point3F mCenter;
F32 mRadius;
@ -259,7 +259,7 @@ protected:
const GFXVertexFormat *mVertexFormat;
TSMesh *parentMeshObject; ///< Current parent object instance
TSMesh *mParentMeshObject; ///< Current parent object instance
U32 mPrimBufferOffset;
@ -268,7 +268,7 @@ protected:
public:
S32 parentMesh; ///< index into shapes mesh list
S32 mParentMesh; ///< index into shapes mesh list
S32 numFrames;
S32 numMatFrames;
S32 vertsPerFrame;
@ -299,12 +299,12 @@ protected:
FlagMask = Billboard|BillboardZAxis|HasDetailTexture|UseEncodedNormals|HasColor|HasTVert2
};
U32 getMeshType() const { return meshType & TypeMask; }
U32 getHasColor() const { return colors.size() > 0 || meshType & HasColor; }
U32 getHasTVert2() const { return tverts2.size() > 0 || meshType & HasTVert2; }
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; }
U32 getHasColor() const { return mColors.size() > 0 || mMeshType & HasColor; }
U32 getHasTVert2() const { return mTverts2.size() > 0 || mMeshType & HasTVert2; }
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 );
@ -319,34 +319,34 @@ protected:
/// @name Vertex data
/// @{
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

View file

@ -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;
@ -282,7 +282,7 @@ void MeshFit::addSourceMesh( const TSShape::Object& obj, const TSMesh* mesh )
S32 count, stride;
U8* pVert;
if ( mesh->mVertexData.isReady() && mesh->verts.size() == 0 )
if ( mesh->mVertexData.isReady() && mesh->mVerts.size() == 0 )
{
count = mesh->mVertexData.size();
stride = mesh->mVertexData.vertSize();
@ -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;
@ -329,61 +329,61 @@ TSMesh* MeshFit::createTriMesh( F32* verts, S32 numVerts, U32* indices, S32 numT
mesh->setFlags(0);
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;
}
@ -404,13 +404,13 @@ void MeshFit::addBox( const Point3F& sides, const MatrixF& mat )
if ( !mesh )
return;
if (mesh->verts.size() > 0)
if (mesh->mVerts.size() > 0)
{
for (S32 i = 0; i < mesh->verts.size(); i++)
for (S32 i = 0; i < mesh->mVerts.size(); i++)
{
Point3F v = mesh->verts[i];
Point3F v = mesh->mVerts[i];
v.convolve(sides);
mesh->verts[i] = v;
mesh->mVerts[i] = v;
}
mesh->mVertexData.setReady(false);
@ -799,7 +799,7 @@ DefineTSShapeConstructorMethod( addPrimitive, bool, ( const char* meshName, cons
MatrixF mat( txfm.getMatrix() );
// Transform the mesh vertices
if ( mesh->mVertexData.isReady() && mesh->verts.size() == 0 )
if ( mesh->mVertexData.isReady() && mesh->mVerts.size() == 0 )
{
for (S32 i = 0; i < mesh->mVertexData.size(); i++)
{
@ -811,10 +811,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

@ -566,8 +566,8 @@ void TSShape::initObjects()
if (accel != NULL) {
delete[] accel->vertexList;
delete[] accel->normalList;
for (S32 j = 0; j < accel->numVerts; j++)
delete[] accel->emitStrings[j];
for (S32 vertID = 0; vertID < accel->numVerts; vertID++)
delete[] accel->emitStrings[vertID];
delete[] accel->emitStrings;
delete accel;
}
@ -585,18 +585,18 @@ void TSShape::initObjects()
if (!mesh)
continue;
if (mesh->parentMesh >= meshes.size())
if (mesh->mParentMesh >= meshes.size())
{
Con::warnf("Mesh %i has a bad parentMeshObject (%i)", iter - meshes.begin(), mesh->parentMesh);
Con::warnf("Mesh %i has a bad parentMeshObject (%i)", iter - meshes.begin(), mesh->mParentMesh);
}
if (mesh->parentMesh >= 0 && mesh->parentMesh < meshes.size())
if (mesh->mParentMesh >= 0 && mesh->mParentMesh < meshes.size())
{
mesh->parentMeshObject = meshes[mesh->parentMesh];
mesh->mParentMeshObject = meshes[mesh->mParentMesh];
}
else
{
mesh->parentMeshObject = NULL;
mesh->mParentMeshObject = NULL;
}
mesh->mVertexFormat = &mVertexFormat;
@ -622,8 +622,8 @@ void TSShape::initVertexBuffers()
mesh->getMeshType() != TSMesh::SkinMeshType))
continue;
destIndices += mesh->indices.size();
destPrims += mesh->primitives.size();
destIndices += mesh->mIndices.size();
destPrims += mesh->mPrimitives.size();
}
// For HW skinning we can just use the static buffer
@ -660,15 +660,15 @@ void TSShape::initVertexBuffers()
AssertFatal(mesh->mVertOffset / mVertexSize == vertStart, "offset mismatch");
vertStart += mesh->mNumVerts;
primStart += mesh->primitives.size();
indStart += mesh->indices.size();
primStart += mesh->mPrimitives.size();
indStart += mesh->mIndices.size();
mesh->mVB = mShapeVertexBuffer;
mesh->mPB = mShapeVertexIndices;
// Advance
piInput += mesh->primitives.size();
ibIndices += mesh->indices.size();
piInput += mesh->mPrimitives.size();
ibIndices += mesh->mIndices.size();
if (TSSkinMesh::smDebugSkinVerts && mesh->getMeshType() == TSMesh::SkinMeshType)
{
@ -683,9 +683,9 @@ void TSShape::initVertexBuffers()
U32 vertsInBuffer = mShapeVertexData.size / mVertexSize;
U32 indsInBuffer = ibIndices - indicesStart;
for (U32 i = 0; i < primStart; i++)
for (U32 primID = 0; primID < primStart; primID++)
{
GFXPrimitive &prim = mShapeVertexIndices->mPrimitiveArray[i];
GFXPrimitive &prim = mShapeVertexIndices->mPrimitiveArray[primID];
if (prim.type != GFXTriangleList && prim.type != GFXTriangleStrip)
{
@ -845,7 +845,7 @@ void TSShape::initVertexFeatures()
mesh->mVertOffset = destVertex;
destVertex += mesh->mVertSize * mesh->getNumVerts();
destIndices += mesh->indices.size();
destIndices += mesh->mIndices.size();
count += 1;
}
@ -906,12 +906,12 @@ void TSShape::initVertexFeatures()
mesh->mVertexData.setReady(true);
#ifdef TORQUE_DEBUG
AssertFatal(mesh->mNumVerts == mesh->verts.size(), "vert mismatch");
AssertFatal(mesh->mNumVerts == mesh->mVerts.size(), "vert mismatch");
for (U32 i = 0; i < mesh->mNumVerts; i++)
{
Point3F v1 = mesh->verts[i];
Point3F v1 = mesh->mVerts[i];
Point3F v2 = mesh->mVertexData.getBase(i).vert();
AssertFatal(mesh->verts[i] == mesh->mVertexData.getBase(i).vert(), "vert data mismatch");
AssertFatal(mesh->mVerts[i] == mesh->mVertexData.getBase(i).vert(), "vert data mismatch");
}
if (mesh->getMeshType() == TSMesh::SkinMeshType)
@ -987,11 +987,11 @@ void TSShape::initMaterialList()
if (!mesh)
continue;
for (k=0; k<mesh->primitives.size(); k++)
for (k=0; k<mesh->mPrimitives.size(); k++)
{
if (mesh->primitives[k].matIndex & TSDrawPrimitive::NoMaterial)
if (mesh->mPrimitives[k].matIndex & TSDrawPrimitive::NoMaterial)
continue;
S32 flags = materialList->getFlags(mesh->primitives[k].matIndex & TSDrawPrimitive::MaterialMask);
S32 flags = materialList->getFlags(mesh->mPrimitives[k].matIndex & TSDrawPrimitive::MaterialMask);
if (flags & TSMaterialList::AuxiliaryMap)
continue;
if (flags & TSMaterialList::Translucent)
@ -1001,7 +1001,7 @@ void TSShape::initMaterialList()
break;
}
}
if (k!=mesh->primitives.size())
if (k!=mesh->mPrimitives.size())
break;
}
if (j!=obj.numMeshes)
@ -1195,10 +1195,10 @@ void TSShape::assembleShape()
tsalloc.checkGuard();
// get bounds...
tsalloc.get32((S32*)&radius,1);
tsalloc.get32((S32*)&mRadius,1);
tsalloc.get32((S32*)&tubeRadius,1);
tsalloc.get32((S32*)&center,3);
tsalloc.get32((S32*)&bounds,6);
tsalloc.get32((S32*)&mBounds,6);
tsalloc.checkGuard();
@ -1303,10 +1303,10 @@ void TSShape::assembleShape()
S32 oldSz = groundTranslations.size();
groundTranslations.setSize(oldSz+seq.numGroundFrames);
groundRotations.setSize(oldSz+seq.numGroundFrames);
for (S32 j=0;j<seq.numGroundFrames;j++)
for (S32 groundFrm =0; groundFrm<seq.numGroundFrames; groundFrm++)
{
groundTranslations[j+oldSz] = nodeTranslations[seq.firstGroundFrame+j-numNodes];
groundRotations[j+oldSz] = nodeRotations[seq.firstGroundFrame+j-numNodes];
groundTranslations[groundFrm +oldSz] = nodeTranslations[seq.firstGroundFrame+ groundFrm -numNodes];
groundRotations[groundFrm +oldSz] = nodeRotations[seq.firstGroundFrame+ groundFrm -numNodes];
}
seq.firstGroundFrame = oldSz;
seq.baseTranslation -= numNodes;
@ -1378,9 +1378,9 @@ void TSShape::assembleShape()
ptr32 = tsalloc.copyToShape32( numDetails * 7, true );
details.setSize( numDetails );
for ( U32 i = 0; i < details.size(); i++, ptr32 += 7 )
for ( U32 detID = 0; detID < details.size(); detID++, ptr32 += 7 )
{
Detail *det = &(details[i]);
Detail *det = &(details[detID]);
// Clear the struct... we don't want to leave
// garbage in the parts that are unfilled.
@ -1408,12 +1408,12 @@ void TSShape::assembleShape()
// Some DTS exporters (MAX - I'm looking at you!) write garbage into the
// averageError and maxError values which stops LOD from working correctly.
// Try to detect and fix it
for ( U32 i = 0; i < details.size(); i++ )
for ( U32 erID = 0; erID < details.size(); erID++ )
{
if ( ( details[i].averageError == 0 ) || ( details[i].averageError > 10000 ) ||
( details[i].maxError == 0 ) || ( details[i].maxError > 10000 ) )
if ( ( details[erID].averageError == 0 ) || ( details[erID].averageError > 10000 ) ||
( details[erID].maxError == 0 ) || ( details[erID].maxError > 10000 ) )
{
details[i].averageError = details[i].maxError = -1.0f;
details[erID].averageError = details[erID].maxError = -1.0f;
}
}
@ -1521,15 +1521,15 @@ void TSShape::assembleShape()
// fill in location of verts, tverts, and normals for detail levels
if (mesh && meshType!=TSMesh::DecalMeshType)
{
TSMesh::smVertsList[i] = mesh->verts.address();
TSMesh::smTVertsList[i] = mesh->tverts.address();
TSMesh::smVertsList[i] = mesh->mVerts.address();
TSMesh::smTVertsList[i] = mesh->mTverts.address();
if (smReadVersion >= 26)
{
TSMesh::smTVerts2List[i] = mesh->tverts2.address();
TSMesh::smColorsList[i] = mesh->colors.address();
TSMesh::smTVerts2List[i] = mesh->mTverts2.address();
TSMesh::smColorsList[i] = mesh->mColors.address();
}
TSMesh::smNormsList[i] = mesh->norms.address();
TSMesh::smEncodedNormsList[i] = mesh->encodedNorms.address();
TSMesh::smNormsList[i] = mesh->mNorms.address();
TSMesh::smEncodedNormsList[i] = mesh->mEncodedNorms.address();
TSMesh::smDataCopied[i] = !skip; // as long as we didn't skip this mesh, the data should be in shape now
if (meshType==TSMesh::SkinMeshType)
{
@ -1617,9 +1617,9 @@ void TSShape::assembleShape()
if (skin)
{
TSMesh::smVertsList[i] = skin->batchData.initialVerts.address();
TSMesh::smTVertsList[i] = skin->tverts.address();
TSMesh::smTVertsList[i] = skin->mTverts.address();
TSMesh::smNormsList[i] = skin->batchData.initialNorms.address();
TSMesh::smEncodedNormsList[i] = skin->encodedNorms.address();
TSMesh::smEncodedNormsList[i] = skin->mEncodedNorms.address();
TSMesh::smDataCopied[i] = !skip; // as long as we didn't skip this mesh, the data should be in shape now
TSSkinMesh::smInitTransformList[i] = skin->batchData.initialTransforms.address();
TSSkinMesh::smVertexIndexList[i] = skin->vertexIndex.address();
@ -1670,10 +1670,10 @@ void TSShape::disassembleShape()
tsalloc.setGuard();
// get bounds...
tsalloc.copyToBuffer32((S32*)&radius,1);
tsalloc.copyToBuffer32((S32*)&mRadius,1);
tsalloc.copyToBuffer32((S32*)&tubeRadius,1);
tsalloc.copyToBuffer32((S32*)&center,3);
tsalloc.copyToBuffer32((S32*)&bounds,6);
tsalloc.copyToBuffer32((S32*)&mBounds,6);
tsalloc.setGuard();
@ -1740,8 +1740,8 @@ void TSShape::disassembleShape()
{
// Legacy details => no explicit autobillboard parameters
U32 legacyDetailSize32 = 7; // only store the first 7 4-byte values of each detail
for ( S32 i = 0; i < details.size(); i++ )
tsalloc.copyToBuffer32( (S32*)&details[i], legacyDetailSize32 );
for ( S32 bbID = 0; bbID < details.size(); bbID++ )
tsalloc.copyToBuffer32( (S32*)&details[bbID], legacyDetailSize32 );
}
tsalloc.setGuard();
@ -1805,15 +1805,15 @@ bool TSShape::canWriteOldFormat() const
continue;
// Cannot use old format if using the new functionality (COLORs, 2nd UV set)
if (meshes[i]->tverts2.size() || meshes[i]->colors.size())
if (meshes[i]->mTverts2.size() || meshes[i]->mColors.size())
return false;
// Cannot use old format if any primitive has too many triangles
// (ie. cannot fit in a S16)
for (S32 j = 0; j < meshes[i]->primitives.size(); j++)
for (S32 j = 0; j < meshes[i]->mPrimitives.size(); j++)
{
if ((meshes[i]->primitives[j].start +
meshes[i]->primitives[j].numElements) >= (1 << 15))
if ((meshes[i]->mPrimitives[j].start +
meshes[i]->mPrimitives[j].numElements) >= (1 << 15))
{
return false;
}
@ -2060,11 +2060,11 @@ void TSShape::createEmptyShape()
names[1] = StringTable->insert("Mesh2");
names[2] = StringTable->insert("Mesh");
radius = 0.866025f;
mRadius = 0.866025f;
tubeRadius = 0.707107f;
center.set(0.0f, 0.5f, 0.0f);
bounds.minExtents.set(-0.5f, 0.0f, -0.5f);
bounds.maxExtents.set(0.5f, 1.0f, 0.5f);
mBounds.minExtents.set(-0.5f, 0.0f, -0.5f);
mBounds.maxExtents.set(0.5f, 1.0f, 0.5f);
mExporterVersion = 124;
mSmallestVisibleSize = 2;

View file

@ -354,10 +354,10 @@ class TSShape
/// @name Bounding
/// @{
F32 radius;
F32 mRadius;
F32 tubeRadius;
Point3F center;
Box3F bounds;
Box3F mBounds;
/// @}

View file

@ -1354,7 +1354,7 @@ 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;
S32 matIndex = mesh->mPrimitives[0].matIndex & TSDrawPrimitive::MaterialMask;
if ((matIndex >= 0) && (matIndex < mShape->materialList->size()))
return mShape->materialList->getMaterialName( matIndex );
else
@ -1391,10 +1391,10 @@ DefineTSShapeConstructorMethod( setMeshMaterial, bool, ( const char* meshName, c
}
// 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();
@ -1459,7 +1459,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 ),,
@ -1471,10 +1471,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->center );
shape->mRadius = ( shape->mBounds.maxExtents - shape->center ).len();
shape->tubeRadius = shape->mRadius;
ADD_TO_CHANGE_SET();
return true;
@ -2214,12 +2214,12 @@ void TSShapeConstructor::ChangeSet::write(TSShape* shape, Stream& stream, const
for (U32 j = 1; j < cmd.argc; j++)
{
// Use relative paths when possible
String str( cmd.argv[j] );
if ( str.startsWith( savePath ) )
str = str.substr( savePath.length() + 1 );
String relStr( cmd.argv[j] );
if (relStr.startsWith( savePath ) )
relStr = relStr.substr( savePath.length() + 1 );
stream.writeText( ", \"" );
stream.write( str.length(), str.c_str() );
stream.write(relStr.length(), relStr.c_str() );
stream.writeText( "\"" );
}
}

View file

@ -756,13 +756,13 @@ void TSShape::removeMeshFromObject(S32 objIndex, S32 meshIndex)
if (meshes[k] == NULL)
continue;
if (meshes[k]->parentMesh == idxToRemove)
if (meshes[k]->mParentMesh == idxToRemove)
{
meshes[k]->parentMesh = -1;
meshes[k]->mParentMesh = -1;
}
else if (meshes[k]->parentMesh > idxToRemove)
else if (meshes[k]->mParentMesh > idxToRemove)
{
meshes[k]->parentMesh--;
meshes[k]->mParentMesh--;
}
}
@ -800,13 +800,13 @@ void TSShape::removeMeshFromObject(S32 objIndex, S32 meshIndex)
if (meshes[k] == NULL)
continue;
if (meshes[k]->parentMesh == idxToRemove)
if (meshes[k]->mParentMesh == idxToRemove)
{
meshes[k]->parentMesh = -1;
meshes[k]->mParentMesh = -1;
}
else if (meshes[k]->parentMesh > idxToRemove)
else if (meshes[k]->mParentMesh > idxToRemove)
{
meshes[k]->parentMesh--;
meshes[k]->mParentMesh--;
}
}
@ -937,8 +937,8 @@ TSMesh* TSShape::copyMesh( const TSMesh* srcMesh ) const
return mesh; // return an empty mesh
// Copy mesh elements
mesh->indices = srcMesh->indices;
mesh->primitives = srcMesh->primitives;
mesh->mIndices = srcMesh->mIndices;
mesh->mPrimitives = srcMesh->mPrimitives;
mesh->numFrames = srcMesh->numFrames;
mesh->numMatFrames = srcMesh->numMatFrames;
mesh->vertsPerFrame = srcMesh->vertsPerFrame;
@ -948,8 +948,8 @@ TSMesh* TSShape::copyMesh( const TSMesh* srcMesh ) const
// Copy vertex data in an *unpacked* form
mesh->copySourceVertexDataFrom(srcMesh);
mesh->createTangents(mesh->verts, mesh->norms);
mesh->encodedNorms.set(NULL, 0);
mesh->createTangents(mesh->mVerts, mesh->mNorms);
mesh->mEncodedNorms.set(NULL, 0);
mesh->computeBounds();
@ -1108,12 +1108,12 @@ bool TSShape::addMesh(TSShape* srcShape, const String& srcMeshName, const String
// Copy materials used by the source mesh (only if from a different shape)
if (srcShape != this)
{
for (S32 i = 0; i < mesh->primitives.size(); i++)
for (S32 i = 0; i < mesh->mPrimitives.size(); i++)
{
if (!(mesh->primitives[i].matIndex & TSDrawPrimitive::NoMaterial))
if (!(mesh->mPrimitives[i].matIndex & TSDrawPrimitive::NoMaterial))
{
S32 drawType = (mesh->primitives[i].matIndex & (~TSDrawPrimitive::MaterialMask));
S32 srcMatIndex = mesh->primitives[i].matIndex & TSDrawPrimitive::MaterialMask;
S32 drawType = (mesh->mPrimitives[i].matIndex & (~TSDrawPrimitive::MaterialMask));
S32 srcMatIndex = mesh->mPrimitives[i].matIndex & TSDrawPrimitive::MaterialMask;
const String& matName = srcShape->materialList->getMaterialName(srcMatIndex);
// Add the material if it does not already exist
@ -1124,7 +1124,7 @@ bool TSShape::addMesh(TSShape* srcShape, const String& srcMeshName, const String
materialList->push_back(matName, srcShape->materialList->getFlags(srcMatIndex));
}
mesh->primitives[i].matIndex = drawType | destMatIndex;
mesh->mPrimitives[i].matIndex = drawType | destMatIndex;
}
}
}

View file

@ -307,18 +307,21 @@ void TSShapeInstance::reSkin( String newBaseName, String oldBaseName )
{
// Try changing base
const String &pName = materialNames[i];
if ( pName.compare( oldBaseName, oldBaseNameLength, String::NoCase ) == 0 )
{
String newName( pName );
newName.replace( 0, oldBaseNameLength, newBaseName );
pMatList->renameMaterial( i, newName );
}
String newName( String::ToLower(pName) );
newName.replace( String::ToLower(oldBaseName), String::ToLower(newBaseName) );
pMatList->renameMaterial( i, newName );
}
// Initialize the material instances
initMaterialList();
}
void TSShapeInstance::resetMaterialList()
{
TSMaterialList* oMatlist = mShape->materialList;
setMaterialList(oMatlist);
}
//-------------------------------------------------------------------------------------
// Render & detail selection
//-------------------------------------------------------------------------------------
@ -662,7 +665,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 ) {

View file

@ -377,7 +377,7 @@ protected:
}
void reSkin( String newBaseName, String oldBaseName = String::EmptyString );
void resetMaterialList();
enum
{
MaskNodeRotation = 0x01,
@ -727,7 +727,7 @@ class TSThread
TSShapeInstance * mShapeInstance; ///< Instance of the shape that this thread animates
S32 sequence; ///< Sequence this thread will perform
F32 pos;
F32 mSeqPos;
F32 timeScale; ///< How fast to play through the sequence

View file

@ -647,27 +647,27 @@ bool TSShape::importSequences(Stream * s, const String& sequencePath)
nodeUniformScales.increment(newScaleMembership.count() * seq.numKeyframes);
// remap node transforms from temporary arrays
for (S32 j = 0; j < nodeMap.size(); j++)
for (S32 nodeID = 0; nodeID < nodeMap.size(); nodeID++)
{
if (nodeMap[j] < 0)
if (nodeMap[nodeID] < 0)
continue;
if (newTransMembership.test(nodeMap[j]))
if (newTransMembership.test(nodeMap[nodeID]))
{
S32 src = seq.numKeyframes * seq.translationMatters.count(j);
S32 dest = seq.baseTranslation + seq.numKeyframes * newTransMembership.count(nodeMap[j]);
S32 src = seq.numKeyframes * seq.translationMatters.count(nodeID);
S32 dest = seq.baseTranslation + seq.numKeyframes * newTransMembership.count(nodeMap[nodeID]);
dCopyArray(&nodeTranslations[dest], &seqTranslations[src], seq.numKeyframes);
}
if (newRotMembership.test(nodeMap[j]))
if (newRotMembership.test(nodeMap[nodeID]))
{
S32 src = seq.numKeyframes * seq.rotationMatters.count(j);
S32 dest = seq.baseRotation + seq.numKeyframes * newRotMembership.count(nodeMap[j]);
S32 src = seq.numKeyframes * seq.rotationMatters.count(nodeID);
S32 dest = seq.baseRotation + seq.numKeyframes * newRotMembership.count(nodeMap[nodeID]);
dCopyArray(&nodeRotations[dest], &seqRotations[src], seq.numKeyframes);
}
if (newScaleMembership.test(nodeMap[j]))
if (newScaleMembership.test(nodeMap[nodeID]))
{
S32 src = seq.numKeyframes * seq.scaleMatters.count(j);
S32 dest = seq.baseScale + seq.numKeyframes * newScaleMembership.count(nodeMap[j]);
S32 src = seq.numKeyframes * seq.scaleMatters.count(nodeID);
S32 dest = seq.baseScale + seq.numKeyframes * newScaleMembership.count(nodeMap[nodeID]);
if (seq.flags & TSShape::ArbitraryScale)
{
dCopyArray(&nodeArbitraryScaleRots[dest], &seqArbitraryScaleRots[src], seq.numKeyframes);
@ -713,10 +713,10 @@ bool TSShape::importSequences(Stream * s, const String& sequencePath)
S32 oldSz = triggers.size();
s->read(&sz);
triggers.setSize(oldSz+sz);
for (S32 i=0; i<sz;i++)
for (S32 triggerID=0; triggerID<sz; triggerID++)
{
s->read(&triggers[i+oldSz].state);
s->read(&triggers[i+oldSz].pos);
s->read(&triggers[triggerID +oldSz].state);
s->read(&triggers[triggerID +oldSz].pos);
}
if (smInitOnRead)

View file

@ -86,10 +86,10 @@ S32 TSSortedMesh::getNumPolys()
Cluster & cluster = clusters[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
}

View file

@ -71,7 +71,7 @@ public:
void disassemble();
TSSortedMesh() {
meshType = SortedMeshType;
mMeshType = SortedMeshType;
}
};

View file

@ -170,17 +170,17 @@ void TSThread::setSequence(S32 seq, F32 toPos)
sequence = seq;
priority = getSequence()->priority;
pos = toPos;
mSeqPos = toPos;
makePath = getSequence()->makePath();
path.start = path.end = 0;
path.loop = 0;
// 1.0f doesn't exist on cyclic sequences
if (pos>0.9999f && getSequence()->isCyclic())
pos = 0.9999f;
if (mSeqPos>0.9999f && getSequence()->isCyclic())
mSeqPos = 0.9999f;
// select keyframes
selectKeyframes(pos,getSequence(),&keyNum1,&keyNum2,&keyPos);
selectKeyframes(mSeqPos,getSequence(),&keyNum1,&keyNum2,&keyPos);
}
void TSThread::transitionToSequence(S32 seq, F32 toPos, F32 duration, bool continuePlay)
@ -207,7 +207,7 @@ void TSThread::transitionToSequence(S32 seq, F32 toPos, F32 duration, bool conti
// set time characteristics of transition
transitionData.oldSequence = sequence;
transitionData.oldPos = pos;
transitionData.oldPos = mSeqPos;
transitionData.duration = duration;
transitionData.pos = 0.0f;
transitionData.direction = timeScale>0.0f ? 1.0f : -1.0f;
@ -219,17 +219,17 @@ void TSThread::transitionToSequence(S32 seq, F32 toPos, F32 duration, bool conti
// set target sequence data
sequence = seq;
priority = getSequence()->priority;
pos = toPos;
mSeqPos = toPos;
makePath = getSequence()->makePath();
path.start = path.end = 0;
path.loop = 0;
// 1.0f doesn't exist on cyclic sequences
if (pos>0.9999f && getSequence()->isCyclic())
pos = 0.9999f;
if (mSeqPos>0.9999f && getSequence()->isCyclic())
mSeqPos = 0.9999f;
// select keyframes
selectKeyframes(pos,getSequence(),&keyNum1,&keyNum2,&keyPos);
selectKeyframes(mSeqPos,getSequence(),&keyNum1,&keyNum2,&keyPos);
}
bool TSThread::isInTransition()
@ -322,12 +322,12 @@ void TSThread::activateTriggers(F32 a, F32 b)
F32 TSThread::getPos()
{
return transitionData.inTransition ? transitionData.pos : pos;
return transitionData.inTransition ? transitionData.pos : mSeqPos;
}
F32 TSThread::getTime()
{
return transitionData.inTransition ? transitionData.pos * transitionData.duration : pos * getSequence()->duration;
return transitionData.inTransition ? transitionData.pos * transitionData.duration : mSeqPos * getSequence()->duration;
}
F32 TSThread::getDuration()
@ -378,48 +378,48 @@ void TSThread::advancePos(F32 delta)
if (makePath)
{
path.start = pos;
pos += delta;
path.start = mSeqPos;
mSeqPos += delta;
if (!getSequence()->isCyclic())
{
pos = mClampF(pos , 0.0f, 1.0f);
mSeqPos = mClampF(mSeqPos, 0.0f, 1.0f);
path.loop = 0;
}
else
{
path.loop = (S32)pos;
if (pos < 0.0f)
path.loop = (S32)mSeqPos;
if (mSeqPos < 0.0f)
path.loop--;
pos -= path.loop;
mSeqPos -= path.loop;
// following necessary because of floating point roundoff errors
if (pos < 0.0f) pos += 1.0f;
if (pos >= 1.0f) pos -= 1.0f;
if (mSeqPos < 0.0f) mSeqPos += 1.0f;
if (mSeqPos >= 1.0f) mSeqPos -= 1.0f;
}
path.end = pos;
path.end = mSeqPos;
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(mSeqPos >=0.0f && mSeqPos <=1.0f,"TSThread::advancePos (1)");
AssertFatal(!getSequence()->isCyclic() || mSeqPos<1.0f,"TSThread::advancePos (2)");
}
else
{
pos += delta;
mSeqPos += delta;
if (!getSequence()->isCyclic())
pos = mClampF(pos, 0.0f, 1.0f);
mSeqPos = mClampF(mSeqPos, 0.0f, 1.0f);
else
{
pos -= S32(pos);
mSeqPos -= S32(mSeqPos);
// following necessary because of floating point roundoff errors
if (pos < 0.0f) pos += 1.0f;
if (pos >= 1.0f) pos -= 1.0f;
if (mSeqPos < 0.0f) mSeqPos += 1.0f;
if (mSeqPos >= 1.0f) mSeqPos -= 1.0f;
}
AssertFatal(pos>=0.0f && pos<=1.0f,"TSThread::advancePos (3)");
AssertFatal(!getSequence()->isCyclic() || pos<1.0f,"TSThread::advancePos (4)");
AssertFatal(mSeqPos >=0.0f && mSeqPos <=1.0f,"TSThread::advancePos (3)");
AssertFatal(!getSequence()->isCyclic() || mSeqPos<1.0f,"TSThread::advancePos (4)");
}
// select keyframes
selectKeyframes(pos,getSequence(),&keyNum1,&keyNum2,&keyPos);
selectKeyframes(mSeqPos,getSequence(),&keyNum1,&keyNum2,&keyPos);
}
void TSThread::advanceTime(F32 delta)
@ -459,7 +459,7 @@ void TSThread::setKeyframeNumber(S32 kf)
keyNum1 = keyNum2 = kf;
keyPos = 0;
pos = 0;
mSeqPos = 0;
}
TSThread::TSThread(TSShapeInstance * _shapeInst)