Revert recent style cleanup changes.

This commit is contained in:
Daniel Buckmaster 2015-03-04 11:55:30 +11:00
parent a73850a4bb
commit 84e8cbb4ee
62 changed files with 3380 additions and 3380 deletions

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->mWrapU)
if (effectExt->wrapU)
flags |= TSMaterialList::S_Wrap;
if (effectExt->mWrapV)
if (effectExt->wrapV)
flags |= TSMaterialList::T_Wrap;
// Set material attributes
@ -146,17 +146,17 @@ ColladaAppMaterial::ColladaAppMaterial(const domMaterial *pMat)
}
// Double-sided flag
doubleSided = effectExt->mDoubleSided;
doubleSided = effectExt->double_sided;
// 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->mBumpSampler);
normalMap = getSamplerImagePath(effect, effectExt->bumpSampler);
// Set the material name
name = ColladaUtils::getOptions().mMatNamePrefix;
if ( ColladaUtils::getOptions().mUseDiffuseNames )
name = ColladaUtils::getOptions().matNamePrefix;
if ( ColladaUtils::getOptions().useDiffuseNames )
{
Torque::Path diffusePath( diffuseMap );
name += diffusePath.getFileName();

View file

@ -40,8 +40,8 @@ namespace DictHash
using namespace ColladaUtils;
bool ColladaAppMesh::mFixedSizeEnabled = false;
S32 ColladaAppMesh::mFixedSize = 2;
bool ColladaAppMesh::fixedSizeEnabled = false;
S32 ColladaAppMesh::fixedSize = 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.mVertex;
return (U32)data.vertex;
}
}
@ -197,27 +197,27 @@ private:
public:
_SourceReader mPoints;
_SourceReader mNormals;
_SourceReader mColors;
_SourceReader mUVs;
_SourceReader mUV2s;
_SourceReader points;
_SourceReader normals;
_SourceReader colors;
_SourceReader uvs;
_SourceReader uv2s;
_SourceReader mJoints;
_SourceReader mWeights;
_SourceReader mInvBindMatrices;
_SourceReader joints;
_SourceReader weights;
_SourceReader invBindMatrices;
/// Clear the mesh streams
void reset()
{
mPoints.reset();
mNormals.reset();
mColors.reset();
mUVs.reset();
mUV2s.reset();
mJoints.reset();
mWeights.reset();
mInvBindMatrices.reset();
points.reset();
normals.reset();
colors.reset();
uvs.reset();
uv2s.reset();
joints.reset();
weights.reset();
invBindMatrices.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, mPoints, vertex_params);
initSourceReader(sortedInputs[Points], Points, points, vertex_params);
const char* normal_params[] = { "X", "Y", "Z", "" };
initSourceReader(sortedInputs[Normals], Normals, mNormals, normal_params);
initSourceReader(sortedInputs[Normals], Normals, normals, normal_params);
const char* color_params[] = { "R", "G", "B", "A", "" };
initSourceReader(sortedInputs[Colors], Colors, mColors, color_params);
initSourceReader(sortedInputs[Colors], Colors, colors, 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, 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);
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);
const char* joint_params[] = { "JOINT", "" };
initSourceReader(sortedInputs[Joints], Joints, mJoints, joint_params);
initSourceReader(sortedInputs[Joints], Joints, joints, joint_params);
const char* weight_params[] = { "WEIGHT", "" };
initSourceReader(sortedInputs[Weights], Weights, mWeights, weight_params);
initSourceReader(sortedInputs[Weights], Weights, weights, weight_params);
const char* matrix_params[] = { "TRANSFORM", "" };
initSourceReader(sortedInputs[InvBindMatrices], InvBindMatrices, mInvBindMatrices, matrix_params);
initSourceReader(sortedInputs[InvBindMatrices], InvBindMatrices, invBindMatrices, matrix_params);
return true;
}
@ -317,19 +317,19 @@ public:
//------------------------------------------------------------------------------
ColladaAppMesh::ColladaAppMesh(const domInstance_geometry* instance, ColladaAppNode* node)
: mInstanceGeom(instance), mInstanceCtrl(0), mAppNode(node), mGeomExt(0)
: instanceGeom(instance), instanceCtrl(0), appNode(node), geomExt(0)
{
mFlags = 0;
mNumFrames = 0;
mNumMatFrames = 0;
flags = 0;
numFrames = 0;
numMatFrames = 0;
}
ColladaAppMesh::ColladaAppMesh(const domInstance_controller* instance, ColladaAppNode* node)
: mInstanceGeom(0), mInstanceCtrl(instance), mAppNode(node), mGeomExt(0)
: instanceGeom(0), instanceCtrl(instance), appNode(node), geomExt(0)
{
mFlags = 0;
mNumFrames = 0;
mNumMatFrames = 0;
flags = 0;
numFrames = 0;
numMatFrames = 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 = mAppNode->getName();
const char* nodeName = appNode->getName();
if ( dStrEqual(nodeName, "null") || dStrEndsWith(nodeName, "PIVOT") )
nodeName = mAppNode->getParentName();
nodeName = appNode->getParentName();
// If all geometry is being fixed to the same size, append the size
// to the name
return allowFixed && mFixedSizeEnabled ? avar("%s %d", nodeName, mFixedSize) : nodeName;
return allowFixed && fixedSizeEnabled ? avar("%s %d", nodeName, fixedSize) : nodeName;
}
MatrixF ColladaAppMesh::getMeshTransform(F32 time)
{
return mAppNode->getNodeTransform(time);
return appNode->getNodeTransform(time);
}
bool ColladaAppMesh::animatesVis(const AppSequence* appSeq)
{
#define IS_VIS_ANIMATED(node) \
(dynamic_cast<const ColladaAppNode*>(node)->nodeExt->mVisibility.isAnimated(appSeq->getStart(), appSeq->getEnd()))
(dynamic_cast<const ColladaAppNode*>(node)->nodeExt->visibility.isAnimated(appSeq->getStart(), appSeq->getEnd()))
// Check if the node visibility is animated within the sequence interval
return IS_VIS_ANIMATED(mAppNode) || (mAppNode->appParent ? IS_VIS_ANIMATED(mAppNode->appParent) : false);
return IS_VIS_ANIMATED(appNode) || (appNode->appParent ? IS_VIS_ANIMATED(appNode->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 < mAppMaterials.size(); iMat++) {
ColladaAppMaterial* appMat = static_cast<ColladaAppMaterial*>(mAppMaterials[iMat]);
for (S32 iMat = 0; iMat < appMaterials.size(); iMat++) {
ColladaAppMaterial* appMat = static_cast<ColladaAppMaterial*>(appMaterials[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->mVisibility.getValue(t))
(dynamic_cast<const ColladaAppNode*>(node)->nodeExt->visibility.getValue(t))
// Get the visibility of the mesh's node at time, 't'
return GET_VIS(mAppNode) * (mAppNode->appParent ? GET_VIS(mAppNode->appParent) : 1.0f);
return GET_VIS(appNode) * (appNode->appParent ? GET_VIS(appNode->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 = mBoundMaterials.find(symbol);
if (itr != mBoundMaterials.end())
Map<StringTableEntry,U32>::Iterator itr = boundMaterials.find(symbol);
if (itr != boundMaterials.end())
return itr->value;
// Find the Collada material that this symbol maps to
U32 matIndex = TSDrawPrimitive::NoMaterial;
const domBind_material* binds = mInstanceGeom ? mInstanceGeom->getBind_material() :
mInstanceCtrl->getBind_material();
const domBind_material* binds = instanceGeom ? instanceGeom->getBind_material() :
instanceCtrl->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 < mAppMaterials.size(); matIndex++) {
if (static_cast<ColladaAppMaterial*>(mAppMaterials[matIndex])->mat == mat)
for (matIndex = 0; matIndex < appMaterials.size(); matIndex++) {
if (static_cast<ColladaAppMaterial*>(appMaterials[matIndex])->mat == mat)
break;
}
// Check if this material needs to be added to the shape global list
if (matIndex == mAppMaterials.size()) {
if (matIndex == appMaterials.size()) {
if (mat)
mAppMaterials.push_back(new ColladaAppMaterial(mat));
appMaterials.push_back(new ColladaAppMaterial(mat));
else
mAppMaterials.push_back(new ColladaAppMaterial(symbol));
appMaterials.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
mAppMaterials.push_back(new ColladaAppMaterial(symbol));
appMaterials.push_back(new ColladaAppMaterial(symbol));
}
// Add this symbol to the bound list for the mesh
mBoundMaterials.insert(StringTable->insert(symbol), matIndex);
boundMaterials.insert(StringTable->insert(symbol), matIndex);
return matIndex;
}
void ColladaAppMesh::getPrimitives(const domGeometry* geometry)
{
// Only do this once
if (mPrimitives.size())
if (primitives.size())
return;
// Read the <geometry> extension
if (!mGeomExt)
mGeomExt = new ColladaExtension_geometry(geometry);
if (!geomExt)
geomExt = 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
mPrimitives.increment();
TSDrawPrimitive& primitive = mPrimitives.last();
primitive.start = mIndices.size();
primitives.increment();
TSDrawPrimitive& primitive = primitives.last();
primitive.start = indices.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*>(mAppMaterials[primitive.matIndex & TSDrawPrimitive::MaterialMask]);
appMat = static_cast<ColladaAppMaterial*>(appMaterials[primitive.matIndex & TSDrawPrimitive::MaterialMask]);
// Force the material to be double-sided if this geometry is double-sided.
if (mGeomExt->mDoubleSided && appMat && appMat->effectExt)
appMat->effectExt->mDoubleSided = true;
if (geomExt->double_sided && appMat && appMat->effectExt)
appMat->effectExt->double_sided = true;
// Pre-allocate triangle indices
primitive.numElements = numTriangles * 3;
mIndices.setSize(mIndices.size() + primitive.numElements);
U32* dstIndex = mIndices.end() - primitive.numElements;
indices.setSize(indices.size() + primitive.numElements);
U32* dstIndex = indices.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 (mVertTuples.size() &&
(((mVertTuples.size()-1) ^ (mVertTuples.size()+2)) & 0x10000))
if (vertTuples.size() &&
(((vertTuples.size()-1) ^ (vertTuples.size()+2)) & 0x10000))
{
// Pad vertTuples up to the next 16-bit boundary
while (mVertTuples.size() & 0xFFFF)
mVertTuples.push_back(VertTuple(mVertTuples.last()));
while (vertTuples.size() & 0xFFFF)
vertTuples.push_back(VertTuple(vertTuples.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)));
mPrimitives.last().numElements -= indicesRemaining;
mPrimitives.push_back(TSDrawPrimitive(mPrimitives.last()));
primitives.last().numElements -= indicesRemaining;
primitives.push_back(TSDrawPrimitive(primitives.last()));
}
mPrimitives.last().numElements = indicesRemaining;
mPrimitives.last().start = mIndices.size() - indicesRemaining;
primitives.last().numElements = indicesRemaining;
primitives.last().start = indices.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.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.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.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;
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;
VertTupleMap::Iterator itr = tupleMap.find(tuple);
if (itr == tupleMap.end())
{
itr = tupleMap.insert(tuple, mVertTuples.size());
mVertTuples.push_back(tuple);
itr = tupleMap.insert(tuple, vertTuples.size());
vertTuples.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 (mAppNode->invertMeshes)
if (appNode->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 (!mPrimitives.size())
if (!primitives.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() + mVertTuples.size());
v_uvs.setSize(v_uvs.size() + mVertTuples.size());
v_points.setSize(v_points.size() + vertTuples.size());
v_uvs.setSize(v_uvs.size() + vertTuples.size());
}
// Get pointers to arrays
Point3F* points_array = &v_points[v_points.size() - mVertTuples.size()];
Point2F* uvs_array = &v_uvs[v_uvs.size() - mVertTuples.size()];
Point3F* points_array = &v_points[v_points.size() - vertTuples.size()];
Point2F* uvs_array = &v_uvs[v_uvs.size() - vertTuples.size()];
Point3F* norms_array = NULL;
ColorI* colors_array = NULL;
Point2F* uv2s_array = NULL;
for (S32 iVert = 0; iVert < mVertTuples.size(); iVert++) {
for (S32 iVert = 0; iVert < vertTuples.size(); iVert++) {
const VertTuple& tuple = mVertTuples[iVert];
const VertTuple& tuple = vertTuples[iVert];
// Change primitives?
if (tuple.mPrim != lastPrimitive) {
if (meshPrims.size() <= tuple.mPrim) {
if (tuple.prim != lastPrimitive) {
if (meshPrims.size() <= tuple.prim) {
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.mPrim]->getInputs());
S32 matIndex = addMaterial(meshPrims[tuple.mPrim]->getMaterial());
streams.readInputs(meshPrims[tuple.prim]->getInputs());
S32 matIndex = addMaterial(meshPrims[tuple.prim]->getMaterial());
if (matIndex != TSDrawPrimitive::NoMaterial)
appMat = static_cast<ColladaAppMaterial*>(mAppMaterials[matIndex]);
appMat = static_cast<ColladaAppMaterial*>(appMaterials[matIndex]);
else
appMat = 0;
lastPrimitive = tuple.mPrim;
lastPrimitive = tuple.prim;
}
// If we are NOT appending values, only set the value if it actually exists
// in the mesh data stream.
if (appendValues || ((tuple.mVertex >= 0) && (tuple.mVertex < streams.mPoints.size()))) {
points_array[iVert] = streams.mPoints.getPoint3FValue(tuple.mVertex);
if (appendValues || ((tuple.vertex >= 0) && (tuple.vertex < streams.points.size()))) {
points_array[iVert] = streams.points.getPoint3FValue(tuple.vertex);
// Flip verts for inverted meshes
if (mAppNode->invertMeshes)
if (appNode->invertMeshes)
points_array[iVert].z = -points_array[iVert].z;
objOffset.mulP(points_array[iVert]);
}
if (appendValues || ((tuple.mUV >= 0) && (tuple.mUV < streams.mUVs.size()))) {
uvs_array[iVert] = streams.mUVs.getPoint2FValue(tuple.mUV);
if (appendValues || ((tuple.uv >= 0) && (tuple.uv < streams.uvs.size()))) {
uvs_array[iVert] = streams.uvs.getPoint2FValue(tuple.uv);
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.mNormal >= 0) && (tuple.mNormal < streams.mNormals.size()) ) {
if ( (tuple.normal >= 0) && (tuple.normal < streams.normals.size()) ) {
if ( !norms_array && iVert == 0 )
{
v_norms.setSize(v_norms.size() + mVertTuples.size());
norms_array = &v_norms[v_norms.size() - mVertTuples.size()];
v_norms.setSize(v_norms.size() + vertTuples.size());
norms_array = &v_norms[v_norms.size() - vertTuples.size()];
}
if ( norms_array ) {
norms_array[iVert] = streams.mNormals.getPoint3FValue(tuple.mNormal);
norms_array[iVert] = streams.normals.getPoint3FValue(tuple.normal);
// Flip normals for inverted meshes
if (mAppNode->invertMeshes)
if (appNode->invertMeshes)
norms_array[iVert].z = -norms_array[iVert].z;
}
}
if ( (tuple.mColor >= 0) && (tuple.mColor < streams.mColors.size()))
if ( (tuple.color >= 0) && (tuple.color < streams.colors.size()))
{
if ( !colors_array && iVert == 0 )
{
v_colors.setSize(v_colors.size() + mVertTuples.size());
colors_array = &v_colors[v_colors.size() - mVertTuples.size()];
v_colors.setSize(v_colors.size() + vertTuples.size());
colors_array = &v_colors[v_colors.size() - vertTuples.size()];
}
if ( colors_array )
colors_array[iVert] = streams.mColors.getColorIValue(tuple.mColor);
colors_array[iVert] = streams.colors.getColorIValue(tuple.color);
}
if ( (tuple.mUV2 >= 0) && (tuple.mUV2 < streams.mUV2s.size()) )
if ( (tuple.uv2 >= 0) && (tuple.uv2 < streams.uv2s.size()) )
{
if ( !uv2s_array && iVert == 0 )
{
v_uv2s.setSize(v_uv2s.size() + mVertTuples.size());
uv2s_array = &v_uv2s[v_uv2s.size() - mVertTuples.size()];
v_uv2s.setSize(v_uv2s.size() + vertTuples.size());
uv2s_array = &v_uv2s[v_uv2s.size() - vertTuples.size()];
}
if ( uv2s_array )
{
uv2s_array[iVert] = streams.mUV2s.getPoint2FValue(tuple.mUV2);
uv2s_array[iVert] = streams.uv2s.getPoint2FValue(tuple.uv2);
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() - 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;
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;
// 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 < mVertTuples.size(); iVert++) {
for (S32 iVert = 0; iVert < vertTuples.size(); iVert++) {
points_array[iVert] *= weightSum;
norms_array[iVert] *= weightSum;
uvs_array[iVert] *= weightSum;
}
if (uv2s_array) {
for (S32 iVert = 0; iVert < mVertTuples.size(); iVert++)
for (S32 iVert = 0; iVert < vertTuples.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, mVertTuples.size());
targetNorms.set(norms_array, mVertTuples.size());
targetUvs.set(uvs_array, mVertTuples.size());
targetPoints.set(points_array, vertTuples.size());
targetNorms.set(norms_array, vertTuples.size());
targetUvs.set(uvs_array, vertTuples.size());
if (colors_array)
targetColors.set(colors_array, mVertTuples.size());
targetColors.set(colors_array, vertTuples.size());
if (uv2s_array)
targetUv2s.set(uv2s_array, mVertTuples.size());
targetUv2s.set(uv2s_array, vertTuples.size());
getVertexData(targetGeoms[iTarget], time, objOffset, targetPoints, targetNorms, targetColors, targetUvs, targetUv2s, false);
// Combine with base geometry
for (S32 iVert = 0; iVert < mVertTuples.size(); iVert++) {
for (S32 iVert = 0; iVert < vertTuples.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 < mVertTuples.size(); iVert++)
for (S32 iVert = 0; iVert < vertTuples.size(); iVert++)
uv2s_array[iVert] += targetUv2s[iVert] * targetWeights[iTarget];
}
if (colors_array) {
for (S32 iVert = 0; iVert < mVertTuples.size(); iVert++)
for (S32 iVert = 0; iVert < vertTuples.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 (mInstanceGeom) {
if (instanceGeom) {
// Simple, static mesh
geometry = mInstanceGeom->getUrl().getElement();
geometry = instanceGeom->getUrl().getElement();
}
else if (mInstanceCtrl) {
const domController* ctrl = daeSafeCast<domController>(mInstanceCtrl->getUrl().getElement());
else if (instanceCtrl) {
const domController* ctrl = daeSafeCast<domController>(instanceCtrl->getUrl().getElement());
if (!ctrl) {
daeErrorHandler::get()->handleWarning(avar("Failed to find <controller> "
"element for %s", getName()));
@ -923,10 +923,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, mPoints, mNormals, mColors, mUVs, mUV2s, true);
getVertexData(daeSafeCast<domGeometry>(geometry), t, objOffset, points, normals, colors, uvs, uv2s, true);
}
else if (geometry->getElementType() == COLLADA_TYPE::MORPH) {
getMorphVertexData(daeSafeCast<domMorph>(geometry), t, objOffset, mPoints, mNormals, mColors, mUVs, mUV2s);
getMorphVertexData(daeSafeCast<domMorph>(geometry), t, objOffset, points, normals, colors, uvs, uv2s);
}
else {
daeErrorHandler::get()->handleWarning(avar("Unsupported geometry type "
@ -937,11 +937,11 @@ void ColladaAppMesh::lockMesh(F32 t, const MatrixF& objOffset)
void ColladaAppMesh::lookupSkinData()
{
// Only lookup skin data once
if (!isSkin() || mWeight.size())
if (!isSkin() || weight.size())
return;
// Get the skin and vertex weight data
const domSkin* skin = daeSafeCast<domController>(mInstanceCtrl->getUrl().getElement())->getSkin();
const domSkin* skin = daeSafeCast<domController>(instanceCtrl->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 +950,7 @@ void ColladaAppMesh::lookupSkinData()
streams.readInputs(skin->getJoints()->getInput_array());
streams.readInputs(weightIndices.getInput_array());
MatrixF invObjOffset(mObjectOffset);
MatrixF invObjOffset(objectOffset);
invObjOffset.inverse();
// Get the bind shape matrix
@ -971,17 +971,17 @@ void ColladaAppMesh::lookupSkinData()
// Set vertex weights
bool tooManyWeightsWarning = false;
for (S32 iVert = 0; iVert < mVertsPerFrame; iVert++) {
for (S32 iVert = 0; iVert < vertsPerFrame; iVert++) {
const domUint* vcount = (domUint*)weights_vcount.getRaw(0);
const domInt* vindices = (domInt*)weights_v.getRaw(0);
vindices += vindicesOffset[mVertTuples[iVert].mVertex];
vindices += vindicesOffset[vertTuples[iVert].vertex];
S32 nonZeroWeightCount = 0;
for (S32 iWeight = 0; iWeight < vcount[mVertTuples[iVert].mVertex]; iWeight++) {
for (S32 iWeight = 0; iWeight < vcount[vertTuples[iVert].vertex]; iWeight++) {
S32 bIndex = vindices[iWeight*2];
F32 bWeight = streams.mWeights.getFloatValue( vindices[iWeight*2 + 1] );
F32 bWeight = streams.weights.getFloatValue( vindices[iWeight*2 + 1] );
// Ignore empty weights
if ( bIndex < 0 || bWeight == 0 )
@ -990,7 +990,7 @@ void ColladaAppMesh::lookupSkinData()
// Limit the number of weights per bone (keep the N largest influences)
if ( nonZeroWeightCount >= TSSkinMesh::BatchData::maxBonePerVert )
{
if (vcount[mVertTuples[iVert].mVertex] > TSSkinMesh::BatchData::maxBonePerVert)
if (vcount[vertTuples[iVert].vertex] > TSSkinMesh::BatchData::maxBonePerVert)
{
if (!tooManyWeightsWarning)
{
@ -1002,25 +1002,25 @@ void ColladaAppMesh::lookupSkinData()
}
// Too many weights => find and replace the smallest one
S32 minIndex = mWeight.size() - TSSkinMesh::BatchData::maxBonePerVert;
F32 minWeight = mWeight[minIndex];
for (S32 i = minIndex + 1; i < mWeight.size(); i++)
S32 minIndex = weight.size() - TSSkinMesh::BatchData::maxBonePerVert;
F32 minWeight = weight[minIndex];
for (S32 i = minIndex + 1; i < weight.size(); i++)
{
if (mWeight[i] < minWeight)
if (weight[i] < minWeight)
{
minWeight = mWeight[i];
minWeight = weight[i];
minIndex = i;
}
}
mBoneIndex[minIndex] = bIndex;
mWeight[minIndex] = bWeight;
boneIndex[minIndex] = bIndex;
weight[minIndex] = bWeight;
}
else
{
mVertexIndex.push_back( iVert );
mBoneIndex.push_back( bIndex );
mWeight.push_back( bWeight );
vertexIndex.push_back( iVert );
boneIndex.push_back( bIndex );
weight.push_back( bWeight );
nonZeroWeightCount++;
}
}
@ -1028,36 +1028,36 @@ void ColladaAppMesh::lookupSkinData()
// Normalize vertex weights (force weights for each vert to sum to 1)
S32 iWeight = 0;
while (iWeight < mWeight.size()) {
while (iWeight < weight.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 < mWeight.size(); iLast++) {
if (mVertexIndex[iLast] != mVertexIndex[iWeight])
for (iLast = iWeight; iLast < weight.size(); iLast++) {
if (vertexIndex[iLast] != vertexIndex[iWeight])
break;
invTotalWeight += mWeight[iLast];
invTotalWeight += weight[iLast];
}
// Then normalize the vertex weights
invTotalWeight = 1.0f / invTotalWeight;
for (; iWeight < iLast; iWeight++)
mWeight[iWeight] *= invTotalWeight;
weight[iWeight] *= invTotalWeight;
}
// Add dummy AppNodes to allow Collada joints to be mapped to 3space nodes
mBones.setSize(streams.mJoints.size());
mInitialTransforms.setSize(streams.mJoints.size());
for (S32 iJoint = 0; iJoint < streams.mJoints.size(); iJoint++)
bones.setSize(streams.joints.size());
initialTransforms.setSize(streams.joints.size());
for (S32 iJoint = 0; iJoint < streams.joints.size(); iJoint++)
{
const char* jointName = streams.mJoints.getStringValue(iJoint);
const char* jointName = streams.joints.getStringValue(iJoint);
// Lookup the joint element
const domNode* joint = 0;
if (mInstanceCtrl->getSkeleton_array().getCount()) {
if (instanceCtrl->getSkeleton_array().getCount()) {
// Search for the node using the <skeleton> as the base element
for (S32 iSkel = 0; iSkel < mInstanceCtrl->getSkeleton_array().getCount(); iSkel++) {
xsAnyURI skeleton = mInstanceCtrl->getSkeleton_array()[iSkel]->getValue();
for (S32 iSkel = 0; iSkel < instanceCtrl->getSkeleton_array().getCount(); iSkel++) {
xsAnyURI skeleton = instanceCtrl->getSkeleton_array()[iSkel]->getValue();
daeSIDResolver resolver(skeleton.getElement(), jointName);
joint = daeSafeCast<domNode>(resolver.getElement());
if (joint)
@ -1072,33 +1072,33 @@ void ColladaAppMesh::lookupSkinData()
if (!joint) {
daeErrorHandler::get()->handleWarning(avar("Failed to find bone '%s', "
"defaulting to instance_controller parent node '%s'", jointName, mAppNode->getName()));
joint = mAppNode->getDomNode();
"defaulting to instance_controller parent node '%s'", jointName, appNode->getName()));
joint = appNode->getDomNode();
}
mBones[iJoint] = new ColladaAppNode(joint);
bones[iJoint] = new ColladaAppNode(joint);
mInitialTransforms[iJoint] = mObjectOffset;
initialTransforms[iJoint] = objectOffset;
// 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.mInvBindMatrices.getMatrixFValue(iJoint);
if (!ColladaUtils::getOptions().mIgnoreNodeScale)
MatrixF invBind = streams.invBindMatrices.getMatrixFValue(iJoint);
if (!ColladaUtils::getOptions().ignoreNodeScale)
{
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;
mInitialTransforms[iJoint].scale(invScale);
initialTransforms[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)
mInitialTransforms[iJoint].scale(Point3F(1, 1, -1));
initialTransforms[iJoint].scale(Point3F(1, 1, -1));
mInitialTransforms[iJoint].mul(invBind);
mInitialTransforms[iJoint].mul(bindShapeMatrix);
initialTransforms[iJoint].mul(invBind);
initialTransforms[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 mPrim, mVertex, mNormal, mColor, mUV, mUV2;
S32 prim, vertex, normal, color, uv, uv2;
Point3F mDataVertex, mDataNormal;
ColorI mDataColor;
Point2F mDataUV, mDataUV2;
Point3F dataVertex, dataNormal;
ColorI dataColor;
Point2F dataUV, dataUV2;
VertTuple(): mPrim(-1), mVertex(-1), mNormal(-1), mColor(-1), mUV(-1), mUV2(-1) {}
VertTuple(): prim(-1), vertex(-1), normal(-1), color(-1), uv(-1), uv2(-1) {}
bool operator==(const VertTuple& p) const
{
return mDataVertex == p.mDataVertex &&
mDataColor == p.mDataColor &&
mDataNormal == p.mDataNormal &&
mDataUV == p.mDataUV &&
mDataUV2 == p.mDataUV2;
return dataVertex == p.dataVertex &&
dataColor == p.dataColor &&
dataNormal == p.dataNormal &&
dataUV == p.dataUV &&
dataUV2 == p.dataUV2;
}
};
@ -79,24 +79,24 @@ class ColladaAppMesh : public AppMesh
typedef AppMesh Parent;
protected:
class ColladaAppNode* mAppNode; ///< Pointer to the node that owns this mesh
const domInstance_geometry* mInstanceGeom;
const domInstance_controller* mInstanceCtrl;
ColladaExtension_geometry* mGeomExt; ///< geometry extension
class ColladaAppNode* appNode; ///< Pointer to the node that owns this mesh
const domInstance_geometry* instanceGeom;
const domInstance_controller* instanceCtrl;
ColladaExtension_geometry* geomExt; ///< geometry extension
Vector<VertTuple> mVertTuples; ///<
Map<StringTableEntry,U32> mBoundMaterials; ///< Local map of symbols to materials
Vector<VertTuple> vertTuples; ///<
Map<StringTableEntry,U32> boundMaterials; ///< Local map of symbols to materials
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
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
//-----------------------------------------------------------------------
/// Get the morph controller for this mesh (if any)
const domMorph* getMorph()
{
if (mInstanceCtrl) {
const domController* ctrl = daeSafeCast<domController>(mInstanceCtrl->getUrl().getElement());
if (instanceCtrl) {
const domController* ctrl = daeSafeCast<domController>(instanceCtrl->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 mGeomExt;
delete geomExt;
}
static void fixDetailSize(bool fixed, S32 size=2)
{
mFixedSizeEnabled = fixed;
mFixedSize = size;
fixedSizeEnabled = fixed;
fixedSize = 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 mAppNode->getFloat(propName,defaultVal);
return appNode->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 mAppNode->getInt(propName,defaultVal);
return appNode->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 mAppNode->getBool(propName,defaultVal);
return appNode->getBool(propName,defaultVal);
}
/// Return true if this mesh is a skin
bool isSkin()
{
if (mInstanceCtrl) {
const domController* ctrl = daeSafeCast<domController>(mInstanceCtrl->getUrl().getElement());
if (instanceCtrl) {
const domController* ctrl = daeSafeCast<domController>(instanceCtrl->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::smDefaultTime-1), defaultTransformValid(false),
lastTransformTime(TSShapeLoader::DefaultTime-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->mUserProperties);
char* properties = dStrdup(nodeExt->user_properties);
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().mElement = node->getContents()[iChild];
nodeTransforms.last().element = 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::smDefaultTime)
if (defaultTransformValid && time == TSShapeLoader::DefaultTime)
{
return defaultNodeTransform;
}
@ -198,7 +198,7 @@ MatrixF ColladaAppNode::getNodeTransform(F32 time)
}
// Cache the default transform
if (time == TSShapeLoader::smDefaultTime)
if (time == TSShapeLoader::DefaultTime)
{
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().mUnit);
lastTransform.scale(ColladaUtils::getOptions().unit);
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].mElement->getElementType()) {
switch (nodeTransforms[iTxfm].element->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().mIgnoreNodeScale)
if (ColladaUtils::getOptions().ignoreNodeScale)
{
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->mTriggers.size();
return clipExt->triggers.size();
}
void ColladaAppSequence::getTrigger(S32 index, TSShape::Trigger& trigger)
{
trigger.pos = clipExt->mTriggers[index].time;
trigger.state = clipExt->mTriggers[index].state;
trigger.pos = clipExt->triggers[index].time;
trigger.state = clipExt->triggers[index].state;
}
U32 ColladaAppSequence::getFlags() const
{
U32 flags = 0;
if (clipExt->mCyclic) flags |= TSShape::Cyclic;
if (clipExt->mBlend) flags |= TSShape::Blend;
if (clipExt->cyclic) flags |= TSShape::Cyclic;
if (clipExt->blend) flags |= TSShape::Blend;
return flags;
}
F32 ColladaAppSequence::getPriority()
{
return clipExt->mPriority;
return clipExt->priority;
}
F32 ColladaAppSequence::getBlendRefTime()
{
return clipExt->mBlendReferenceTime;
return clipExt->blendReferenceTime;
}
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->mEnabled = active;
animData->enabled = active;
}
// Recurse into child animations

View file

@ -29,10 +29,10 @@
/// the interval
bool ColladaExtension_effect::animatesTextureTransform(F32 start, F32 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);
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);
}
/// 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 != mLastAnimTime) {
if (time != lastAnimTime) {
// Update texture transform
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(),
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(),
0));
mTextureTransform.scale(Point3F(mRepeatU.getValue(time), mRepeatV.getValue(time), 1.0f));
textureTransform.scale(Point3F(repeatU.getValue(time), repeatV.getValue(time), 1.0f));
mLastAnimTime = time;
lastAnimTime = time;
}
// Apply texture transform
Point3F result;
mTextureTransform.mulP(Point3F(uv.x, uv.y, 0), &result);
textureTransform.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* mTechnique;
const domTechnique* pTechnique;
/// 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 (mTechnique) {
if (pTechnique) {
// search the technique contents for the desired parameter
for (S32 iParam = 0; iParam < mTechnique->getContents().getCount(); iParam++) {
const domAny* param = daeSafeCast<domAny>(mTechnique->getContents()[iParam]);
for (S32 iParam = 0; iParam < pTechnique->getContents().getCount(); iParam++) {
const domAny* param = daeSafeCast<domAny>(pTechnique->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.mDefaultVal = defaultVal;
value.defaultVal = defaultVal;
if (const domAny* param = findParam(name))
value.mElement = param;
value.element = param;
}
public:
ColladaExtension() : mTechnique(0) { }
ColladaExtension() : pTechnique(0) { }
virtual ~ColladaExtension() { }
};
@ -122,14 +122,14 @@ public:
class ColladaExtension_effect : public ColladaExtension
{
// Cached texture transform
F32 mLastAnimTime;
MatrixF mTextureTransform;
F32 lastAnimTime;
MatrixF textureTransform;
public:
//----------------------------------
// <effect>
// MAX3D profile elements
bool mDoubleSided;
bool double_sided;
//----------------------------------
// <effect>.<profile_COMMON>
@ -139,39 +139,39 @@ public:
//----------------------------------
// <effect>.<profile_COMMON>.<technique>.<blinn/phong/lambert>.<diffuse>.<texture>
// MAYA profile elements
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;
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;
//----------------------------------
// <effect>.<profile_COMMON>.<technique>
// FCOLLADA profile elements
domFx_sampler2D_common_complexType* mBumpSampler;
domFx_sampler2D_common_complexType* bumpSampler;
public:
ColladaExtension_effect(const domEffect* effect)
: mLastAnimTime(TSShapeLoader::smDefaultTime-1), mTextureTransform(true), mBumpSampler(0)
: lastAnimTime(TSShapeLoader::DefaultTime-1), textureTransform(true), bumpSampler(0)
{
//----------------------------------
// <effect>
// MAX3D profile
mTechnique = findExtraTechnique(effect, "MAX3D");
GET_EXTRA_PARAM(mDoubleSided, false);
pTechnique = findExtraTechnique(effect, "MAX3D");
GET_EXTRA_PARAM(double_sided, false);
//----------------------------------
// <effect>.<profile_COMMON>
const domProfile_COMMON* profileCommon = ColladaUtils::findEffectCommonProfile(effect);
// GOOGLEEARTH profile (same double_sided element)
mTechnique = findExtraTechnique(profileCommon, "GOOGLEEARTH");
GET_EXTRA_PARAM(mDoubleSided, mDoubleSided);
pTechnique = findExtraTechnique(profileCommon, "GOOGLEEARTH");
GET_EXTRA_PARAM(double_sided, double_sided);
//----------------------------------
// <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
mWrapU = mWrapV = true;
mMirrorU = mMirrorV = false;
wrapU = wrapV = true;
mirrorU = mirrorV = 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();
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));
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));
}
// MAYA profile
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);
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);
// FCOLLADA profile
if (profileCommon) {
mTechnique = findExtraTechnique((const domProfile_COMMON::domTechnique*)profileCommon->getTechnique(), "FCOLLADA");
if (mTechnique) {
domAny* bump = daeSafeCast<domAny>(const_cast<domTechnique*>(mTechnique)->getChild("bump"));
pTechnique = findExtraTechnique((const domProfile_COMMON::domTechnique*)profileCommon->getTechnique(), "FCOLLADA");
if (pTechnique) {
domAny* bump = daeSafeCast<domAny>(const_cast<domTechnique*>(pTechnique)->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)
mBumpSampler = param->getSampler2D();
bumpSampler = param->getSampler2D();
}
}
}
@ -235,21 +235,21 @@ class ColladaExtension_node : public ColladaExtension
{
public:
// FCOLLADA or OpenCOLLADA profile elements
AnimatedFloat mVisibility;
const char* mUserProperties;
AnimatedFloat visibility;
const char* user_properties;
ColladaExtension_node(const domNode* node)
{
// FCOLLADA profile
mTechnique = findExtraTechnique(node, "FCOLLADA");
GET_EXTRA_PARAM(mVisibility, 1.0);
GET_EXTRA_PARAM(mUserProperties, "");
pTechnique = findExtraTechnique(node, "FCOLLADA");
GET_EXTRA_PARAM(visibility, 1.0);
GET_EXTRA_PARAM(user_properties, "");
// OpenCOLLADA profile
mTechnique = findExtraTechnique(node, "OpenCOLLADA");
if (!mVisibility.mElement)
GET_EXTRA_PARAM(mVisibility, 1.0);
GET_EXTRA_PARAM(mUserProperties, mUserProperties);
pTechnique = findExtraTechnique(node, "OpenCOLLADA");
if (!visibility.element)
GET_EXTRA_PARAM(visibility, 1.0);
GET_EXTRA_PARAM(user_properties, user_properties);
}
};
@ -258,13 +258,13 @@ class ColladaExtension_geometry : public ColladaExtension
{
public:
// MAYA profile elements
bool mDoubleSided;
bool double_sided;
ColladaExtension_geometry(const domGeometry* geometry)
{
// MAYA profile
mTechnique = findExtraTechnique(geometry, "MAYA");
GET_EXTRA_PARAM(mDoubleSided, false);
pTechnique = findExtraTechnique(geometry, "MAYA");
GET_EXTRA_PARAM(double_sided, false);
}
};
@ -278,27 +278,27 @@ public:
};
// Torque profile elements (none of these are animatable)
S32 mNumTriggers;
Vector<Trigger> mTriggers;
bool mCyclic;
bool mBlend;
F32 mBlendReferenceTime;
F32 mPriority;
S32 num_triggers;
Vector<Trigger> triggers;
bool cyclic;
bool blend;
F32 blendReferenceTime;
F32 priority;
ColladaExtension_animation_clip(const domAnimation_clip* clip)
{
// Torque profile
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);
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);
}
GET_EXTRA_PARAM(mCyclic, false);
GET_EXTRA_PARAM(mBlend, false);
GET_EXTRA_PARAM(mBlendReferenceTime, 0.0f);
GET_EXTRA_PARAM(mPriority, 5.0f);
GET_EXTRA_PARAM(cyclic, false);
GET_EXTRA_PARAM(blend, false);
GET_EXTRA_PARAM(blendReferenceTime, 0.0f);
GET_EXTRA_PARAM(priority, 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::smDefaultTime));
mat.mul(appNode->getNodeTransform(TSShapeLoader::DefaultTime));
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().mUnit = unit;
ColladaUtils::getOptions().mUpAxis = upAxis;
ColladaUtils::getOptions().unit = unit;
ColladaUtils::getOptions().upAxis = 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().mUnit <= 0.0f)
ColladaUtils::getOptions().mUnit = unit;
if (ColladaUtils::getOptions().unit <= 0.0f)
ColladaUtils::getOptions().unit = unit;
if (ColladaUtils::getOptions().mUpAxis == UPAXISTYPE_COUNT)
ColladaUtils::getOptions().mUpAxis = upAxis;
if (ColladaUtils::getOptions().upAxis == UPAXISTYPE_COUNT)
ColladaUtils::getOptions().upAxis = 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.mInput.initFromSource(source);
data.input.initFromSource(source);
// Adjust the maximum sequence end time
maxEndTime = getMax(maxEndTime, data.mInput.getFloatValue((S32)data.mInput.size()-1));
maxEndTime = getMax(maxEndTime, data.input.getFloatValue((S32)data.input.size()-1));
// Detect the frame rate (minimum time between keyframes)
for (S32 iFrame = 1; iFrame < data.mInput.size(); iFrame++)
for (S32 iFrame = 1; iFrame < data.input.size(); iFrame++)
{
F32 delta = data.mInput.getFloatValue( iFrame ) - data.mInput.getFloatValue( iFrame-1 );
F32 delta = data.input.getFloatValue( iFrame ) - data.input.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.mOutput.initFromSource(source);
data.output.initFromSource(source);
else if (dStrEqual(input->getSemantic(), "IN_TANGENT"))
data.mInTangent.initFromSource(source);
data.inTangent.initFromSource(source);
else if (dStrEqual(input->getSemantic(), "OUT_TANGENT"))
data.mOutTangent.initFromSource(source);
data.outTangent.initFromSource(source);
else if (dStrEqual(input->getSemantic(), "INTERPOLATION"))
data.mInterpolation.initFromSource(source);
data.interpolation.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.mOutput.getFloatValue(0)));
visTarget->setValue(avar("%g", data.output.getFloatValue(0)));
}
// Ignore empty animations
if (data.mInput.size() == 0) {
if (data.input.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++)
mAppSequences.push_back(new ColladaAppSequence(libraryClips->getAnimation_clip_array()[iClip]));
appSequences.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 < mAppSequences.size(); iSeq++) {
ColladaAppSequence* appSeq = dynamic_cast<ColladaAppSequence*>(mAppSequences[iSeq]);
for (S32 iSeq = 0; iSeq < appSequences.size(); iSeq++) {
ColladaAppSequence* appSeq = dynamic_cast<ColladaAppSequence*>(appSequences[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::smMinFrameRate, TSShapeLoader::smMaxFrameRate);
appSeq->fps = mClamp(1.0f / minFrameTime + 0.5f, TSShapeLoader::MinFrameRate, TSShapeLoader::MaxFrameRate);
}
// First grab all of the top-level nodes
@ -276,7 +276,7 @@ void ColladaShapeLoader::enumerateScene()
// Set LOD option
bool singleDetail = true;
switch (ColladaUtils::getOptions().mLodType)
switch (ColladaUtils::getOptions().lodType)
{
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().mSingleDetailSize );
ColladaAppMesh::fixDetailSize( singleDetail, ColladaUtils::getOptions().singleDetailSize );
// 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 (!mBoundsNode)
if (!boundsNode)
{
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().mAlwaysImport, name, false))
if (FindMatch::isMatchMultipleExprs(ColladaUtils::getOptions().alwaysImport, name, false))
return false;
else
return FindMatch::isMatchMultipleExprs(ColladaUtils::getOptions().mNeverImport, name, false);
return FindMatch::isMatchMultipleExprs(ColladaUtils::getOptions().neverImport, name, false);
}
bool ColladaShapeLoader::ignoreMesh(const String& name)
{
if (FindMatch::isMatchMultipleExprs(ColladaUtils::getOptions().mAlwaysImportMesh, name, false))
if (FindMatch::isMatchMultipleExprs(ColladaUtils::getOptions().alwaysImportMesh, name, false))
return false;
else
return FindMatch::isMatchMultipleExprs(ColladaUtils::getOptions().mNeverImportMesh, name, false);
return FindMatch::isMatchMultipleExprs(ColladaUtils::getOptions().neverImportMesh, 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().mAdjustCenter ||
ColladaUtils::getOptions().mAdjustFloor) )
(ColladaUtils::getOptions().adjustCenter ||
ColladaUtils::getOptions().adjustFloor) )
{
// Compute shape offset
Point3F shapeOffset = Point3F::Zero;
if ( ColladaUtils::getOptions().mAdjustCenter )
if ( ColladaUtils::getOptions().adjustCenter )
{
bounds.getCenter( &shapeOffset );
shapeOffset = -shapeOffset;
}
if ( ColladaUtils::getOptions().mAdjustFloor )
if ( ColladaUtils::getOptions().adjustFloor )
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 < mShape->mNodes.size(); iNode++)
for (S32 iNode = 0; iNode < shape->nodes.size(); iNode++)
{
if ( !mAppNodes[iNode]->isParentRoot() )
if ( !appNodes[iNode]->isParentRoot() )
continue;
// Adjust default translation
mShape->mDefaultTranslations[iNode] += shapeOffset;
shape->defaultTranslations[iNode] += shapeOffset;
// Adjust animated translations
for (S32 iSeq = 0; iSeq < mShape->mSequences.size(); iSeq++)
for (S32 iSeq = 0; iSeq < shape->sequences.size(); iSeq++)
{
const TSShape::Sequence& seq = mShape->mSequences[iSeq];
const TSShape::Sequence& seq = shape->sequences[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;
mShape->mNodeTranslations[index] += shapeOffset;
shape->nodeTranslations[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().mForceUpdateMaterials)
if (!ColladaUtils::getOptions().forceUpdateMaterials)
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::mAppMaterials.size(); iMat++ )
for ( U32 iMat = 0; iMat < AppMesh::appMaterials.size(); iMat++ )
{
ColladaAppMaterial *mat = dynamic_cast<ColladaAppMaterial*>( AppMesh::mAppMaterials[iMat] );
ColladaAppMaterial *mat = dynamic_cast<ColladaAppMaterial*>( AppMesh::appMaterials[iMat] );
if ( mat )
{
Material *mappedMat;
if ( Sim::findObject( MATMGR->getMapEntry( mat->getName() ), mappedMat ) )
{
// Only update existing materials if forced to
if ( ColladaUtils::getOptions().mForceUpdateMaterials )
if ( ColladaUtils::getOptions().forceUpdateMaterials )
persistMgr.setDirty( mappedMat );
}
else
@ -686,8 +686,8 @@ TSShape* loadColladaShape(const Torque::Path &path)
#ifdef DAE2DTS_TOOL
// Command line overrides certain options
ColladaUtils::getOptions().mForceUpdateMaterials = cmdLineOptions.mForceUpdateMaterials;
ColladaUtils::getOptions().mUseDiffuseNames = cmdLineOptions.mUseDiffuseNames;
ColladaUtils::getOptions().forceUpdateMaterials = cmdLineOptions.forceUpdateMaterials;
ColladaUtils::getOptions().useDiffuseNames = cmdLineOptions.useDiffuseNames;
#endif
}

View file

@ -49,7 +49,7 @@ void ColladaUtils::convertTransform(MatrixF& mat)
{
MatrixF rot(true);
switch (ColladaUtils::getOptions().mUpAxis)
switch (ColladaUtils::getOptions().upAxis)
{
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
mTargetValueCount = fullCount;
mTargetValueOffset = 0;
targetValueCount = fullCount;
targetValueOffset = 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) {
mTargetValueOffset = (indN * 4) + indM; // @todo: 4x4 matrix only
mTargetValueCount = 1;
targetValueOffset = (indN * 4) + indM; // @todo: 4x4 matrix only
targetValueCount = 1;
}
else if (dSscanf(p, "(%d)", &indN) == 1) {
mTargetValueOffset = indN;
mTargetValueCount = 1;
targetValueOffset = indN;
targetValueCount = 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])) {
mTargetValueOffset = iElem;
mTargetValueCount = 1;
targetValueOffset = iElem;
targetValueCount = 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 (mInput.size() == 0)
if (input.size() == 0)
{
*value = 0.0f;
return;
}
else if (mInput.size() == 1)
else if (input.size() == 1)
{
*value = mOutput.getStringArrayData(0)[offset];
*value = output.getStringArrayData(0)[offset];
return;
}
// clamp time to valid range
F32 curveStart = mInput.getFloatValue(0);
F32 curveEnd = mInput.getFloatValue(mInput.size()-1);
F32 curveStart = input.getFloatValue(0);
F32 curveEnd = input.getFloatValue(input.size()-1);
t = mClampF(t, curveStart, curveEnd);
// find the index of the input keyframe BEFORE 't'
S32 index;
for (index = 0; index < mInput.size()-2; index++) {
if (mInput.getFloatValue(index + 1) > t)
for (index = 0; index < input.size()-2; index++) {
if (input.getFloatValue(index + 1) > t)
break;
}
// get the data for the two control points either side of 't'
Point2F v0;
v0.x = mInput.getFloatValue(index);
v0.y = mOutput.getStringArrayData(index)[offset];
v0.x = input.getFloatValue(index);
v0.y = output.getStringArrayData(index)[offset];
Point2F v3;
v3.x = mInput.getFloatValue(index + 1);
v3.y = mOutput.getStringArrayData(index + 1)[offset];
v3.x = input.getFloatValue(index + 1);
v3.y = output.getStringArrayData(index + 1)[offset];
// If spline interpolation is specified but the tangents are not available,
// default to LINEAR.
const char* interp_method = mInterpolation.getStringValue(index);
const char* interp_method = interpolation.getStringValue(index);
if (dStrEqual(interp_method, "BEZIER") ||
dStrEqual(interp_method, "HERMITE") ||
dStrEqual(interp_method, "CARDINAL")) {
const double* inArray = mInTangent.getStringArrayData(index + 1);
const double* outArray = mOutTangent.getStringArrayData(index);
const double* inArray = inTangent.getStringArrayData(index + 1);
const double* outArray = outTangent.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 = mInput.getFloatValue(index-1);
v0.y = mOutput.getStringArrayData(index-1)[offset];
v0.x = input.getFloatValue(index-1);
v0.y = output.getStringArrayData(index-1)[offset];
}
else {
// mirror P1 through P0
v0 = v1 + (v1 - v2);
}
if (index < (mInput.size()-2)) {
v3.x = mInput.getFloatValue(index+2);
v3.y = mOutput.getStringArrayData(index+2)[offset];
if (index < (input.size()-2)) {
v3.x = input.getFloatValue(index+2);
v3.y = output.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 = mInTangent.getStringArrayData(index + 1);
const double* outArray = mOutTangent.getStringArrayData(index);
const double* inArray = inTangent.getStringArrayData(index + 1);
const double* outArray = outTangent.getStringArrayData(index);
if (mOutput.stride() == mInTangent.stride()) {
if (output.stride() == inTangent.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 (mInput.size() == 0)
if (input.size() == 0)
*value = "";
else if (mInput.size() == 1)
*value = mOutput.getStringValue(0);
else if (input.size() == 1)
*value = output.getStringValue(0);
else
{
// clamp time to valid range
F32 curveStart = mInput.getFloatValue(0);
F32 curveEnd = mInput.getFloatValue(mInput.size()-1);
F32 curveStart = input.getFloatValue(0);
F32 curveEnd = input.getFloatValue(input.size()-1);
t = mClampF(t, curveStart, curveEnd);
// find the index of the input keyframe BEFORE 't'
S32 index;
for (index = 0; index < mInput.size()-2; index++) {
if (mInput.getFloatValue(index + 1) > t)
for (index = 0; index < input.size()-2; index++) {
if (input.getFloatValue(index + 1) > t)
break;
}
// String values only support STEP interpolation, so just get the
// value at the input keyframe
*value = mOutput.getStringValue(index);
*value = output.getStringValue(index);
}
}

View file

@ -76,20 +76,20 @@ namespace ColladaUtils
NumLodTypes
};
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
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
ImportOptions()
{
@ -98,20 +98,20 @@ namespace ColladaUtils
void reset()
{
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;
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;
}
};
@ -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* 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
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
public:
_SourceReader() : mSource(0), mAccessor(0) {}
_SourceReader() : source(0), accessor(0) {}
void reset()
{
mSource = 0;
mAccessor = 0;
mOffsets.clear();
source = 0;
accessor = 0;
offsets.clear();
}
//------------------------------------------------------
// Initialize the _SourceReader object
bool initFromSource(const domSource* src, const char* paramNames[] = 0)
{
mSource = src;
mAccessor = mSource->getTechnique_common()->getAccessor();
mOffsets.clear();
source = src;
accessor = source->getTechnique_common()->getAccessor();
offsets.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
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;
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;
break;
}
}
@ -331,9 +331,9 @@ public:
}
// If no input params were specified, just map the source params directly
if (!mOffsets.size()) {
for (S32 iParam = 0; iParam < mAccessor->getParam_array().getCount(); iParam++)
mOffsets.push_back(iParam);
if (!offsets.size()) {
for (S32 iParam = 0; iParam < accessor->getParam_array().getCount(); iParam++)
offsets.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 mAccessor ? mAccessor->getCount() : 0; }
S32 size() const { return accessor ? accessor->getCount() : 0; }
// Get the number of elements per group in the source
S32 stride() const { return mAccessor ? mAccessor->getStride() : 0; }
S32 stride() const { return accessor ? accessor->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 (mSource->getFloat_array())
return &mSource->getFloat_array()->getValue()[index*stride()];
if (source->getFloat_array())
return &source->getFloat_array()->getValue()[index*stride()];
}
return 0;
}
@ -367,10 +367,10 @@ public:
{
if ((index >= 0) && (index < size())) {
// could be plain strings or IDREFs
if (mSource->getName_array())
return mSource->getName_array()->getValue()[index*stride()];
else if (mSource->getIDREF_array())
return mSource->getIDREF_array()->getValue()[index*stride()].getID();
if (source->getName_array())
return source->getName_array()->getValue()[index*stride()];
else if (source->getIDREF_array())
return source->getIDREF_array()->getValue()[index*stride()].getID();
}
return "";
}
@ -379,7 +379,7 @@ public:
{
F32 value(0);
if (const double* data = getStringArrayData(index))
return data[mOffsets[0]];
return data[offsets[0]];
return value;
}
@ -387,7 +387,7 @@ public:
{
Point2F value(0, 0);
if (const double* data = getStringArrayData(index))
value.set(data[mOffsets[0]], data[mOffsets[1]]);
value.set(data[offsets[0]], data[offsets[1]]);
return value;
}
@ -395,7 +395,7 @@ public:
{
Point3F value(1, 0, 0);
if (const double* data = getStringArrayData(index))
value.set(data[mOffsets[0]], data[mOffsets[1]], data[mOffsets[2]]);
value.set(data[offsets[0]], data[offsets[1]], data[offsets[2]]);
return value;
}
@ -404,11 +404,11 @@ public:
ColorI value(255, 255, 255, 255);
if (const double* data = getStringArrayData(index))
{
value.red = data[mOffsets[0]] * 255.0;
value.green = data[mOffsets[1]] * 255.0;
value.blue = data[mOffsets[2]] * 255.0;
value.red = data[offsets[0]] * 255.0;
value.green = data[offsets[1]] * 255.0;
value.blue = data[offsets[2]] * 255.0;
if ( stride() == 4 )
value.alpha = data[mOffsets[3]] * 255.0;
value.alpha = data[offsets[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* mPrimitive;
domListOfUInts *mTriangleData;
T* primitive;
domListOfUInts *pTriangleData;
S32 stride;
public:
ColladaPrimitive(const daeElement* e) : mTriangleData(0)
ColladaPrimitive(const daeElement* e) : pTriangleData(0)
{
// Cast to geometric primitive element
mPrimitive = daeSafeCast<T>(const_cast<daeElement*>(e));
primitive = daeSafeCast<T>(const_cast<daeElement*>(e));
// Determine stride
stride = 0;
@ -495,13 +495,13 @@ public:
}
~ColladaPrimitive()
{
delete mTriangleData;
delete pTriangleData;
}
/// Most primitives can use these common implementations
const char* getElementName() { return mPrimitive->getElementName(); }
const char* getMaterial() { return mPrimitive->getMaterial(); }
const domInputLocalOffset_Array& getInputs() { return mPrimitive->getInput_array(); }
const char* getElementName() { return primitive->getElementName(); }
const char* getMaterial() { return primitive->getMaterial(); }
const domInputLocalOffset_Array& getInputs() { return primitive->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 (mPrimitive->getP() ? &(mPrimitive->getP()->getValue()) : NULL);
return (primitive->getP() ? &(primitive->getP()->getValue()) : NULL);
}
//-----------------------------------------------------------------------------
// <tristrips>
template<> inline const domListOfUInts *ColladaPrimitive<domTristrips>::getTriangleData()
{
if (!mTriangleData)
if (!pTriangleData)
{
// Convert strips to triangles
mTriangleData = new domListOfUInts();
pTriangleData = new domListOfUInts();
for (S32 iStrip = 0; iStrip < mPrimitive->getCount(); iStrip++) {
for (S32 iStrip = 0; iStrip < primitive->getCount(); iStrip++) {
domP* P = mPrimitive->getP_array()[iStrip];
domP* P = primitive->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
mTriangleData->appendArray(stride, v0);
mTriangleData->appendArray(stride, v0 + 2*stride);
mTriangleData->appendArray(stride, v0 + stride);
pTriangleData->appendArray(stride, v0);
pTriangleData->appendArray(stride, v0 + 2*stride);
pTriangleData->appendArray(stride, v0 + stride);
}
else
{
// CCW triangle
mTriangleData->appendArray(stride*3, v0);
pTriangleData->appendArray(stride*3, v0);
}
}
}
}
return mTriangleData;
return pTriangleData;
}
//-----------------------------------------------------------------------------
// <trifans>
template<> inline const domListOfUInts *ColladaPrimitive<domTrifans>::getTriangleData()
{
if (!mTriangleData)
if (!pTriangleData)
{
// Convert strips to triangles
mTriangleData = new domListOfUInts();
pTriangleData = new domListOfUInts();
for (S32 iStrip = 0; iStrip < mPrimitive->getCount(); iStrip++) {
for (S32 iStrip = 0; iStrip < primitive->getCount(); iStrip++) {
domP* P = mPrimitive->getP_array()[iStrip];
domP* P = primitive->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) {
mTriangleData->appendArray(stride, pSrcData); // shared vertex
mTriangleData->appendArray(stride, v0); // previous vertex
mTriangleData->appendArray(stride, v0+stride); // current vertex
pTriangleData->appendArray(stride, pSrcData); // shared vertex
pTriangleData->appendArray(stride, v0); // previous vertex
pTriangleData->appendArray(stride, v0+stride); // current vertex
}
}
}
return mTriangleData;
return pTriangleData;
}
//-----------------------------------------------------------------------------
// <polygons>
template<> inline const domListOfUInts *ColladaPrimitive<domPolygons>::getTriangleData()
{
if (!mTriangleData)
if (!pTriangleData)
{
// Convert polygons to triangles
mTriangleData = new domListOfUInts();
pTriangleData = new domListOfUInts();
for (S32 iPoly = 0; iPoly < mPrimitive->getCount(); iPoly++) {
for (S32 iPoly = 0; iPoly < primitive->getCount(); iPoly++) {
domP* P = mPrimitive->getP_array()[iPoly];
domP* P = primitive->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++) {
mTriangleData->appendArray(stride, v0);
mTriangleData->appendArray(stride*2, pSrcData);
pTriangleData->appendArray(stride, v0);
pTriangleData->appendArray(stride*2, pSrcData);
pSrcData += stride;
}
}
}
return mTriangleData;
return pTriangleData;
}
//-----------------------------------------------------------------------------
// <polylist>
template<> inline const domListOfUInts *ColladaPrimitive<domPolylist>::getTriangleData()
{
if (!mTriangleData)
if (!pTriangleData)
{
// Convert polygons to triangles
mTriangleData = new domListOfUInts();
pTriangleData = 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 = mPrimitive->getVcount()->getValue();
const domListOfUInts& vcount = primitive->getVcount()->getValue();
U32 expectedCount = 0;
for (S32 iPoly = 0; iPoly < vcount.getCount(); iPoly++)
expectedCount += vcount[iPoly];
expectedCount *= stride;
if (!mPrimitive->getP() || !mPrimitive->getP()->getValue().getCount() ||
(mPrimitive->getP()->getValue().getCount() != expectedCount) )
if (!primitive->getP() || !primitive->getP()->getValue().getCount() ||
(primitive->getP()->getValue().getCount() != expectedCount) )
{
Con::warnf("<polylist> element found with invalid <p> array. This primitive will be ignored.");
return mTriangleData;
return pTriangleData;
}
domUint* pSrcData = &(mPrimitive->getP()->getValue()[0]);
domUint* pSrcData = &(primitive->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++) {
mTriangleData->appendArray(stride, v0);
mTriangleData->appendArray(stride*2, pSrcData);
pTriangleData->appendArray(stride, v0);
pTriangleData->appendArray(stride*2, pSrcData);
pSrcData += stride;
}
pSrcData += stride;
}
}
return mTriangleData;
return pTriangleData;
}
//-----------------------------------------------------------------------------
@ -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 *mElement;
AnimChannels(daeElement* el) : mElement(el)
daeElement *element;
AnimChannels(daeElement* el) : element(el)
{
mElement->setUserData(this);
element->setUserData(this);
}
~AnimChannels()
{
if (mElement)
mElement->setUserData(0);
if (element)
element->setUserData(0);
}
};
struct AnimData
{
bool mEnabled; ///!< Used to select animation channels for the current clip
bool enabled; ///!< Used to select animation channels for the current clip
_SourceReader mInput;
_SourceReader mOutput;
_SourceReader input;
_SourceReader output;
_SourceReader mInTangent;
_SourceReader mOutTangent;
_SourceReader inTangent;
_SourceReader outTangent;
_SourceReader mInterpolation;
_SourceReader interpolation;
U32 mTargetValueOffset; ///< Offset into the target element (for arrays of values)
U32 mTargetValueCount; ///< Number of values animated (from OUTPUT source array)
U32 targetValueOffset; ///< Offset into the target element (for arrays of values)
U32 targetValueCount; ///< 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() : mEnabled(false) { }
AnimData() : enabled(false) { }
void parseTargetString(const char* target, S32 fullCount, const char* elements[]);
@ -737,13 +737,13 @@ struct AnimData
template<class T>
struct AnimatedElement
{
const daeElement* mElement; ///< The Collada element (can be NULL)
T mDefaultVal; ///< Default value (used when element is NULL)
const daeElement* element; ///< The Collada element (can be NULL)
T defaultVal; ///< Default value (used when element is NULL)
AnimatedElement(const daeElement* e=0) : mElement(e) { }
AnimatedElement(const daeElement* e=0) : element(e) { }
/// Check if the element has any animations channels
bool isAnimated() { return (AnimData::getAnimChannels(mElement) != 0); }
bool isAnimated() { return (AnimData::getAnimChannels(element) != 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(mDefaultVal);
if (const domAny* param = daeSafeCast<domAny>(const_cast<daeElement*>(mElement))) {
T value(defaultVal);
if (const domAny* param = daeSafeCast<domAny>(const_cast<daeElement*>(element))) {
// If the element is not animated, just use its current value
value = convert<T>(param->getValue());
// Animate the value
const AnimChannels* channels = AnimData::getAnimChannels(mElement);
const AnimChannels* channels = AnimData::getAnimChannels(element);
if (channels && (time >= 0)) {
for (S32 iChannel = 0; iChannel < channels->size(); iChannel++) {
const AnimData* animData = (*channels)[iChannel];
if (animData->mEnabled)
if (animData->enabled)
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->mDefaultVal);
if (this->mElement) {
T vec(this->defaultVal);
if (this->element) {
// Get a copy of the vector
vec = *(T*)const_cast<daeElement*>(this->mElement)->getValuePointer();
vec = *(T*)const_cast<daeElement*>(this->element)->getValuePointer();
// Animate the vector
const AnimChannels* channels = AnimData::getAnimChannels(this->mElement);
const AnimChannels* channels = AnimData::getAnimChannels(this->element);
if (channels && (time >= 0)) {
for (S32 iChannel = 0; iChannel < channels->size(); iChannel++) {
const AnimData* animData = (*channels)[iChannel];
if (animData->mEnabled) {
for (S32 iValue = 0; iValue < animData->mTargetValueCount; iValue++)
animData->interpValue(time, iValue, &vec[animData->mTargetValueOffset + iValue]);
if (animData->enabled) {
for (S32 iValue = 0; iValue < animData->targetValueCount; iValue++)
animData->interpValue(time, iValue, &vec[animData->targetValueOffset + iValue]);
}
}
}

View file

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

View file

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

File diff suppressed because it is too large Load diff

View file

@ -94,31 +94,31 @@ protected:
};
public:
static const F32 smDefaultTime;
static const F64 smMinFrameRate;
static const F64 smMaxFrameRate;
static const F64 smAppGroundFrameRate;
static const F32 DefaultTime;
static const F64 MinFrameRate;
static const F64 MaxFrameRate;
static const F64 AppGroundFrameRate;
protected:
// Variables used during loading that must be held until the shape is deleted
TSShape* mShape;
Vector<AppMesh*> mAppMeshes;
TSShape* shape;
Vector<AppMesh*> appMeshes;
// Variables used during loading, but that can be discarded afterwards
static Torque::Path smShapePath;
static Torque::Path shapePath;
AppNode* mBoundsNode;
Vector<AppNode*> mAppNodes; ///< Nodes in the loaded shape
Vector<AppSequence*> mAppSequences;
AppNode* boundsNode;
Vector<AppNode*> appNodes; ///< Nodes in the loaded shape
Vector<AppSequence*> appSequences;
Vector<Subshape*> mSubShapes;
Vector<Subshape*> subshapes;
Vector<QuatF*> mNodeRotCache;
Vector<Point3F*> mNodeTransCache;
Vector<QuatF*> mNodeScaleRotCache;
Vector<Point3F*> mNodeScaleCache;
Vector<QuatF*> nodeRotCache;
Vector<Point3F*> nodeTransCache;
Vector<QuatF*> nodeScaleRotCache;
Vector<Point3F*> nodeScaleCache;
Point3F mShapeOffset; ///< Offset used to translate the shape origin
Point3F shapeOffset; ///< Offset used to translate the shape origin
//--------------------------------------------------------------------------
@ -183,10 +183,10 @@ protected:
void install();
public:
TSShapeLoader() : mBoundsNode(0) { }
TSShapeLoader() : boundsNode(0) { }
virtual ~TSShapeLoader();
static const Torque::Path& getShapePath() { return smShapePath; }
static const Torque::Path& getShapePath() { return shapePath; }
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->mSubShapeFirstNode.size(); i++)
for (S32 i=0; i<mShape->subShapeFirstNode.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->mSubShapeFirstNode.size(); i++)
for (S32 i=0; i<mShape->subShapeFirstNode.size(); i++)
mDirtyFlags[i] &= ~dirty;
}
@ -62,25 +62,25 @@ void TSShapeInstance::animateNodes(S32 ss)
{
PROFILE_SCOPE( TSShapeInstance_animateNodes );
if (!mShape->mNodes.size())
if (!mShape->nodes.size())
return;
// @todo: When a node is added, we need to make sure to resize the nodeTransforms array as well
mNodeTransforms.setSize(mShape->mNodes.size());
mNodeTransforms.setSize(mShape->nodes.size());
// temporary storage for node transforms
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());
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());
TSIntegerSet rotBeenSet;
TSIntegerSet tranBeenSet;
TSIntegerSet scaleBeenSet;
rotBeenSet.setAll(mShape->mNodes.size());
tranBeenSet.setAll(mShape->mNodes.size());
scaleBeenSet.setAll(mShape->mNodes.size());
rotBeenSet.setAll(mShape->nodes.size());
tranBeenSet.setAll(mShape->nodes.size());
scaleBeenSet.setAll(mShape->nodes.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->mSubShapeFirstNode[ss];
b = a + mShape->mSubShapeNumNodes[ss];
a = mShape->subShapeFirstNode[ss];
b = a + mShape->subShapeNumNodes[ss];
for (i=a; i<b; i++)
{
if (rotBeenSet.test(i))
{
mShape->mDefaultRotations[i].getQuatF(&smNodeCurrentRotations[i]);
mShape->defaultRotations[i].getQuatF(&smNodeCurrentRotations[i]);
smRotationThreads[i] = NULL;
}
if (tranBeenSet.test(i))
{
smNodeCurrentTranslations[i] = mShape->mDefaultTranslations[i];
smNodeCurrentTranslations[i] = mShape->defaultTranslations[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->mKeyNum1,j,&q1);
mShape->getRotation(*th->getSequence(),th->mKeyNum2,j,&q2);
TSTransform::interpolate(q1,q2,th->mKeyPos,&smNodeCurrentRotations[nodeIndex]);
mShape->getRotation(*th->getSequence(),th->keyNum1,j,&q1);
mShape->getRotation(*th->getSequence(),th->keyNum2,j,&q2);
TSTransform::interpolate(q1,q2,th->keyPos,&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->mKeyNum1,j);
const Point3F & p2 = mShape->getTranslation(*th->getSequence(),th->mKeyNum2,j);
TSTransform::interpolate(p1,p2,th->mKeyPos,&smNodeCurrentTranslations[nodeIndex]);
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]);
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->mBlendDisabled)
if (th->blendDisabled)
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->mNodes[i].parentIndex;
S32 parentIdx = mShape->nodes[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->mNodes.size());
smScaleThreads.setSize(mShape->nodes.size());
scaleBeenSet.takeAway(mCallbackNodes);
scaleBeenSet.takeAway(mHandsOffNodes);
if (animatesUniformScale())
{
smNodeCurrentUniformScales.setSize(mShape->mNodes.size());
smNodeCurrentUniformScales.setSize(mShape->nodes.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->mNodes.size());
smNodeCurrentAlignedScales.setSize(mShape->nodes.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->mNodes.size());
smNodeCurrentArbitraryScales.setSize(mShape->nodes.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->mTransitionData.inTransition ? thread : NULL;
thread = thread && thread->transitionData.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]->mTransitionData.oldRotationNodes.test(nodeIndex) || mTransitionThreads[i]->getSequence()->rotationMatters.test(nodeIndex))
if (mTransitionThreads[i]->transitionData.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->mTransitionData.pos,&smNodeCurrentRotations[nodeIndex]);
TSTransform::interpolate(mNodeReferenceRotations[nodeIndex].getQuatF(&tmpQ),smNodeCurrentRotations[nodeIndex],thread->transitionData.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->mTransitionData.inTransition ? thread : NULL;
thread = thread && thread->transitionData.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]->mTransitionData.oldTranslationNodes.test(nodeIndex) || mTransitionThreads[i]->getSequence()->translationMatters.test(nodeIndex))
if (mTransitionThreads[i]->transitionData.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->mTransitionData.pos;
F32 k = thread->transitionData.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->mTransitionData.inTransition ? thread : NULL;
thread = thread && thread->transitionData.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]->mTransitionData.oldScaleNodes.test(nodeIndex) || mTransitionThreads[i]->getSequence()->scaleMatters.test(nodeIndex))
if (mTransitionThreads[i]->transitionData.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->mTransitionData.pos * (mNodeReferenceUniformScales[nodeIndex]-smNodeCurrentUniformScales[nodeIndex]);
smNodeCurrentUniformScales[nodeIndex] += thread->transitionData.pos * (mNodeReferenceUniformScales[nodeIndex]-smNodeCurrentUniformScales[nodeIndex]);
else if (animatesAlignedScale())
TSTransform::interpolate(mNodeReferenceScaleFactors[nodeIndex],smNodeCurrentAlignedScales[nodeIndex],thread->mTransitionData.pos,&smNodeCurrentAlignedScales[nodeIndex]);
TSTransform::interpolate(mNodeReferenceScaleFactors[nodeIndex],smNodeCurrentAlignedScales[nodeIndex],thread->transitionData.pos,&smNodeCurrentAlignedScales[nodeIndex]);
else
{
QuatF q;
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);
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);
}
}
}
@ -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->mKeyNum1,j);
F32 s2 = mShape->getUniformScale(*thread->getSequence(),thread->mKeyNum2,j);
uniformScale = TSTransform::interpolate(s1,s2,thread->mKeyPos);
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);
alignedScale.set(uniformScale,uniformScale,uniformScale);
break;
}
case 5: // aligned -> aligned
case 9: // aligned -> arbitrary
{
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);
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);
break;
}
case 10: // arbitrary -> arbitary
{
TSScale s1,s2;
mShape->getArbitraryScale(*thread->getSequence(),thread->mKeyNum1,j,&s1);
mShape->getArbitraryScale(*thread->getSequence(),thread->mKeyNum2,j,&s2);
TSTransform::interpolate(s1,s2,thread->mKeyPos,&arbitraryScale);
mShape->getArbitraryScale(*thread->getSequence(),thread->keyNum1,j,&s1);
mShape->getArbitraryScale(*thread->getSequence(),thread->keyNum2,j,&s2);
TSTransform::interpolate(s1,s2,thread->keyPos,&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->mKeyNum1,offset);
const Point3F & p2 = mShape->getTranslation(*th->getSequence(),th->mKeyNum2,offset);
const Point3F & p1 = mShape->getTranslation(*th->getSequence(),th->keyNum1,offset);
const Point3F & p2 = mShape->getTranslation(*th->getSequence(),th->keyNum2,offset);
Point3F p;
TSTransform::interpolate(p1,p2,th->mKeyPos,&p);
TSTransform::interpolate(p1,p2,th->keyPos,&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->mKeyNum1,jrot,&q1);
mShape->getRotation(*thread->getSequence(),thread->mKeyNum2,jrot,&q2);
mShape->getRotation(*thread->getSequence(),thread->keyNum1,jrot,&q1);
mShape->getRotation(*thread->getSequence(),thread->keyNum2,jrot,&q2);
QuatF quat;
TSTransform::interpolate(q1,q2,thread->mKeyPos,&quat);
TSTransform::interpolate(q1,q2,thread->keyPos,&quat);
TSTransform::setMatrix(quat,&mat);
jrot++;
}
if (thread->getSequence()->translationMatters.test(nodeIndex))
{
const Point3F & p1 = mShape->getTranslation(*thread->getSequence(),thread->mKeyNum1,jtrans);
const Point3F & p2 = mShape->getTranslation(*thread->getSequence(),thread->mKeyNum2,jtrans);
const Point3F & p1 = mShape->getTranslation(*thread->getSequence(),thread->keyNum1,jtrans);
const Point3F & p2 = mShape->getTranslation(*thread->getSequence(),thread->keyNum2,jtrans);
Point3F p;
TSTransform::interpolate(p1,p2,thread->mKeyPos,&p);
TSTransform::interpolate(p1,p2,thread->keyPos,&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->mKeyNum1,jscale);
F32 s2 = mShape->getUniformScale(*thread->getSequence(),thread->mKeyNum2,jscale);
F32 scale = TSTransform::interpolate(s1,s2,thread->mKeyPos);
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);
TSTransform::applyScale(scale,&mat);
}
else if (animatesAlignedScale())
{
Point3F s1 = mShape->getAlignedScale(*thread->getSequence(),thread->mKeyNum1,jscale);
Point3F s2 = mShape->getAlignedScale(*thread->getSequence(),thread->mKeyNum2,jscale);
Point3F s1 = mShape->getAlignedScale(*thread->getSequence(),thread->keyNum1,jscale);
Point3F s2 = mShape->getAlignedScale(*thread->getSequence(),thread->keyNum2,jscale);
Point3F scale;
TSTransform::interpolate(s1,s2,thread->mKeyPos,&scale);
TSTransform::interpolate(s1,s2,thread->keyPos,&scale);
TSTransform::applyScale(scale,&mat);
}
else
{
TSScale s1,s2;
mShape->getArbitraryScale(*thread->getSequence(),thread->mKeyNum1,jscale,&s1);
mShape->getArbitraryScale(*thread->getSequence(),thread->mKeyNum2,jscale,&s2);
mShape->getArbitraryScale(*thread->getSequence(),thread->keyNum1,jscale,&s1);
mShape->getArbitraryScale(*thread->getSequence(),thread->keyNum2,jscale,&s2);
TSScale scale;
TSTransform::interpolate(s1,s2,thread->mKeyPos,&scale);
TSTransform::interpolate(s1,s2,thread->keyPos,&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->mSubShapeFirstObject[ss];
S32 b = a + mShape->mSubShapeNumObjects[ss];
S32 a = mShape->subShapeFirstObject[ss];
S32 b = a + mShape->subShapeNumObjects[ss];
for (i=a; i<b; i++)
{
if (beenSet.test(i))
mMeshObjects[i].visible = mShape->mObjectStates[i].vis;
mMeshObjects[i].visible = mShape->objectStates[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->mKeyNum1,j).vis;
F32 state2 = mShape->getObjectState(*th->getSequence(),th->mKeyNum2,j).vis;
F32 state1 = mShape->getObjectState(*th->getSequence(),th->keyNum1,j).vis;
F32 state2 = mShape->getObjectState(*th->getSequence(),th->keyNum2,j).vis;
if ((state1-state2) * (state1-state2) > 0.99f)
// goes from 0 to 1 -- discreet jump
mMeshObjects[objectIndex].visible = th->mKeyPos<0.5f ? state1 : state2;
mMeshObjects[objectIndex].visible = th->keyPos<0.5f ? state1 : state2;
else
// interpolate between keyframes when visibility change is gradual
mMeshObjects[objectIndex].visible = (1.0f-th->mKeyPos) * state1 + th->mKeyPos * state2;
mMeshObjects[objectIndex].visible = (1.0f-th->keyPos) * state1 + th->keyPos * 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->mSubShapeFirstObject[ss];
S32 b = a + mShape->mSubShapeNumObjects[ss];
S32 a = mShape->subShapeFirstObject[ss];
S32 b = a + mShape->subShapeNumObjects[ss];
for (i=a; i<b; i++)
if (beenSet.test(i))
mMeshObjects[i].frame = mShape->mObjectStates[i].frameIndex;
mMeshObjects[i].frame = mShape->objectStates[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->mKeyPos<0.5f) ? th->mKeyNum1 : th->mKeyNum2;
S32 key = (th->keyPos<0.5f) ? th->keyNum1 : th->keyNum2;
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->mSubShapeFirstObject[ss];
S32 b = a + mShape->mSubShapeNumObjects[ss];
S32 a = mShape->subShapeFirstObject[ss];
S32 b = a + mShape->subShapeNumObjects[ss];
for (i=a; i<b; i++)
if (beenSet.test(i))
mMeshObjects[i].matFrame = mShape->mObjectStates[i].matFrameIndex;
mMeshObjects[i].matFrame = mShape->objectStates[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->mKeyPos<0.5f) ? th->mKeyNum1 : th->mKeyNum2;
S32 key = (th->keyPos<0.5f) ? th->keyNum1 : th->keyNum2;
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->mDetails[dl].subShapeNum;
S32 ss = mShape->details[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->mSubShapeNumNodes.size(); i++)
for (S32 i=0; i<mShape->subShapeNumNodes.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->mSubShapeNumNodes.size(); i++)
for (S32 i=0; i<mShape->subShapeNumNodes.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->mTransitionData.inTransition,"TSShapeInstance::addPath");
AssertFatal(!gt->transitionData.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->mTransitionData.inTransition && th->getSequence()->numGroundFrames>0)
if (!th->transitionData.inTransition && th->getSequence()->numGroundFrames>0)
{
mGroundThread = th;
return true;
@ -950,9 +950,9 @@ void TSShapeInstance::animateGround()
if (!mGroundThread && !initGround())
return;
S32 & loop = mGroundThread->mPath.loop;
F32 & start = mGroundThread->mPath.start;
F32 & end = mGroundThread->mPath.end;
S32 & loop = mGroundThread->path.loop;
F32 & start = mGroundThread->path.start;
F32 & end = mGroundThread->path.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->mTransitionData.inTransition)
if (thread->transitionData.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->mTransitionData.inTransition)
if (thread->transitionData.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->mDetails.size(),"TSShapeInstance::buildPolyList");
AssertFatal(dl>=0 && dl<mShape->details.size(),"TSShapeInstance::buildPolyList");
// get subshape and object detail
const TSDetail * detail = &mShape->mDetails[dl];
const TSDetail * detail = &mShape->details[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->mSubShapeFirstObject[ss];
S32 end = mShape->mSubShapeNumObjects[ss] + start;
S32 start = mShape->subShapeFirstObject[ss];
S32 end = mShape->subShapeNumObjects[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->mDetails.size(),"TSShapeInstance::buildPolyList");
AssertFatal(dl>=0 && dl<mShape->details.size(),"TSShapeInstance::buildPolyList");
// get subshape and object detail
const TSDetail * detail = &mShape->mDetails[dl];
const TSDetail * detail = &mShape->details[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->mSubShapeFirstObject[ss];
S32 end = mShape->mSubShapeNumObjects[ss] + start;
S32 start = mShape->subShapeFirstObject[ss];
S32 end = mShape->subShapeNumObjects[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->mDetails.size(),"TSShapeInstance::castRay");
AssertFatal(dl>=0 && dl<mShape->details.size(),"TSShapeInstance::castRay");
// get subshape and object detail
const TSDetail * detail = &mShape->mDetails[dl];
const TSDetail * detail = &mShape->details[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->mSubShapeFirstObject[ss];
S32 end = mShape->mSubShapeNumObjects[ss] + start;
S32 start = mShape->subShapeFirstObject[ss];
S32 end = mShape->subShapeNumObjects[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->mDetails.size(),"TSShapeInstance::castRayRendered");
AssertFatal(dl>=0 && dl<mShape->details.size(),"TSShapeInstance::castRayRendered");
// get subshape and object detail
const TSDetail * detail = &mShape->mDetails[dl];
const TSDetail * detail = &mShape->details[dl];
S32 ss = detail->subShapeNum;
S32 od = detail->objectDetailNum;
if ( ss == -1 )
return false;
S32 start = mShape->mSubShapeFirstObject[ss];
S32 end = mShape->mSubShapeNumObjects[ss] + start;
S32 start = mShape->subShapeFirstObject[ss];
S32 end = mShape->subShapeNumObjects[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->mDetails.size(),"TSShapeInstance::support");
AssertFatal(dl>=0 && dl<mShape->details.size(),"TSShapeInstance::support");
// get subshape and object detail
const TSDetail * detail = &mShape->mDetails[dl];
const TSDetail * detail = &mShape->details[dl];
S32 ss = detail->subShapeNum;
S32 od = detail->objectDetailNum;
S32 start = mShape->mSubShapeFirstObject[ss];
S32 end = mShape->mSubShapeNumObjects[ss] + start;
S32 start = mShape->subShapeFirstObject[ss];
S32 end = mShape->subShapeNumObjects[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->mDetails.size(),"TSShapeInstance::computeBounds");
AssertFatal(dl>=0 && dl<mShape->details.size(),"TSShapeInstance::computeBounds");
// get subshape and object detail
const TSDetail * detail = &mShape->mDetails[dl];
const TSDetail * detail = &mShape->details[dl];
S32 ss = detail->subShapeNum;
S32 od = detail->objectDetailNum;
// use shape bounds for imposter details
if (ss < 0)
{
bounds = mShape->mBounds;
bounds = mShape->bounds;
return;
}
S32 start = mShape->mSubShapeFirstObject[ss];
S32 end = mShape->mSubShapeNumObjects[ss] + start;
S32 start = mShape->subShapeFirstObject[ss];
S32 end = mShape->subShapeNumObjects[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->mDetails.size(),"TSShapeInstance::buildPolyListOpcode");
AssertFatal(dl>=0 && dl<mShape->details.size(),"TSShapeInstance::buildPolyListOpcode");
// get subshape and object detail
const TSDetail * detail = &mShape->mDetails[dl];
const TSDetail * detail = &mShape->details[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->mSubShapeFirstObject[ss];
S32 end = mShape->mSubShapeNumObjects[ss] + start;
S32 start = mShape->subShapeFirstObject[ss];
S32 end = mShape->subShapeNumObjects[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->mDetails.size(),"TSShapeInstance::castRayOpcode");
AssertFatal(dl>=0 && dl<mShape->details.size(),"TSShapeInstance::castRayOpcode");
info->t = 100.f;
// get subshape and object detail
const TSDetail * detail = &mShape->mDetails[dl];
const TSDetail * detail = &mShape->details[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->mSubShapeFirstObject[ss];
S32 end = mShape->mSubShapeNumObjects[ss] + start;
S32 start = mShape->subShapeFirstObject[ss];
S32 end = mShape->subShapeNumObjects[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->mDetails.size(),"TSShapeInstance::buildConvexOpcode");
AssertFatal(dl>=0 && dl<mShape->details.size(),"TSShapeInstance::buildConvexOpcode");
// get subshape and object detail
const TSDetail * detail = &mShape->mDetails[dl];
const TSDetail * detail = &mShape->details[dl];
S32 ss = detail->subShapeNum;
S32 od = detail->objectDetailNum;
// nothing emitted yet...
bool emitted = false;
S32 start = mShape->mSubShapeFirstObject[ss];
S32 end = mShape->mSubShapeNumObjects[ss] + start;
S32 start = mShape->subShapeFirstObject[ss];
S32 end = mShape->subShapeNumObjects[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 < mDetails.size(); i++ )
for ( U32 i = 0; i < details.size(); i++ )
{
// Make sure we skip any details that shouldn't be rendered
if ( mDetails[i].size < 0 )
if ( details[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 ( mDetails[i].size > highestSize )
if ( details[i].size > highestSize )
{
highestDetail = i;
highestSize = mDetails[i].size;
highestSize = details[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 < mDetails.size(); i++ )
for ( U32 i = 0; i < details.size(); i++ )
{
const String &name = mNames[ mDetails[i].nameIndex ];
const String &name = names[ details[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 < mDetails.size(); i++ )
for ( U32 i = 0; i < details.size(); i++ )
{
const String &name = mNames[ mDetails[i].nameIndex ];
const String &name = names[ details[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 = mDetails[0];
const TSShape::Detail &detail = details[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 = mSubShapeFirstObject[ detail.subShapeNum ];
S32 end = start + mSubShapeNumObjects[ detail.subShapeNum ];
S32 start = subShapeFirstObject[ detail.subShapeNum ];
S32 end = start + subShapeNumObjects[ detail.subShapeNum ];
for ( S32 o=start; o < end; o++ )
{
const TSShape::Object &object = mObjects[o];
const TSShape::Object &object = objects[o];
if ( detail.objectDetailNum >= object.numMeshes )
continue;
// No mesh or no verts.... nothing to do.
TSMesh *mesh = mMeshes[ object.startMeshIndex + detail.objectDetailNum ];
TSMesh *mesh = meshes[ 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 < mDetails.size(); i++ )
for ( U32 i = 0; i < details.size(); i++ )
{
const TSShape::Detail &detail = mDetails[i];
const String &name = mNames[detail.nameIndex];
const TSShape::Detail &detail = details[i];
const String &name = names[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 = mSubShapeFirstObject[ detail.subShapeNum ];
S32 end = start + mSubShapeNumObjects[ detail.subShapeNum ];
S32 start = subShapeFirstObject[ detail.subShapeNum ];
S32 end = start + subShapeNumObjects[ detail.subShapeNum ];
if ( start >= end )
continue;
for ( S32 o=start; o < end; o++ )
{
const TSShape::Object &object = mObjects[o];
const String &meshName = mNames[ object.nameIndex ];
const TSShape::Object &object = objects[o];
const String &meshName = names[ object.nameIndex ];
if ( object.numMeshes <= detail.objectDetailNum )
continue;
// No mesh, a flat bounds, or no verts.... nothing to do.
TSMesh *mesh = mMeshes[ object.startMeshIndex + detail.objectDetailNum ];
TSMesh *mesh = meshes[ 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->mMesh != this )
if( chunkc->mesh != this )
continue;
if( chunkc->mIdx != curIdx )
if( chunkc->idx != 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->mMesh = this;
cp->mIdx = curIdx;
cp->mesh = this;
cp->idx = curIdx;
cp->mObject = TSStaticPolysoupConvex::smCurObject;
cp->mNormal = p;
cp->mVerts[0] = a;
cp->mVerts[1] = b;
cp->mVerts[2] = c;
cp->mVerts[3] = peak;
cp->normal = p;
cp->verts[0] = a;
cp->verts[1] = b;
cp->verts[2] = c;
cp->verts[3] = peak;
// Update the bounding box.
Box3F &bounds = cp->mBox;
Box3F &bounds = cp->box;
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 < mPrimitives.size(); i++ )
for ( U32 i = 0; i < primitives.size(); i++ )
{
TSDrawPrimitive & draw = mPrimitives[i];
TSDrawPrimitive & draw = primitives[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 + mIndices[start + 0];
U32 idx0 = base + indices[start + 0];
U32 idx1;
U32 idx2 = base + mIndices[start + 1];
U32 idx2 = base + indices[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 + mIndices[start + j];
idx2 = base + indices[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 : mVerts.size() );
mi->SetNbVertices( mVertexData.isReady() ? mNumVerts : verts.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 < mPrimitives.size(); i++ )
for ( U32 i = 0; i < primitives.size(); i++ )
{
TSDrawPrimitive & draw = mPrimitives[i];
TSDrawPrimitive & draw = primitives[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 + mIndices[start + j + 0];
curIts->mVRef[1] = base + mIndices[start + j + 1];
curIts->mVRef[0] = base + mIndices[start + j + 2];
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->mMatIdx = matIndex;
curIts++;
@ -1434,16 +1434,16 @@ void TSMesh::prepOpcodeCollision()
{
AssertFatal( (draw.matIndex & TSDrawPrimitive::TypeMask) == TSDrawPrimitive::Strip,"TSMesh::buildPolyList (2)" );
U32 idx0 = base + mIndices[start + 0];
U32 idx0 = base + indices[start + 0];
U32 idx1;
U32 idx2 = base + mIndices[start + 1];
U32 idx2 = base + indices[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 + mIndices[start + j];
idx2 = base + indices[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( mVerts[i].x, mVerts[i].y, mVerts[i].z );
pts[i].Set( verts[i].x, verts[i].y, verts[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->mNodes[nodeIndex];
const TSShape::Node & node = mShape->nodes[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->mMeshes[f+k])
if (mShape->meshes[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->mNodes.size(); k++)
for (S32 k=nodeIndex+1; k<mShape->nodes.size(); k++)
{
if (mShape->mNodes[k].parentIndex == nodeIndex)
if (mShape->nodes[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->mDetails.size(); i++)
for (i=0; i<mShape->details.size(); i++)
{
const TSDetail & detail = mShape->mDetails[i];
const TSDetail & detail = mShape->details[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->mSubShapeFirstNode.size(); i++)
for (i=0; i<mShape->subShapeFirstNode.size(); i++)
{
S32 a = mShape->mSubShapeFirstNode[i];
S32 b = a + mShape->mSubShapeNumNodes[i];
S32 a = mShape->subShapeFirstNode[i];
S32 b = a + mShape->subShapeNumNodes[i];
dumpLine(avar(" Subtree %i\r\n",i));
// compute detail sizes for each subshape
Vector<S32> detailSizes;
for (S32 l=0;l<mShape->mDetails.size(); l++)
for (S32 l=0;l<mShape->details.size(); l++)
{
if ((mShape->mDetails[l].subShapeNum==i) || (mShape->mDetails[l].subShapeNum==-1))
detailSizes.push_back((S32)mShape->mDetails[l].size);
if ((mShape->details[l].subShapeNum==i) || (mShape->details[l].subShapeNum==-1))
detailSizes.push_back((S32)mShape->details[l].size);
}
for (j=a; j<b; j++)
{
const TSNode & node = mShape->mNodes[j];
const TSNode & node = mShape->nodes[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->mObjects.size(); i++)
for (i=0; i<mShape->objects.size(); i++)
{
if (mShape->mObjects[i].nodeIndex<0) // must be a skin
if (mShape->objects[i].nodeIndex<0) // must be a skin
{
if (!foundSkin)
dumpLine("\r\n Skins:\r\n");
foundSkin=true;
const char * skinName = "";
S32 nameIndex = mShape->mObjects[i].nameIndex;
S32 nameIndex = mShape->objects[i].nameIndex;
if (nameIndex>=0)
skinName = mShape->getName(nameIndex);
dumpLine(avar(" Skin %s with following details: ",skinName));
for (S32 num=0; num<mShape->mObjects[i].numMeshes; num++)
for (S32 num=0; num<mShape->objects[i].numMeshes; num++)
{
if (mShape->mMeshes[mShape->mObjects[i].startMeshIndex + num])
dumpLine(avar(" %i",(S32)mShape->mDetails[num].size));
if (mShape->meshes[mShape->objects[i].startMeshIndex + num])
dumpLine(avar(" %i",(S32)mShape->details[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->mSequences.size(); i++)
for (i = 0; i < mShape->sequences.size(); i++)
{
const char *name = "(none)";
if (mShape->mSequences[i].nameIndex != -1)
name = mShape->getName(mShape->mSequences[i].nameIndex);
if (mShape->sequences[i].nameIndex != -1)
name = mShape->getName(mShape->sequences[i].nameIndex);
dumpLine(avar(" %3d: %s%s%s\r\n", i, name,
mShape->mSequences[i].isCyclic() ? " (cyclic)" : "",
mShape->mSequences[i].isBlend() ? " (blend)" : ""));
mShape->sequences[i].isCyclic() ? " (cyclic)" : "",
mShape->sequences[i].isBlend() ? " (blend)" : ""));
}
if (mShape->mMaterialList)
if (mShape->materialList)
{
TSMaterialList * ml = mShape->mMaterialList;
TSMaterialList * ml = mShape->materialList;
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->mRadius;
mCenter = mShape->mCenter;
mRadius = mShape->radius;
mCenter = mShape->center;
mCachePath = cachePath;

File diff suppressed because it is too large Load diff

View file

@ -105,7 +105,7 @@ class TSMesh
struct TSMeshVertexArray;
protected:
U32 mMeshType;
U32 meshType;
Box3F mBounds;
Point3F mCenter;
F32 mRadius;
@ -140,17 +140,17 @@ class TSMesh
FlagMask = Billboard|BillboardZAxis|HasDetailTexture|UseEncodedNormals
};
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; }
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; }
const Point3F* getNormals( S32 firstVert );
S32 mParentMesh; ///< index into shapes mesh list
S32 mNumFrames;
S32 mNumMatFrames;
S32 mVertsPerFrame;
S32 parentMesh; ///< index into shapes mesh list
S32 numFrames;
S32 numMatFrames;
S32 vertsPerFrame;
/// @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> mVerts;
FreeableVector<Point3F> mNorms;
FreeableVector<Point2F> mTVerts;
FreeableVector<Point4F> mTangents;
FreeableVector<Point3F> verts;
FreeableVector<Point3F> norms;
FreeableVector<Point2F> tverts;
FreeableVector<Point4F> tangents;
// Optional second texture uvs.
FreeableVector<Point2F> mTVerts2;
FreeableVector<Point2F> tverts2;
// Optional vertex colors data.
FreeableVector<ColorI> mColors;
FreeableVector<ColorI> colors;
/// @}
Vector<TSDrawPrimitive> mPrimitives;
Vector<U8> mEncodedNorms;
Vector<U32> mIndices;
Vector<TSDrawPrimitive> primitives;
Vector<U8> encodedNorms;
Vector<U32> indices;
/// billboard data
Point3F mBillboardAxis;
Point3F billboardAxis;
/// @name Convex Hull Data
/// Convex hulls are convex (no angles >= 180º) meshes used for collision
/// @{
Vector<Point3F> mPlaneNormals;
Vector<F32> mPlaneConstants;
Vector<U32> mPlaneMaterials;
S32 mPlanesPerFrame;
U32 mMergeBufferStart;
Vector<Point3F> planeNormals;
Vector<F32> planeConstants;
Vector<U32> planeMaterials;
S32 planesPerFrame;
U32 mergeBufferStart;
/// @}
/// @name Render Methods
@ -501,13 +501,13 @@ public:
typedef TSMesh Parent;
/// Structure containing data needed to batch skinning
BatchData mBatchData;
bool mBatchDataInitialized;
BatchData batchData;
bool batchDataInitialized;
/// vectors that define the vertex, weight, bone tuples
Vector<F32> mWeight;
Vector<S32> mBoneIndex;
Vector<S32> mVertexIndex;
Vector<F32> weight;
Vector<S32> boneIndex;
Vector<S32> vertexIndex;
/// 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->mDetails[dl].subShapeNum;
S32 ss = mShape->details[dl].subShapeNum;
if ( ss < 0 )
return;
S32 od = mShape->mDetails[dl].objectDetailNum;
S32 start = mShape->mSubShapeFirstObject[ss];
S32 end = start + mShape->mSubShapeNumObjects[ss];
S32 od = mShape->details[dl].objectDetailNum;
S32 start = mShape->subShapeFirstObject[ss];
S32 end = start + mShape->subShapeNumObjects[ss];
for ( S32 i = start; i < end; i++ )
{
const TSShape::Object &obj = mShape->mObjects[i];
const TSMesh* mesh = ( od < obj.numMeshes ) ? mShape->mMeshes[obj.startMeshIndex + od] : NULL;
const TSShape::Object &obj = mShape->objects[i];
const TSMesh* mesh = ( od < obj.numMeshes ) ? mShape->meshes[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->mObjects[objIndex];
const TSShape::Object &obj = mShape->objects[objIndex];
for ( S32 i = 0; i < obj.numMeshes; i++ )
{
const TSMesh* mesh = mShape->mMeshes[obj.startMeshIndex + i];
const TSMesh* mesh = mShape->meshes[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->mPrimitives.size(); i++ )
for ( S32 i = 0; i < mesh->primitives.size(); i++ )
{
const TSDrawPrimitive& draw = mesh->mPrimitives[i];
const TSDrawPrimitive& draw = mesh->primitives[i];
if ( (draw.matIndex & TSDrawPrimitive::TypeMask) == TSDrawPrimitive::Triangles )
{
mIndices.merge( &mesh->mIndices[draw.start], draw.numElements );
mIndices.merge( &mesh->indices[draw.start], draw.numElements );
}
else
{
U32 idx0 = mesh->mIndices[draw.start + 0];
U32 idx0 = mesh->indices[draw.start + 0];
U32 idx1;
U32 idx2 = mesh->mIndices[draw.start + 1];
U32 idx2 = mesh->indices[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->mIndices[draw.start + j];
idx2 = mesh->indices[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->mVerts.size();
count = mesh->verts.size();
stride = sizeof(Point3F);
pVert = (U8*)mesh->mVerts.address();
pVert = (U8*)mesh->verts.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)->mMeshes.size())
if (!bool(hShape) || !((TSShape*)hShape)->meshes.size())
{
Con::errorf("TSShape::createMesh: Could not load source mesh from %s", filename.c_str());
return NULL;
}
TSMesh* srcMesh = ((TSShape*)hShape)->mMeshes[0];
TSMesh* srcMesh = ((TSShape*)hShape)->meshes[0];
return mShape->copyMesh( srcMesh );
}
TSMesh* MeshFit::createTriMesh( F32* verts, S32 numVerts, U32* indices, S32 numTris ) const
{
TSMesh* mesh = mShape->copyMesh( NULL );
mesh->mNumFrames = 1;
mesh->mNumMatFrames = 1;
mesh->mVertsPerFrame = numVerts;
mesh->numFrames = 1;
mesh->numMatFrames = 1;
mesh->vertsPerFrame = numVerts;
mesh->setFlags(0);
mesh->mHasColor = false;
mesh->mHasTVert2 = false;
mesh->mNumVerts = numVerts;
mesh->mIndices.reserve( numTris * 3 );
mesh->indices.reserve( numTris * 3 );
for ( S32 i = 0; i < numTris; i++ )
{
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->indices.push_back( indices[i*3 + 0] );
mesh->indices.push_back( indices[i*3 + 2] );
mesh->indices.push_back( indices[i*3 + 1] );
}
mesh->mVerts.set( verts, numVerts );
mesh->verts.set( verts, numVerts );
// Compute mesh normals
mesh->mNorms.setSize( mesh->mVerts.size() );
for (S32 iNorm = 0; iNorm < mesh->mNorms.size(); iNorm++)
mesh->mNorms[iNorm] = Point3F::Zero;
mesh->norms.setSize( mesh->verts.size() );
for (S32 iNorm = 0; iNorm < mesh->norms.size(); iNorm++)
mesh->norms[iNorm] = Point3F::Zero;
// Sum triangle normals for each vertex
for (S32 iInd = 0; iInd < mesh->mIndices.size(); iInd += 3)
for (S32 iInd = 0; iInd < mesh->indices.size(); iInd += 3)
{
// Compute the normal for this triangle
S32 idx0 = mesh->mIndices[iInd + 0];
S32 idx1 = mesh->mIndices[iInd + 1];
S32 idx2 = mesh->mIndices[iInd + 2];
S32 idx0 = mesh->indices[iInd + 0];
S32 idx1 = mesh->indices[iInd + 1];
S32 idx2 = mesh->indices[iInd + 2];
const Point3F& v0 = mesh->mVerts[idx0];
const Point3F& v1 = mesh->mVerts[idx1];
const Point3F& v2 = mesh->mVerts[idx2];
const Point3F& v0 = mesh->verts[idx0];
const Point3F& v1 = mesh->verts[idx1];
const Point3F& v2 = mesh->verts[idx2];
Point3F n;
mCross(v2 - v0, v1 - v0, &n);
n.normalize(); // remove this to use 'weighted' normals (large triangles will have more effect)
mesh->mNorms[idx0] += n;
mesh->mNorms[idx1] += n;
mesh->mNorms[idx2] += n;
mesh->norms[idx0] += n;
mesh->norms[idx1] += n;
mesh->norms[idx2] += n;
}
// Normalize the vertex normals (this takes care of averaging the triangle normals)
for (S32 iNorm = 0; iNorm < mesh->mNorms.size(); iNorm++)
mesh->mNorms[iNorm].normalize();
for (S32 iNorm = 0; iNorm < mesh->norms.size(); iNorm++)
mesh->norms[iNorm].normalize();
// Set some dummy UVs
mesh->mTVerts.setSize( numVerts );
for ( S32 j = 0; j < mesh->mTVerts.size(); j++ )
mesh->mTVerts[j].set( 0, 0 );
mesh->tverts.setSize( numVerts );
for ( S32 j = 0; j < mesh->tverts.size(); j++ )
mesh->tverts[j].set( 0, 0 );
// Add a single triangle-list primitive
mesh->mPrimitives.increment();
mesh->mPrimitives.last().start = 0;
mesh->mPrimitives.last().numElements = mesh->mIndices.size();
mesh->mPrimitives.last().matIndex = TSDrawPrimitive::Triangles |
mesh->primitives.increment();
mesh->primitives.last().start = 0;
mesh->primitives.last().numElements = mesh->indices.size();
mesh->primitives.last().matIndex = TSDrawPrimitive::Triangles |
TSDrawPrimitive::Indexed |
TSDrawPrimitive::NoMaterial;
mesh->createTangents( mesh->mVerts, mesh->mNorms );
mesh->mEncodedNorms.set( NULL,0 );
mesh->createTangents( mesh->verts, mesh->norms );
mesh->encodedNorms.set( NULL,0 );
return mesh;
}
@ -792,10 +792,10 @@ DefineTSShapeConstructorMethod( addPrimitive, bool, ( const char* meshName, cons
}
else
{
for (S32 i = 0; i < mesh->mVerts.size(); i++)
for (S32 i = 0; i < mesh->verts.size(); i++)
{
Point3F v(mesh->mVerts[i]);
mat.mulP( v, &mesh->mVerts[i] );
Point3F v(mesh->verts[i]);
mat.mulP( v, &mesh->verts[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->mSubShapeFirstNode.size(),"TSPartInstance::breakShape: subShape out of range.");
AssertFatal(subShape>=0 && subShape<shape->mShape->subShapeFirstNode.size(),"TSPartInstance::breakShape: subShape out of range.");
S32 start = shape->mShape->mSubShapeFirstNode[subShape];
S32 start = shape->mShape->subShapeFirstNode[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->mNodes[currentNode];
const TSShape::Node * node = &shape->mShape->nodes[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->mObjects[object].nextSibling;
object = shape->mShape->objects[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->mNodes[child].nextSibling;
child = shape->mShape->nodes[child].nextSibling;
}
return;
@ -184,14 +184,14 @@ void TSPartInstance::breakShape(TSShapeInstance * shape, TSPartInstance * curren
while (object>=0)
{
currentPart->addObject(object);
object = shape->mShape->mObjects[object].nextSibling;
object = shape->mShape->objects[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->mNodes[child].nextSibling;
child = shape->mShape->nodes[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()->mDetails[dl].size;
return mSourceShape->getShape()->details[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> 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;
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;
/// @}
/// These are set up at load time, but memory is allocated along with loaded data
/// @{
Vector<S32> mSubShapeFirstTranslucentObject;
Vector<TSMesh*> mMeshes;
Vector<S32> subShapeFirstTranslucentObject;
Vector<TSMesh*> meshes;
/// @}
@ -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> mAlphaIn;
Vector<F32> mAlphaOut
Vector<F32> alphaIn;
Vector<F32> alphaOut
;
/// @}
/// @name Resizeable vectors
/// @{
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;
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;
/// @}
TSMaterialList * mMaterialList;
TSMaterialList * materialList;
/// @name Bounding
/// @{
F32 mRadius;
F32 mTubeRadius;
Point3F mCenter;
Box3F mBounds;
F32 radius;
F32 tubeRadius;
Point3F center;
Box3F bounds;
/// @}
@ -348,7 +348,7 @@ class TSShape
S32 mSmallestVisibleDL; ///< @see mSmallestVisibleSize
S32 mReadVersion; ///< File version that this shape was read from.
U32 mFlags; ///< hasTranslucancy
U32 mData; ///< User-defined data storage.
U32 data; ///< 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 mNodeRotations[seq.baseRotation + rotNum*seq.numKeyframes + keyframeNum].getQuatF(quat);
return nodeRotations[seq.baseRotation + rotNum*seq.numKeyframes + keyframeNum].getQuatF(quat);
}
inline const Point3F & TSShape::getTranslation(const Sequence & seq, S32 keyframeNum, S32 tranNum) const
{
return mNodeTranslations[seq.baseTranslation + tranNum*seq.numKeyframes + keyframeNum];
return nodeTranslations[seq.baseTranslation + tranNum*seq.numKeyframes + keyframeNum];
}
inline F32 TSShape::getUniformScale(const Sequence & seq, S32 keyframeNum, S32 scaleNum) const
{
return mNodeUniformScales[seq.baseScale + scaleNum*seq.numKeyframes + keyframeNum];
return nodeUniformScales[seq.baseScale + scaleNum*seq.numKeyframes + keyframeNum];
}
inline const Point3F & TSShape::getAlignedScale(const Sequence & seq, S32 keyframeNum, S32 scaleNum) const
{
return mNodeAlignedScales[seq.baseScale + scaleNum*seq.numKeyframes + keyframeNum];
return nodeAlignedScales[seq.baseScale + scaleNum*seq.numKeyframes + keyframeNum];
}
inline TSScale & TSShape::getArbitraryScale(const Sequence & seq, S32 keyframeNum, S32 scaleNum, TSScale * scale) const
{
mNodeArbitraryScaleRots[seq.baseScale + scaleNum*seq.numKeyframes + keyframeNum].getQuatF(&scale->mRotate);
scale->mScale = mNodeArbitraryScaleFactors[seq.baseScale + scaleNum*seq.numKeyframes + keyframeNum];
nodeArbitraryScaleRots[seq.baseScale + scaleNum*seq.numKeyframes + keyframeNum].getQuatF(&scale->mRotate);
scale->mScale = nodeArbitraryScaleFactors[seq.baseScale + scaleNum*seq.numKeyframes + keyframeNum];
return *scale;
}
inline const TSShape::ObjectState & TSShape::getObjectState(const Sequence & seq, S32 keyframeNum, S32 objectNum) const
{
return mObjectStates[seq.baseObjectState + objectNum*seq.numKeyframes + keyframeNum];
return objectStates[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.mUpAxis, TSShapeConstructor),
addField( "upAxis", TYPEID< domUpAxisType >(), Offset(mOptions.upAxis, 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.mUnit, TSShapeConstructor),
addField( "unit", TypeF32, Offset(mOptions.unit, 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.mLodType, TSShapeConstructor),
addField( "lodType", TYPEID< ColladaUtils::ImportOptions::eLodType >(), Offset(mOptions.lodType, 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.mSingleDetailSize, TSShapeConstructor),
addField( "singleDetailSize", TypeS32, Offset(mOptions.singleDetailSize, 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.mMatNamePrefix, TSShapeConstructor),
addField( "matNamePrefix", TypeRealString, Offset(mOptions.matNamePrefix, 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.mAlwaysImport, TSShapeConstructor),
addField( "alwaysImport", TypeRealString, Offset(mOptions.alwaysImport, 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.mNeverImport, TSShapeConstructor),
addField( "neverImport", TypeRealString, Offset(mOptions.neverImport, 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.mAlwaysImportMesh, TSShapeConstructor),
addField( "alwaysImportMesh", TypeRealString, Offset(mOptions.alwaysImportMesh, 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.mNeverImportMesh, TSShapeConstructor),
addField( "neverImportMesh", TypeRealString, Offset(mOptions.neverImportMesh, 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.mIgnoreNodeScale, TSShapeConstructor),
addField( "ignoreNodeScale", TypeBool, Offset(mOptions.ignoreNodeScale, 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.mAdjustCenter, TSShapeConstructor),
addField( "adjustCenter", TypeBool, Offset(mOptions.adjustCenter, TSShapeConstructor),
"Translate COLLADA model on import so the origin is at the center. No effect for DTS files." );
addField( "adjustFloor", TypeBool, Offset(mOptions.mAdjustFloor, TSShapeConstructor),
addField( "adjustFloor", TypeBool, Offset(mOptions.adjustFloor, 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.mForceUpdateMaterials, TSShapeConstructor),
addField( "forceUpdateMaterials", TypeBool, Offset(mOptions.forceUpdateMaterials, 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->mNodes[var##Index]); \
TSShape::Node* var = var##Index < 0 ? NULL : &(mShape->nodes[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->mNodes[var##Index]); \
TSShape::Node* var = &(mShape->nodes[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->mObjects[var##Index]); \
TSShape::Object* var = &(mShape->objects[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->mSequences[var##Index]); \
TSShape::Sequence* var = &(mShape->sequences[var##Index]); \
TORQUE_UNUSED(var##Index); \
TORQUE_UNUSED(var);
@ -695,7 +695,7 @@ DefineTSShapeConstructorMethod( getNodeCount, S32, (),,
"%count = %this.getNodeCount();\n"
"@endtsexample\n" )
{
return mShape->mNodes.size();
return mShape->nodes.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->mNodes.size(), "" );
return mShape->getName( mShape->mNodes[index].nameIndex );
CHECK_INDEX_IN_RANGE( getNodeName, index, mShape->nodes.size(), "" );
return mShape->getName( mShape->nodes[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->mNodes[node->parentIndex].nameIndex );
return mShape->getName( mShape->nodes[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->mNodes[nodeChildren[index]].nameIndex );
return mShape->getName( mShape->nodes[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->mObjects[nodeObjects[index]].nameIndex );
return mShape->getName( mShape->objects[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->mDefaultTranslations[nodeIndex];
const Quat16& q16 = mShape->mDefaultRotations[nodeIndex];
pos = mShape->defaultTranslations[nodeIndex];
const Quat16& q16 = mShape->defaultRotations[nodeIndex];
aa.set( q16.getQuatF() );
}
@ -1067,7 +1067,7 @@ DefineTSShapeConstructorMethod( getObjectCount, S32, (),, (), 0,
"%count = %this.getObjectCount();\n"
"@endtsexample\n" )
{
return mShape->mObjects.size();
return mShape->objects.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->mObjects.size(), "" );
CHECK_INDEX_IN_RANGE( getObjectName, index, mShape->objects.size(), "" );
return mShape->getName( mShape->mObjects[index].nameIndex );
return mShape->getName( mShape->objects[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->mNodes[obj->nodeIndex].nameIndex );
return mShape->getName( mShape->nodes[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->mDetails[objectDetails[index]].size);
dSprintf(returnBuffer, bufSize, "%s %d", name, (S32)mShape->details[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->mDetails[objectDetails[index]].size;
return (S32)mShape->details[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->mPrimitives[0].matIndex & TSDrawPrimitive::MaterialMask;
if ((matIndex >= 0) && (matIndex < mShape->mMaterialList->size()))
return mShape->mMaterialList->getMaterialName( matIndex );
S32 matIndex = mesh->primitives[0].matIndex & TSDrawPrimitive::MaterialMask;
if ((matIndex >= 0) && (matIndex < mShape->materialList->size()))
return mShape->materialList->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->mMaterialList->size(); matIndex++ )
for ( matIndex = 0; matIndex < mShape->materialList->size(); matIndex++ )
{
if ( dStrEqual( matName, mShape->mMaterialList->getMaterialName( matIndex ) ) )
if ( dStrEqual( matName, mShape->materialList->getMaterialName( matIndex ) ) )
break;
}
if ( matIndex == mShape->mMaterialList->size() )
if ( matIndex == mShape->materialList->size() )
{
// Add a new material to the shape
U32 flags = TSMaterialList::S_Wrap | TSMaterialList::T_Wrap;
mShape->mMaterialList->push_back( matName, flags );
mShape->materialList->push_back( matName, flags );
}
// Set this material for all primitives in the mesh
for ( S32 i = 0; i < mesh->mPrimitives.size(); i++ )
for ( S32 i = 0; i < mesh->primitives.size(); i++ )
{
U32 matType = mesh->mPrimitives[i].matIndex & ( TSDrawPrimitive::TypeMask | TSDrawPrimitive::Indexed );
mesh->mPrimitives[i].matIndex = ( matType | matIndex );
U32 matType = mesh->primitives[i].matIndex & ( TSDrawPrimitive::TypeMask | TSDrawPrimitive::Indexed );
mesh->primitives[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->mBounds;
return mShape->bounds;
}}
DefineTSShapeConstructorMethod( setBounds, bool, ( Box3F bbox ),,
@ -1444,10 +1444,10 @@ DefineTSShapeConstructorMethod( setBounds, bool, ( Box3F bbox ),,
// Set shape bounds
TSShape* shape = mShape;
shape->mBounds = bbox;
shape->mBounds.getCenter( &shape->mCenter );
shape->mRadius = ( shape->mBounds.maxExtents - shape->mCenter ).len();
shape->mTubeRadius = shape->mRadius;
shape->bounds = bbox;
shape->bounds.getCenter( &shape->center );
shape->radius = ( shape->bounds.maxExtents - shape->center ).len();
shape->tubeRadius = shape->radius;
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->mDetails.size();
return mShape->details.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->mDetails.size(), "" );
CHECK_INDEX_IN_RANGE( getDetailLevelName, index, mShape->details.size(), "" );
return mShape->getName(mShape->mDetails[index].nameIndex);
return mShape->getName(mShape->details[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->mDetails.size(), 0 );
CHECK_INDEX_IN_RANGE( getDetailLevelSize, index, mShape->details.size(), 0 );
return (S32)mShape->mDetails[index].size;
return (S32)mShape->details[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->mDetails.size(); i++ )
for ( S32 i = 0; i < mShape->details.size(); i++ )
{
if ( mShape->mDetails[i].subShapeNum < 0 )
if ( mShape->details[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->mDetails.size(), "" );
CHECK_INDEX_IN_RANGE( getImposterSettings, index, mShape->details.size(), "" );
// Return information about the detail level
const TSShape::Detail& det = mShape->mDetails[index];
const TSShape::Detail& det = mShape->details[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->mSequences.size();
return mShape->sequences.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->mSequences.size(), "" );
CHECK_INDEX_IN_RANGE( getSequenceName, index, mShape->sequences.size(), "" );
return mShape->getName( mShape->mSequences[index].nameIndex );
return mShape->getName( mShape->sequences[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->mGroundTranslations[seq->firstGroundFrame];
const Point3F& p2 = mShape->mGroundTranslations[seq->firstGroundFrame + 1];
const Point3F& p1 = mShape->groundTranslations[seq->firstGroundFrame];
const Point3F& p2 = mShape->groundTranslations[seq->firstGroundFrame + 1];
trans = p2 - p1;
QuatF r1 = mShape->mGroundRotations[seq->firstGroundFrame].getQuatF();
QuatF r2 = mShape->mGroundRotations[seq->firstGroundFrame + 1].getQuatF();
QuatF r1 = mShape->groundRotations[seq->firstGroundFrame].getQuatF();
QuatF r2 = mShape->groundRotations[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->mTriggers[seq->firstTrigger + index];
const TSShape::Trigger& trig = mShape->triggers[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->mSequences.size(); i++)
for (S32 i = 0; i < shape->sequences.size(); i++)
{
const char* seqName = shape->getName( shape->mSequences[i].nameIndex );
const char* seqName = shape->getName( shape->sequences[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->mMaterialList);
setMaterialList(mShape->materialList);
// set up node data
initNodeTransforms();
@ -184,7 +184,7 @@ void TSShapeInstance::buildInstanceData(TSShape * _shape, bool loadMaterials)
initMeshObjects();
// set up subtree data
S32 ss = mShape->mSubShapeFirstNode.size(); // we have this many subtrees
S32 ss = mShape->subShapeFirstNode.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->mNodes.size();
S32 numNodes = mShape->nodes.size();
mNodeTransforms.setSize(numNodes);
}
void TSShapeInstance::initMeshObjects()
{
// add objects to trees
S32 numObjects = mShape->mObjects.size();
S32 numObjects = mShape->objects.size();
mMeshObjects.setSize(numObjects);
for (S32 i=0; i<numObjects; i++)
{
const TSObject * obj = &mShape->mObjects[i];
const TSObject * obj = &mShape->objects[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->mMeshes[obj->startMeshIndex];
objInst->meshList = &mShape->meshes[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->mDetails.size(),
AssertFatal( dl >= 0 && dl < mShape->details.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->mDetails[dl];
const TSDetail *detail = &mShape->details[dl];
const S32 ss = detail->subShapeNum;
if ( ss < 0 )
return;
const S32 start = mShape->mSubShapeFirstObject[ss];
const S32 end = start + mShape->mSubShapeNumObjects[ss];
const S32 start = mShape->subShapeFirstObject[ss];
const S32 end = start + mShape->subShapeNumObjects[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->mAlphaOut[mCurrentDetailLevel];
F32 alphaIn = mShape->mAlphaIn[mCurrentDetailLevel];
F32 alphaOut = mShape->alphaOut[mCurrentDetailLevel];
F32 alphaIn = mShape->alphaIn[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->mDetails.size() && mShape->mDetails[ mCurrentDetailLevel + 1 ].size > 0.0f )
if ( mCurrentDetailLevel + 1 < mShape->details.size() && mShape->details[ 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->mDetails.size() && mShape->mDetails[ mCurrentDetailLevel + 1 ].size > 0.0f )
if ( mCurrentDetailLevel + 1 < mShape->details.size() && mShape->details[ 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->mNames[ nameIndex ];
const char *name = mShape->names[ 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->mDetails.size(),"TSShapeInstance::render" );
AssertFatal( dl >= 0 && dl < mShape->details.size(),"TSShapeInstance::render" );
S32 i;
const TSDetail * detail = &mShape->mDetails[dl];
const TSDetail * detail = &mShape->details[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->mBillboardDetails[ dl ]->render( rdata, mAlphaAlways ? mAlphaAlwaysValue : 1.0f );
mShape->billboardDetails[ dl ]->render( rdata, mAlphaAlways ? mAlphaAlwaysValue : 1.0f );
return;
}
// run through the meshes
S32 start = rdata.isNoRenderNonTranslucent() ? mShape->mSubShapeFirstTranslucentObject[ss] : mShape->mSubShapeFirstObject[ss];
S32 end = rdata.isNoRenderTranslucent() ? mShape->mSubShapeFirstTranslucentObject[ss] : mShape->mSubShapeFirstObject[ss] + mShape->mSubShapeNumObjects[ss];
S32 start = rdata.isNoRenderNonTranslucent() ? mShape->subShapeFirstTranslucentObject[ss] : mShape->subShapeFirstObject[ss];
S32 end = rdata.isNoRenderTranslucent() ? mShape->subShapeFirstTranslucentObject[ss] : mShape->subShapeFirstObject[ss] + mShape->subShapeNumObjects[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->mRadius / scaledDistance ) * state->getWorldToScreenScale().y * pixelScale;
F32 pixelRadius = ( mShape->radius / 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->mDetails[mShape->mSmallestVisibleDL].averageError * 20.0f;
prevErr = 10.0f * mShape->details[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->mDetails[i].averageError;
F32 err0 = 10.0f * mShape->details[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->mMeshes.size(); i++)
for(S32 i=0; i<mShape->meshes.size(); i++)
{
if(mShape->mMeshes[i])
mShape->mMeshes[i]->prepOpcodeCollision();
if(mShape->meshes[i])
mShape->meshes[i]->prepOpcodeCollision();
}
}

View file

@ -531,7 +531,7 @@ protected:
void deltaGround1(TSThread *, F32 start, F32 end, MatrixF& mat);
/// @}
U32 getNumDetails() const { return mShape ? mShape->mDetails.size() : 0; }
U32 getNumDetails() const { return mShape ? mShape->details.size() : 0; }
S32 getCurrentDetail() const { return mCurrentDetailLevel; }
@ -702,20 +702,20 @@ class TSThread
{
friend class TSShapeInstance;
S32 mPriority;
S32 priority;
TSShapeInstance * mShapeInstance; ///< Instance of the shape that this thread animates
S32 mSequence; ///< Sequence this thread will perform
F32 mPos;
S32 sequence; ///< Sequence this thread will perform
F32 pos;
F32 mTimeScale; ///< How fast to play through the sequence
F32 timeScale; ///< How fast to play through the sequence
S32 mKeyNum1; ///< Keyframe at or before current position
S32 mKeyNum2; ///< Keyframe at or after current position
F32 mKeyPos;
S32 keyNum1; ///< Keyframe at or before current position
S32 keyNum2; ///< Keyframe at or after current position
F32 keyPos;
bool mBlendDisabled; ///< Blend with other sequences?
bool blendDisabled; ///< 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
} mTransitionData;
} transitionData;
struct
{
F32 start;
F32 end;
S32 loop;
} mPath;
bool mMakePath;
} path;
bool makePath;
/// 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 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); }
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); }
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 (!mObjects.address() || !mMeshes.address() || !numSkins)
if (!objects.address() || !meshes.address() || !numSkins)
// not ready for this yet, will catch it on the next pass
return;
S32 numObjects = mObjects.size();
TSObject * newObjects = mObjects.address() + mObjects.size();
TSSkinMesh ** skins = (TSSkinMesh**)&mMeshes[numMeshes];
S32 numObjects = objects.size();
TSObject * newObjects = objects.address() + objects.size();
TSSkinMesh ** skins = (TSSkinMesh**)&meshes[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++];
mObjects.increment();
objects.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)
{
mObjects.decrement();
objects.decrement();
numSkinObjects--;
}
}
dMemcpy(skins,skinsCopy.address(),skinsCopy.size()*sizeof(TSSkinMesh*));
if (mSubShapeFirstObject.size()==1)
if (subShapeFirstObject.size()==1)
// as long as only one subshape, we'll now be rendered
mSubShapeNumObjects[0] += numSkinObjects;
subShapeNumObjects[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(mObjectStates.address()+numObjects+numSkinObjects,mObjectStates.address()+numObjects,(mObjectStates.size()-numObjects)*sizeof(ObjectState));
dMemmove(objectStates.address()+numObjects+numSkinObjects,objectStates.address()+numObjects,(objectStates.size()-numObjects)*sizeof(ObjectState));
for (i=numObjects; i<numObjects+numSkinObjects; i++)
{
mObjectStates[i].vis=1.0f;
mObjectStates[i].frameIndex=0;
mObjectStates[i].matFrameIndex=0;
objectStates[i].vis=1.0f;
objectStates[i].frameIndex=0;
objectStates[i].matFrameIndex=0;
}
for (i=0;i<mSequences.size();i++)
for (i=0;i<sequences.size();i++)
{
mSequences[i].baseObjectState += numSkinObjects;
sequences[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 = mNodes.size();
sz = nodes.size();
s->write(sz);
for (i=0;i<mNodes.size();i++)
writeName(s,mNodes[i].nameIndex);
for (i=0;i<nodes.size();i++)
writeName(s,nodes[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(mObjects.size());
s->write(objects.size());
// write node states -- skip default node states
s->write(mNodeRotations.size());
for (i=0;i<mNodeRotations.size();i++)
s->write(nodeRotations.size());
for (i=0;i<nodeRotations.size();i++)
{
s->write(mNodeRotations[i].x);
s->write(mNodeRotations[i].y);
s->write(mNodeRotations[i].z);
s->write(mNodeRotations[i].w);
s->write(nodeRotations[i].x);
s->write(nodeRotations[i].y);
s->write(nodeRotations[i].z);
s->write(nodeRotations[i].w);
}
s->write(mNodeTranslations.size());
for (i=0;i<mNodeTranslations.size(); i++)
s->write(nodeTranslations.size());
for (i=0;i<nodeTranslations.size(); i++)
{
s->write(mNodeTranslations[i].x);
s->write(mNodeTranslations[i].y);
s->write(mNodeTranslations[i].z);
s->write(nodeTranslations[i].x);
s->write(nodeTranslations[i].y);
s->write(nodeTranslations[i].z);
}
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(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(mNodeAlignedScales[i].x);
s->write(mNodeAlignedScales[i].y);
s->write(mNodeAlignedScales[i].z);
s->write(nodeAlignedScales[i].x);
s->write(nodeAlignedScales[i].y);
s->write(nodeAlignedScales[i].z);
}
s->write(mNodeArbitraryScaleRots.size());
for (i=0;i<mNodeArbitraryScaleRots.size();i++)
s->write(nodeArbitraryScaleRots.size());
for (i=0;i<nodeArbitraryScaleRots.size();i++)
{
s->write(mNodeArbitraryScaleRots[i].x);
s->write(mNodeArbitraryScaleRots[i].y);
s->write(mNodeArbitraryScaleRots[i].z);
s->write(mNodeArbitraryScaleRots[i].w);
s->write(nodeArbitraryScaleRots[i].x);
s->write(nodeArbitraryScaleRots[i].y);
s->write(nodeArbitraryScaleRots[i].z);
s->write(nodeArbitraryScaleRots[i].w);
}
for (i=0;i<mNodeArbitraryScaleFactors.size();i++)
for (i=0;i<nodeArbitraryScaleFactors.size();i++)
{
s->write(mNodeArbitraryScaleFactors[i].x);
s->write(mNodeArbitraryScaleFactors[i].y);
s->write(mNodeArbitraryScaleFactors[i].z);
s->write(nodeArbitraryScaleFactors[i].x);
s->write(nodeArbitraryScaleFactors[i].y);
s->write(nodeArbitraryScaleFactors[i].z);
}
s->write(mGroundTranslations.size());
for (i=0;i<mGroundTranslations.size();i++)
s->write(groundTranslations.size());
for (i=0;i<groundTranslations.size();i++)
{
s->write(mGroundTranslations[i].x);
s->write(mGroundTranslations[i].y);
s->write(mGroundTranslations[i].z);
s->write(groundTranslations[i].x);
s->write(groundTranslations[i].y);
s->write(groundTranslations[i].z);
}
for (i=0;i<mGroundRotations.size();i++)
for (i=0;i<groundRotations.size();i++)
{
s->write(mGroundRotations[i].x);
s->write(mGroundRotations[i].y);
s->write(mGroundRotations[i].z);
s->write(mGroundRotations[i].w);
s->write(groundRotations[i].x);
s->write(groundRotations[i].y);
s->write(groundRotations[i].z);
s->write(groundRotations[i].w);
}
// write object states -- legacy..no object states
s->write((S32)0);
// write sequences
s->write(mSequences.size());
for (i=0;i<mSequences.size();i++)
s->write(sequences.size());
for (i=0;i<sequences.size();i++)
{
Sequence & seq = mSequences[i];
Sequence & seq = sequences[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(mTriggers.size());
for (i=0; i<mTriggers.size(); i++)
s->write(triggers.size());
for (i=0; i<triggers.size(); i++)
{
s->write(mTriggers[i].state);
s->write(mTriggers[i].pos);
s->write(triggers[i].state);
s->write(triggers[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( mNodes.size() );
for ( S32 i = 0; i < mNodes.size(); i++ )
writeName( s, mNodes[i].nameIndex );
s->write( nodes.size() );
for ( S32 i = 0; i < nodes.size(); i++ )
writeName( s, nodes[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( mObjects.size() );
s->write( objects.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( mNodeRotations[i].x );
s->write( mNodeRotations[i].y );
s->write( mNodeRotations[i].z );
s->write( mNodeRotations[i].w );
s->write( nodeRotations[i].x );
s->write( nodeRotations[i].y );
s->write( nodeRotations[i].z );
s->write( nodeRotations[i].w );
}
count = seq.translationMatters.count() * seq.numKeyframes;
s->write( count );
for ( S32 i = seq.baseTranslation; i < seq.baseTranslation + count; i++ )
{
s->write( mNodeTranslations[i].x );
s->write( mNodeTranslations[i].y );
s->write( mNodeTranslations[i].z );
s->write( nodeTranslations[i].x );
s->write( nodeTranslations[i].y );
s->write( nodeTranslations[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( mNodeUniformScales[i] );
s->write( nodeUniformScales[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( mNodeAlignedScales[i].x );
s->write( mNodeAlignedScales[i].y );
s->write( mNodeAlignedScales[i].z );
s->write( nodeAlignedScales[i].x );
s->write( nodeAlignedScales[i].y );
s->write( nodeAlignedScales[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( mNodeArbitraryScaleRots[i].x );
s->write( mNodeArbitraryScaleRots[i].y );
s->write( mNodeArbitraryScaleRots[i].z );
s->write( mNodeArbitraryScaleRots[i].w );
s->write( nodeArbitraryScaleRots[i].x );
s->write( nodeArbitraryScaleRots[i].y );
s->write( nodeArbitraryScaleRots[i].z );
s->write( nodeArbitraryScaleRots[i].w );
}
for ( S32 i = seq.baseScale; i < seq.baseScale + count; i++ )
{
s->write( mNodeArbitraryScaleFactors[i].x );
s->write( mNodeArbitraryScaleFactors[i].y );
s->write( mNodeArbitraryScaleFactors[i].z );
s->write( nodeArbitraryScaleFactors[i].x );
s->write( nodeArbitraryScaleFactors[i].y );
s->write( nodeArbitraryScaleFactors[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( mGroundTranslations[i].x );
s->write( mGroundTranslations[i].y );
s->write( mGroundTranslations[i].z );
s->write( groundTranslations[i].x );
s->write( groundTranslations[i].y );
s->write( groundTranslations[i].z );
}
for ( S32 i = seq.firstGroundFrame; i < seq.firstGroundFrame + seq.numGroundFrames; i++ )
{
s->write( mGroundRotations[i].x );
s->write( mGroundRotations[i].y );
s->write( mGroundRotations[i].z );
s->write( mGroundRotations[i].w );
s->write( groundRotations[i].x );
s->write( groundRotations[i].y );
s->write( groundRotations[i].z );
s->write( groundRotations[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( mTriggers[i].state );
s->write( mTriggers[i].pos );
s->write( triggers[i].state );
s->write( triggers[i].pos );
}
smVersion = currentVersion;
@ -460,7 +460,7 @@ bool TSShape::importSequences(Stream * s, const String& sequencePath)
for (i=0;i<sz;i++)
{
U32 startSize = mNames.size();
U32 startSize = names.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 (mNames.size() != startSize)
if (names.size() != startSize)
{
mNames.decrement();
names.decrement();
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());
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());
}
}
}
@ -487,9 +487,9 @@ bool TSShape::importSequences(Stream * s, const String& sequencePath)
s->read(&oldShapeNumObjects);
// adjust all the new keyframes
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
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
// 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 = mGroundTranslations.size();
mGroundTranslations.setSize(sz+oldSz);
S32 oldSz = groundTranslations.size();
groundTranslations.setSize(sz+oldSz);
for (i=oldSz;i<sz+oldSz;i++)
{
s->read(&mGroundTranslations[i].x);
s->read(&mGroundTranslations[i].y);
s->read(&mGroundTranslations[i].z);
s->read(&groundTranslations[i].x);
s->read(&groundTranslations[i].y);
s->read(&groundTranslations[i].z);
}
mGroundRotations.setSize(sz+oldSz);
groundRotations.setSize(sz+oldSz);
for (i=oldSz;i<sz+oldSz;i++)
{
s->read(&mGroundRotations[i].x);
s->read(&mGroundRotations[i].y);
s->read(&mGroundRotations[i].z);
s->read(&mGroundRotations[i].w);
s->read(&groundRotations[i].x);
s->read(&groundRotations[i].y);
s->read(&groundRotations[i].z);
s->read(&groundRotations[i].w);
}
}
else
@ -590,28 +590,28 @@ bool TSShape::importSequences(Stream * s, const String& sequencePath)
// read sequences
s->read(&sz);
S32 startSeqNum = mSequences.size();
S32 startSeqNum = sequences.size();
for (i=0;i<sz;i++)
{
mSequences.increment();
Sequence & seq = mSequences.last();
sequences.increment();
Sequence & seq = sequences.last();
// read name
seq.nameIndex = readName(s,true);
// read the rest of the sequence
seq.read(s,false);
seq.baseRotation = mNodeRotations.size();
seq.baseTranslation = mNodeTranslations.size();
seq.baseRotation = nodeRotations.size();
seq.baseTranslation = nodeTranslations.size();
if (smReadVersion > 21)
{
if (seq.animatesUniformScale())
seq.baseScale = mNodeUniformScales.size();
seq.baseScale = nodeUniformScales.size();
else if (seq.animatesAlignedScale())
seq.baseScale = mNodeAlignedScales.size();
seq.baseScale = nodeAlignedScales.size();
else if (seq.animatesArbitraryScale())
seq.baseScale = mNodeArbitraryScaleFactors.size();
seq.baseScale = nodeArbitraryScaleFactors.size();
}
// remap the node matters arrays
@ -633,18 +633,18 @@ bool TSShape::importSequences(Stream * s, const String& sequencePath)
}
// resize node transform arrays
mNodeTranslations.increment(newTransMembership.count() * seq.numKeyframes);
mNodeRotations.increment(newRotMembership.count() * seq.numKeyframes);
nodeTranslations.increment(newTransMembership.count() * seq.numKeyframes);
nodeRotations.increment(newRotMembership.count() * seq.numKeyframes);
if (seq.flags & TSShape::ArbitraryScale)
{
S32 scaleCount = newScaleMembership.count() * seq.numKeyframes;
mNodeArbitraryScaleRots.increment(scaleCount);
mNodeArbitraryScaleFactors.increment(scaleCount);
nodeArbitraryScaleRots.increment(scaleCount);
nodeArbitraryScaleFactors.increment(scaleCount);
}
else if (seq.flags & TSShape::AlignedScale)
mNodeAlignedScales.increment(newScaleMembership.count() * seq.numKeyframes);
nodeAlignedScales.increment(newScaleMembership.count() * seq.numKeyframes);
else
mNodeUniformScales.increment(newScaleMembership.count() * seq.numKeyframes);
nodeUniformScales.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(&mNodeTranslations[dest], &seqTranslations[src], seq.numKeyframes);
dCopyArray(&nodeTranslations[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(&mNodeRotations[dest], &seqRotations[src], seq.numKeyframes);
dCopyArray(&nodeRotations[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(&mNodeArbitraryScaleRots[dest], &seqArbitraryScaleRots[src], seq.numKeyframes);
dCopyArray(&mNodeArbitraryScaleFactors[dest], &seqArbitraryScaleFactors[src], seq.numKeyframes);
dCopyArray(&nodeArbitraryScaleRots[dest], &seqArbitraryScaleRots[src], seq.numKeyframes);
dCopyArray(&nodeArbitraryScaleFactors[dest], &seqArbitraryScaleFactors[src], seq.numKeyframes);
}
else if (seq.flags & TSShape::AlignedScale)
dCopyArray(&mNodeAlignedScales[dest], &seqAlignedScales[src], seq.numKeyframes);
dCopyArray(&nodeAlignedScales[dest], &seqAlignedScales[src], seq.numKeyframes);
else
dCopyArray(&mNodeUniformScales[dest], &seqUniformScales[src], seq.numKeyframes);
dCopyArray(&nodeUniformScales[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 += mTriggers.size();
seq.firstTrigger += triggers.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<mSequences.size(); i++)
for (i=startSeqNum; i<sequences.size(); i++)
{
// move ground transform data to ground vectors
Sequence & seq = mSequences[i];
S32 oldSz = mGroundTranslations.size();
mGroundTranslations.setSize(oldSz+seq.numGroundFrames);
mGroundRotations.setSize(oldSz+seq.numGroundFrames);
Sequence & seq = sequences[i];
S32 oldSz = groundTranslations.size();
groundTranslations.setSize(oldSz+seq.numGroundFrames);
groundRotations.setSize(oldSz+seq.numGroundFrames);
for (S32 j=0;j<seq.numGroundFrames;j++)
{
mGroundTranslations[j+oldSz] = mNodeTranslations[seq.firstGroundFrame+adjNodeTrans+j];
mGroundRotations[j+oldSz] = mNodeRotations[seq.firstGroundFrame+adjNodeRots+j];
groundTranslations[j+oldSz] = nodeTranslations[seq.firstGroundFrame+adjNodeTrans+j];
groundRotations[j+oldSz] = nodeRotations[seq.firstGroundFrame+adjNodeRots+j];
}
seq.firstGroundFrame = oldSz;
}
}
// add the new triggers
S32 oldSz = mTriggers.size();
S32 oldSz = triggers.size();
s->read(&sz);
mTriggers.setSize(oldSz+sz);
triggers.setSize(oldSz+sz);
for (S32 i=0; i<sz;i++)
{
s->read(&mTriggers[i+oldSz].state);
s->read(&mTriggers[i+oldSz].pos);
s->read(&triggers[i+oldSz].state);
s->read(&triggers[i+oldSz].pos);
}
if (smInitOnRead)
@ -846,7 +846,7 @@ void TSShape::writeName(Stream * s, S32 nameIndex)
{
const char * name = "";
if (nameIndex>=0)
name = mNames[nameIndex];
name = names[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 = mNames.size();
mNames.increment();
mNames.last() = buffer;
nameIndex = names.size();
names.increment();
names.last() = buffer;
}
}

View file

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

View file

@ -48,14 +48,14 @@ public:
///< if frontCluster==backCluster, no plane to test against...
};
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)
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)
/// sometimes, we want to write the depth value to the frame buffer even when object is translucent
bool mAlwaysWriteDepth;
bool alwaysWriteDepth;
// render methods..
void render(S32 frame, S32 matFrame, TSMaterialList *);
@ -71,7 +71,7 @@ public:
void disassemble();
TSSortedMesh() {
mMeshType = SortedMeshType;
meshType = 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->mGroundTranslations[getSequence()->firstGroundFrame + frame - 1];
q1 = &mShapeInstance->mShape->mGroundRotations[getSequence()->firstGroundFrame + frame - 1].getQuatF(&rot1);
p1 = &mShapeInstance->mShape->groundTranslations[getSequence()->firstGroundFrame + frame - 1];
q1 = &mShapeInstance->mShape->groundRotations[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->mGroundTranslations[getSequence()->firstGroundFrame + frame];
q2 = &mShapeInstance->mShape->mGroundRotations[getSequence()->firstGroundFrame + frame].getQuatF(&rot2);
p2 = &mShapeInstance->mShape->groundTranslations[getSequence()->firstGroundFrame + frame];
q2 = &mShapeInstance->mShape->groundRotations[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->mSequences.size()>seq && toPos>=0.0f && toPos<=1.0f,
AssertFatal(shape && shape->sequences.size()>seq && toPos>=0.0f && toPos<=1.0f,
"TSThread::setSequence: invalid shape handle, sequence number, or position.");
mShapeInstance->clearTransition(this);
mSequence = seq;
mPriority = getSequence()->priority;
mPos = toPos;
mMakePath = getSequence()->makePath();
mPath.start = mPath.end = 0;
mPath.loop = 0;
sequence = seq;
priority = getSequence()->priority;
pos = toPos;
makePath = getSequence()->makePath();
path.start = path.end = 0;
path.loop = 0;
// 1.0f doesn't exist on cyclic sequences
if (mPos>0.9999f && getSequence()->isCyclic())
mPos = 0.9999f;
if (pos>0.9999f && getSequence()->isCyclic())
pos = 0.9999f;
// select keyframes
selectKeyframes(mPos,getSequence(),&mKeyNum1,&mKeyNum2,&mKeyPos);
selectKeyframes(pos,getSequence(),&keyNum1,&keyNum2,&keyPos);
}
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 (mTransitionData.inTransition)
if (transitionData.inTransition)
{
mTransitionData.oldRotationNodes.overlap(getSequence()->rotationMatters);
mTransitionData.oldTranslationNodes.overlap(getSequence()->translationMatters);
mTransitionData.oldScaleNodes.overlap(getSequence()->scaleMatters);
transitionData.oldRotationNodes.overlap(getSequence()->rotationMatters);
transitionData.oldTranslationNodes.overlap(getSequence()->translationMatters);
transitionData.oldScaleNodes.overlap(getSequence()->scaleMatters);
}
else
{
mTransitionData.oldRotationNodes = getSequence()->rotationMatters;
mTransitionData.oldTranslationNodes = getSequence()->translationMatters;
mTransitionData.oldScaleNodes = getSequence()->scaleMatters;
transitionData.oldRotationNodes = getSequence()->rotationMatters;
transitionData.oldTranslationNodes = getSequence()->translationMatters;
transitionData.oldScaleNodes = getSequence()->scaleMatters;
}
// set time characteristics of transition
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;
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;
// in transition...
mTransitionData.inTransition = true;
transitionData.inTransition = true;
// set target sequence data
mSequence = seq;
mPriority = getSequence()->priority;
mPos = toPos;
mMakePath = getSequence()->makePath();
mPath.start = mPath.end = 0;
mPath.loop = 0;
sequence = seq;
priority = getSequence()->priority;
pos = toPos;
makePath = getSequence()->makePath();
path.start = path.end = 0;
path.loop = 0;
// 1.0f doesn't exist on cyclic sequences
if (mPos>0.9999f && getSequence()->isCyclic())
mPos = 0.9999f;
if (pos>0.9999f && getSequence()->isCyclic())
pos = 0.9999f;
// select keyframes
selectKeyframes(mPos,getSequence(),&mKeyNum1,&mKeyNum2,&mKeyPos);
selectKeyframes(pos,getSequence(),&keyNum1,&keyNum2,&keyPos);
}
bool TSThread::isInTransition()
{
return mTransitionData.inTransition;
return transitionData.inTransition;
}
void TSThread::animateTriggers()
@ -242,30 +242,30 @@ void TSThread::animateTriggers()
if (!getSequence()->numTriggers)
return;
switch (mPath.loop)
switch (path.loop)
{
case -1 :
activateTriggers(mPath.start,0);
activateTriggers(1,mPath.end);
activateTriggers(path.start,0);
activateTriggers(1,path.end);
break;
case 0 :
activateTriggers(mPath.start,mPath.end);
activateTriggers(path.start,path.end);
break;
case 1 :
activateTriggers(mPath.start,1);
activateTriggers(0,mPath.end);
activateTriggers(path.start,1);
activateTriggers(0,path.end);
break;
default:
{
if (mPath.loop>0)
if (path.loop>0)
{
activateTriggers(mPath.end,1);
activateTriggers(0,mPath.end);
activateTriggers(path.end,1);
activateTriggers(0,path.end);
}
else
{
activateTriggers(mPath.end,0);
activateTriggers(1,mPath.end);
activateTriggers(path.end,0);
activateTriggers(1,path.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->mTriggers[i].pos)
if (a>lastPos && a<=shape->triggers[i].pos)
aIndex = i;
// is b between this trigger and previous one...
if (b>lastPos && b<=shape->mTriggers[i].pos)
if (b>lastPos && b<=shape->triggers[i].pos)
bIndex = i;
lastPos = shape->mTriggers[i].pos;
lastPos = shape->triggers[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->mTriggers[i].state;
U32 state = shape->triggers[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->mTriggers[i].state;
U32 state = shape->triggers[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 mTransitionData.inTransition ? mTransitionData.pos : mPos;
return transitionData.inTransition ? transitionData.pos : pos;
}
F32 TSThread::getTime()
{
return mTransitionData.inTransition ? mTransitionData.pos * mTransitionData.duration : mPos * getSequence()->duration;
return transitionData.inTransition ? transitionData.pos * transitionData.duration : pos * getSequence()->duration;
}
F32 TSThread::getDuration()
{
return mTransitionData.inTransition ? mTransitionData.duration : getSequence()->duration;
return transitionData.inTransition ? transitionData.duration : getSequence()->duration;
}
F32 TSThread::getScaledDuration()
{
return getDuration() / mFabs(mTimeScale);
return getDuration() / mFabs(timeScale);
}
F32 TSThread::getTimeScale()
{
return mTimeScale;
return timeScale;
}
void TSThread::setTimeScale(F32 ts)
{
mTimeScale = ts;
timeScale = 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 | (mTransitionData.inTransition ? TSShapeInstance::TransformDirty : 0);
for (S32 i=0; i<mShapeInstance->getShape()->mSubShapeFirstNode.size(); i++)
U32 dirtyFlags = getSequence()->dirtyFlags | (transitionData.inTransition ? TSShapeInstance::TransformDirty : 0);
for (S32 i=0; i<mShapeInstance->getShape()->subShapeFirstNode.size(); i++)
mShapeInstance->mDirtyFlags[i] |= dirtyFlags;
}
if (mTransitionData.inTransition)
if (transitionData.inTransition)
{
mTransitionData.pos += mTransitionData.direction * delta;
if (mTransitionData.pos<0 || mTransitionData.pos>=1.0f)
transitionData.pos += transitionData.direction * delta;
if (transitionData.pos<0 || transitionData.pos>=1.0f)
{
mShapeInstance->clearTransition(this);
if (mTransitionData.pos<0.0f)
if (transitionData.pos<0.0f)
// return to old sequence
mShapeInstance->setSequence(this,mTransitionData.oldSequence,mTransitionData.oldPos);
mShapeInstance->setSequence(this,transitionData.oldSequence,transitionData.oldPos);
}
// re-adjust delta to be correct time-wise
delta *= mTransitionData.targetScale * mTransitionData.duration / getSequence()->duration;
delta *= transitionData.targetScale * transitionData.duration / getSequence()->duration;
}
// even if we are in a transition, keep playing the sequence
if (mMakePath)
if (makePath)
{
mPath.start = mPos;
mPos += delta;
path.start = pos;
pos += delta;
if (!getSequence()->isCyclic())
{
mPos = mClampF(mPos , 0.0f, 1.0f);
mPath.loop = 0;
pos = mClampF(pos , 0.0f, 1.0f);
path.loop = 0;
}
else
{
mPath.loop = (S32)mPos;
if (mPos < 0.0f)
mPath.loop--;
mPos -= mPath.loop;
path.loop = (S32)pos;
if (pos < 0.0f)
path.loop--;
pos -= path.loop;
// following necessary because of floating point roundoff errors
if (mPos < 0.0f) mPos += 1.0f;
if (mPos >= 1.0f) mPos -= 1.0f;
if (pos < 0.0f) pos += 1.0f;
if (pos >= 1.0f) pos -= 1.0f;
}
mPath.end = mPos;
path.end = pos;
animateTriggers(); // do this automatically...no need for user to call it
AssertFatal(mPos>=0.0f && mPos<=1.0f,"TSThread::advancePos (1)");
AssertFatal(!getSequence()->isCyclic() || mPos<1.0f,"TSThread::advancePos (2)");
AssertFatal(pos>=0.0f && pos<=1.0f,"TSThread::advancePos (1)");
AssertFatal(!getSequence()->isCyclic() || pos<1.0f,"TSThread::advancePos (2)");
}
else
{
mPos += delta;
pos += delta;
if (!getSequence()->isCyclic())
mPos = mClampF(mPos, 0.0f, 1.0f);
pos = mClampF(pos, 0.0f, 1.0f);
else
{
mPos -= S32(mPos);
pos -= S32(pos);
// following necessary because of floating point roundoff errors
if (mPos < 0.0f) mPos += 1.0f;
if (mPos >= 1.0f) mPos -= 1.0f;
if (pos < 0.0f) pos += 1.0f;
if (pos >= 1.0f) pos -= 1.0f;
}
AssertFatal(mPos>=0.0f && mPos<=1.0f,"TSThread::advancePos (3)");
AssertFatal(!getSequence()->isCyclic() || mPos<1.0f,"TSThread::advancePos (4)");
AssertFatal(pos>=0.0f && pos<=1.0f,"TSThread::advancePos (3)");
AssertFatal(!getSequence()->isCyclic() || pos<1.0f,"TSThread::advancePos (4)");
}
// select keyframes
selectKeyframes(mPos,getSequence(),&mKeyNum1,&mKeyNum2,&mKeyPos);
selectKeyframes(pos,getSequence(),&keyNum1,&keyNum2,&keyPos);
}
void TSThread::advanceTime(F32 delta)
{
advancePos(mTimeScale * delta / getDuration());
advancePos(timeScale * delta / getDuration());
}
void TSThread::setPos(F32 pos)
@ -432,40 +432,40 @@ void TSThread::setPos(F32 pos)
void TSThread::setTime(F32 time)
{
setPos(mTimeScale * time/getDuration());
setPos(timeScale * time/getDuration());
}
S32 TSThread::getKeyframeCount()
{
AssertFatal(!mTransitionData.inTransition,"TSThread::getKeyframeCount: not while in transition");
AssertFatal(!transitionData.inTransition,"TSThread::getKeyframeCount: not while in transition");
return getSequence()->numKeyframes + 1;
}
S32 TSThread::getKeyframeNumber()
{
AssertFatal(!mTransitionData.inTransition,"TSThread::getKeyframeNumber: not while in transition");
AssertFatal(!transitionData.inTransition,"TSThread::getKeyframeNumber: not while in transition");
return mKeyNum1;
return keyNum1;
}
void TSThread::setKeyframeNumber(S32 kf)
{
AssertFatal(kf>=0 && kf<= getSequence()->numKeyframes,
"TSThread::setKeyframeNumber: invalid frame specified.");
AssertFatal(!mTransitionData.inTransition,"TSThread::setKeyframeNumber: not while in transition");
AssertFatal(!transitionData.inTransition,"TSThread::setKeyframeNumber: not while in transition");
mKeyNum1 = mKeyNum2 = kf;
mKeyPos = 0;
mPos = 0;
keyNum1 = keyNum2 = kf;
keyPos = 0;
pos = 0;
}
TSThread::TSThread(TSShapeInstance * _shapeInst)
{
mTimeScale = 1.0f;
timeScale = 1.0f;
mShapeInstance = _shapeInst;
mTransitionData.inTransition = false;
mBlendDisabled = false;
transitionData.inTransition = false;
blendDisabled = 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 (mPriority > th2.mPriority)
if (priority > th2.priority)
ret = -1;
if (th2.mPriority > mPriority)
if (th2.priority > priority)
ret = 1;
return ret;
}
@ -500,7 +500,7 @@ S32 TSThread::operator<(const TSThread & th2) const
TSThread * TSShapeInstance::addThread()
{
if (mShape->mSequences.empty())
if (mShape->sequences.empty())
return NULL;
mThreadList.increment();
@ -542,7 +542,7 @@ U32 TSShapeInstance::threadCount()
void TSShapeInstance::setSequence(TSThread * thread, S32 seq, F32 pos)
{
if ( (thread->mTransitionData.inTransition && mTransitionThreads.size()>1) || mTransitionThreads.size()>0)
if ( (thread->transitionData.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->mSequence;
return (U32)thread->sequence;
}
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->mTransitionData.oldRotationNodes);
mTransitionRotationNodes.overlap(thread->transitionData.oldRotationNodes);
mTransitionRotationNodes.overlap(thread->getSequence()->rotationMatters);
mTransitionTranslationNodes.overlap(thread->mTransitionData.oldTranslationNodes);
mTransitionTranslationNodes.overlap(thread->transitionData.oldTranslationNodes);
mTransitionTranslationNodes.overlap(thread->getSequence()->translationMatters);
mTransitionScaleNodes.overlap(thread->mTransitionData.oldScaleNodes);
mTransitionScaleNodes.overlap(thread->transitionData.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->mTransitionData.inTransition)
if (!thread->transitionData.inTransition)
return;
// if other transitions are still playing,
@ -614,7 +614,7 @@ void TSShapeInstance::clearTransition(TSThread * thread)
animateNodeSubtrees();
// turn off transition...
thread->mTransitionData.inTransition = false;
thread->transitionData.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]->mTransitionData.oldRotationNodes);
mTransitionRotationNodes.overlap(mTransitionThreads[i]->transitionData.oldRotationNodes);
mTransitionRotationNodes.overlap(mTransitionThreads[i]->getSequence()->rotationMatters);
mTransitionTranslationNodes.overlap(mTransitionThreads[i]->mTransitionData.oldTranslationNodes);
mTransitionTranslationNodes.overlap(mTransitionThreads[i]->transitionData.oldTranslationNodes);
mTransitionTranslationNodes.overlap(mTransitionThreads[i]->getSequence()->translationMatters);
mTransitionScaleNodes.overlap(mTransitionThreads[i]->mTransitionData.oldScaleNodes);
mTransitionScaleNodes.overlap(mTransitionThreads[i]->transitionData.oldScaleNodes);
mTransitionScaleNodes.overlap(mTransitionThreads[i]->getSequence()->scaleMatters);
}
@ -656,9 +656,9 @@ void TSShapeInstance::updateTransitions()
updateTransitionNodeTransforms(transitionNodes);
S32 i;
mNodeReferenceRotations.setSize(mShape->mNodes.size());
mNodeReferenceTranslations.setSize(mShape->mNodes.size());
for (i=0; i<mShape->mNodes.size(); i++)
mNodeReferenceRotations.setSize(mShape->nodes.size());
mNodeReferenceTranslations.setSize(mShape->nodes.size());
for (i=0; i<mShape->nodes.size(); i++)
{
if (mTransitionRotationNodes.test(i))
mNodeReferenceRotations[i].set(smNodeCurrentRotations[i]);
@ -674,8 +674,8 @@ void TSShapeInstance::updateTransitions()
if (animatesUniformScale())
{
mNodeReferenceUniformScales.setSize(mShape->mNodes.size());
for (i=0; i<mShape->mNodes.size(); i++)
mNodeReferenceUniformScales.setSize(mShape->nodes.size());
for (i=0; i<mShape->nodes.size(); i++)
{
if (mTransitionScaleNodes.test(i))
mNodeReferenceUniformScales[i] = smNodeCurrentUniformScales[i];
@ -683,8 +683,8 @@ void TSShapeInstance::updateTransitions()
}
else if (animatesAlignedScale())
{
mNodeReferenceScaleFactors.setSize(mShape->mNodes.size());
for (i=0; i<mShape->mNodes.size(); i++)
mNodeReferenceScaleFactors.setSize(mShape->nodes.size());
for (i=0; i<mShape->nodes.size(); i++)
{
if (mTransitionScaleNodes.test(i))
mNodeReferenceScaleFactors[i] = smNodeCurrentAlignedScales[i];
@ -692,9 +692,9 @@ void TSShapeInstance::updateTransitions()
}
else
{
mNodeReferenceScaleFactors.setSize(mShape->mNodes.size());
mNodeReferenceArbitraryScaleRots.setSize(mShape->mNodes.size());
for (i=0; i<mShape->mNodes.size(); i++)
mNodeReferenceScaleFactors.setSize(mShape->nodes.size());
mNodeReferenceArbitraryScaleRots.setSize(mShape->nodes.size());
for (i=0; i<mShape->nodes.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->mTransitionData.inTransition)
if (th->transitionData.inTransition)
{
th->mTransitionData.duration *= 1.0f - th->mTransitionData.pos;
th->mTransitionData.pos = 0.0f;
th->transitionData.duration *= 1.0f - th->transitionData.pos;
th->transitionData.pos = 0.0f;
}
}
}
@ -728,22 +728,22 @@ void TSShapeInstance::checkScaleCurrentlyAnimated()
void TSShapeInstance::setBlendEnabled(TSThread * thread, bool blendOn)
{
thread->mBlendDisabled = !blendOn;
thread->blendDisabled = !blendOn;
}
bool TSShapeInstance::getBlendEnabled(TSThread * thread)
{
return !thread->mBlendDisabled;
return !thread->blendDisabled;
}
void TSShapeInstance::setPriority(TSThread * thread, F32 priority)
{
thread->mPriority = priority;
thread->priority = priority;
}
F32 TSShapeInstance::getPriority(TSThread * thread)
{
return thread->mPriority;
return thread->priority;
}
F32 TSShapeInstance::getTime(TSThread * thread)