Merge branch 'master' into console-func-refactor

Conflicts:
	Engine/source/app/net/net.cpp
	Engine/source/console/astNodes.cpp
	Engine/source/console/compiledEval.cpp
	Engine/source/console/console.h
	Engine/source/console/consoleInternal.h
	Engine/source/console/engineAPI.h
This commit is contained in:
Daniel Buckmaster 2014-10-14 14:40:17 +11:00
commit b507dc9555
6487 changed files with 315149 additions and 609761 deletions

View file

@ -38,10 +38,10 @@ void zero_vert_normal_bulk_SSE(const dsize_t count, U8 * __restrict const outPtr
vMask = _mm_load_ps((const F32*)&_point3f_zero_mask);
// pre-populate cache
for(int i = 0; i < 8; i++)
for(S32 i = 0; i < 8; i++)
_mm_prefetch(reinterpret_cast<const char *>(outData + outStride * i), _MM_HINT_T0);
for(int i = 0; i < count; i++)
for(S32 i = 0; i < count; i++)
{
TSMesh::__TSMeshVertexBase *curElem = reinterpret_cast<TSMesh::__TSMeshVertexBase *>(outData);
@ -102,13 +102,13 @@ void m_matF_x_BatchedVertWeightList_SSE(const MatrixF &mat,
// pre-populate cache
const TSSkinMesh::BatchData::BatchedVertWeight &firstElem = batch[0];
for(int i = 0; i < 8; i++)
for(S32 i = 0; i < 8; i++)
{
_mm_prefetch(reinterpret_cast<const char *>(iPtr + inStride * i), _MM_HINT_T0);
_mm_prefetch(reinterpret_cast<const char *>(outPtr + outStride * (i + firstElem.vidx)), _MM_HINT_T0);
}
for(register int i = 0; i < count; i++)
for(register S32 i = 0; i < count; i++)
{
const TSSkinMesh::BatchData::BatchedVertWeight &inElem = batch[i];
TSMesh::__TSMeshVertexBase *outElem = reinterpret_cast<TSMesh::__TSMeshVertexBase *>(outPtr + inElem.vidx * outStride);

View file

@ -46,13 +46,13 @@ void m_matF_x_BatchedVertWeightList_SSE4(const MatrixF &mat,
// pre-populate cache
const TSSkinMesh::BatchData::BatchedVertWeight &firstElem = batch[0];
for(int i = 0; i < 8; i++)
for(S32 i = 0; i < 8; i++)
{
_mm_prefetch(reinterpret_cast<const char *>(iPtr + inStride * i), _MM_HINT_T0);
_mm_prefetch(reinterpret_cast<const char *>(outPtr + outStride * (i + firstElem.vidx)), _MM_HINT_T0);
}
for(int i = 0; i < count; i++)
for(S32 i = 0; i < count; i++)
{
const TSSkinMesh::BatchData::BatchedVertWeight &inElem = batch[i];
TSMesh::__TSMeshVertexBase *outElem = reinterpret_cast<TSMesh::__TSMeshVertexBase *>(outPtr + inElem.vidx * outStride);

View file

@ -179,7 +179,7 @@ private:
const domVertices* vertices = daeSafeCast<domVertices>(element);
// Search for the input with the desired semantic
const char* semantic = SourceTypeToSemantic( type );
for (int iInput = 0; iInput < vertices->getInput_array().getCount(); iInput++)
for (S32 iInput = 0; iInput < vertices->getInput_array().getCount(); iInput++)
{
domInputLocal* input = vertices->getInput_array().get(iInput);
if (dStrEqual(input->getSemantic(), semantic))
@ -230,12 +230,12 @@ public:
*maxOffset = 0;
// Clear output array
for (int i = 0; i < NumStreams; i++)
for (S32 i = 0; i < NumStreams; i++)
sortedInputs[i] = 0;
// Separate inputs by type, and sort by set (ie. lowest TEXCOORD set becomes UV,
// next TEXCOORD set becomes UV2 etc)
for (int iInput = 0; iInput < inputs.getCount(); iInput++) {
for (S32 iInput = 0; iInput < inputs.getCount(); iInput++) {
const T& input = inputs[iInput];
const daeString semantic = input->getSemantic();
@ -247,7 +247,7 @@ public:
// The <vertices> element may contain multiple inputs (eg. POSITION, NORMAL etc)
domInputLocalRef verticesInputs[NumStreams];
classifyInputs(vertices->getInput_array(), verticesInputs);
for (int iStream = 0; iStream < NumStreams; iStream++)
for (S32 iStream = 0; iStream < NumStreams; iStream++)
{
if (verticesInputs[iStream] != 0)
sortedInputs[iStream] = input;
@ -367,7 +367,7 @@ 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 (int iMat = 0; iMat < appMaterials.size(); 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()))
@ -379,7 +379,7 @@ bool ColladaAppMesh::animatesMatFrame(const AppSequence* appSeq)
bool animated = false;
bool differentUVs = false;
if (const domMorph* morph = getMorph()) {
for (int iInput = 0; iInput < morph->getTargets()->getInput_array().getCount(); iInput++) {
for (S32 iInput = 0; iInput < morph->getTargets()->getInput_array().getCount(); iInput++) {
const domInputLocal* input = morph->getTargets()->getInput_array()[iInput];
if (dStrEqual(input->getSemantic(), "MORPH_TARGET")) {
// @todo: Check if morph targets have different UVs to base geometry
@ -402,7 +402,7 @@ bool ColladaAppMesh::animatesFrame(const AppSequence* appSeq)
// the morph weights are animated within the sequence interval
bool animated = false;
if (const domMorph* morph = getMorph()) {
for (int iInput = 0; iInput < morph->getTargets()->getInput_array().getCount(); iInput++) {
for (S32 iInput = 0; iInput < morph->getTargets()->getInput_array().getCount(); iInput++) {
const domInputLocal* input = morph->getTargets()->getInput_array()[iInput];
if (dStrEqual(input->getSemantic(), "MORPH_WEIGHT")) {
const domSource* source = daeSafeCast<domSource>(findInputSource(input));
@ -441,7 +441,7 @@ S32 ColladaAppMesh::addMaterial(const char* symbol)
instanceCtrl->getBind_material();
if (binds) {
const domInstance_material_Array& matArray = binds->getTechnique_common()->getInstance_material_array();
for (int iBind = 0; iBind < matArray.getCount(); iBind++) {
for (S32 iBind = 0; iBind < matArray.getCount(); iBind++) {
if (dStrEqual(matArray[iBind]->getSymbol(), symbol)) {
// Find the index of the bound material in the shape global list
@ -488,7 +488,7 @@ void ColladaAppMesh::getPrimitives(const domGeometry* geometry)
// about unsupported elements
Vector<BasePrimitive*> meshPrims;
const daeElementRefArray& contents = geometry->getMesh()->getContents();
for (int iElem = 0; iElem < contents.getCount(); iElem++) {
for (S32 iElem = 0; iElem < contents.getCount(); iElem++) {
if (BasePrimitive::isPrimitive(contents[iElem])) {
if (BasePrimitive::isSupportedPrimitive(contents[iElem]))
@ -505,7 +505,7 @@ void ColladaAppMesh::getPrimitives(const domGeometry* geometry)
VertTupleMap tupleMap;
// Create Torque primitives
for (int iPrim = 0; iPrim < meshPrims.size(); iPrim++) {
for (S32 iPrim = 0; iPrim < meshPrims.size(); iPrim++) {
// Primitive element must have at least 1 triangle
const domListOfUInts* pTriData = meshPrims[iPrim]->getTriangleData();
@ -619,11 +619,11 @@ void ColladaAppMesh::getPrimitives(const domGeometry* geometry)
}
}
for (int iPrim = 0; iPrim < meshPrims.size(); iPrim++)
for (S32 iPrim = 0; iPrim < meshPrims.size(); iPrim++)
delete meshPrims[iPrim];
}
void ColladaAppMesh::getVertexData(const domGeometry* geometry, F32 time, const MatrixF& objectOffset,
void ColladaAppMesh::getVertexData(const domGeometry* geometry, F32 time, const MatrixF& objOffset,
Vector<Point3F>& v_points,
Vector<Point3F>& v_norms,
Vector<ColorI>& v_colors,
@ -641,7 +641,7 @@ void ColladaAppMesh::getVertexData(const domGeometry* geometry, F32 time, const
// Get the supported primitive elements for this geometry
Vector<BasePrimitive*> meshPrims;
const daeElementRefArray& contents = geometry->getMesh()->getContents();
for (int iElem = 0; iElem < contents.getCount(); iElem++) {
for (S32 iElem = 0; iElem < contents.getCount(); iElem++) {
if (BasePrimitive::isSupportedPrimitive(contents[iElem]))
meshPrims.push_back(BasePrimitive::get(contents[iElem]));
}
@ -659,7 +659,7 @@ void ColladaAppMesh::getVertexData(const domGeometry* geometry, F32 time, const
ColorI* colors_array = NULL;
Point2F* uv2s_array = NULL;
for (int iVert = 0; iVert < vertTuples.size(); iVert++) {
for (S32 iVert = 0; iVert < vertTuples.size(); iVert++) {
const VertTuple& tuple = vertTuples[iVert];
@ -693,7 +693,7 @@ void ColladaAppMesh::getVertexData(const domGeometry* geometry, F32 time, const
if (appNode->invertMeshes)
points_array[iVert].z = -points_array[iVert].z;
objectOffset.mulP(points_array[iVert]);
objOffset.mulP(points_array[iVert]);
}
if (appendValues || ((tuple.uv >= 0) && (tuple.uv < streams.uvs.size()))) {
@ -751,11 +751,11 @@ void ColladaAppMesh::getVertexData(const domGeometry* geometry, F32 time, const
}
}
for (int iPrim = 0; iPrim < meshPrims.size(); iPrim++)
for (S32 iPrim = 0; iPrim < meshPrims.size(); iPrim++)
delete meshPrims[iPrim];
}
void ColladaAppMesh::getMorphVertexData(const domMorph* morph, F32 time, const MatrixF& objectOffset,
void ColladaAppMesh::getMorphVertexData(const domMorph* morph, F32 time, const MatrixF& objOffset,
Vector<Point3F>& v_points,
Vector<Point3F>& v_norms,
Vector<ColorI>& v_colors,
@ -768,7 +768,7 @@ void ColladaAppMesh::getMorphVertexData(const domMorph* morph, F32 time, const M
Vector<const domGeometry*> targetGeoms;
domListOfFloats targetWeights;
for (int iInput = 0; iInput < morph->getTargets()->getInput_array().getCount(); iInput++) {
for (S32 iInput = 0; iInput < morph->getTargets()->getInput_array().getCount(); iInput++) {
const domInputLocal* input = morph->getTargets()->getInput_array()[iInput];
const domSource* source = daeSafeCast<domSource>(findInputSource(input));
@ -777,7 +777,7 @@ void ColladaAppMesh::getMorphVertexData(const domMorph* morph, F32 time, const M
_SourceReader srcTargets;
srcTargets.initFromSource(source);
for (int iTarget = 0; iTarget < srcTargets.size(); iTarget++) {
for (S32 iTarget = 0; iTarget < srcTargets.size(); iTarget++) {
// Lookup the element and add to the targets list
daeIDRef idref(srcTargets.getStringValue(iTarget));
idref.setContainer(morph->getDocument()->getDomRoot());
@ -807,7 +807,7 @@ void ColladaAppMesh::getMorphVertexData(const domMorph* morph, F32 time, const M
return;
getPrimitives(baseGeometry);
getVertexData(baseGeometry, time, objectOffset, v_points, v_norms, v_colors, v_uvs, v_uv2s, true);
getVertexData(baseGeometry, time, objOffset, v_points, v_norms, v_colors, v_uvs, v_uv2s, true);
// Get pointers to the arrays of base geometry data
Point3F* points_array = &v_points[v_points.size() - vertTuples.size()];
@ -820,27 +820,27 @@ void ColladaAppMesh::getMorphVertexData(const domMorph* morph, F32 time, const M
if (morph->getMethod() == MORPHMETHODTYPE_NORMALIZED) {
F32 weightSum = 0.0f;
for (int iWeight = 0; iWeight < targetWeights.getCount(); iWeight++) {
for (S32 iWeight = 0; iWeight < targetWeights.getCount(); iWeight++) {
weightSum += targetWeights[iWeight];
}
// Result = Base*(1.0-w1-w2 ... -wN) + w1*Target1 + w2*Target2 ... + wN*TargetN
weightSum = mClampF(1.0f - weightSum, 0.0f, 1.0f);
for (int iVert = 0; iVert < vertTuples.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 (int iVert = 0; iVert < vertTuples.size(); iVert++)
for (S32 iVert = 0; iVert < vertTuples.size(); iVert++)
uv2s_array[iVert] *= weightSum;
}
}
// Interpolate using the target geometry and weights
for (int iTarget = 0; iTarget < targetGeoms.size(); iTarget++) {
for (S32 iTarget = 0; iTarget < targetGeoms.size(); iTarget++) {
// Ignore empty weights
if (targetWeights[iTarget] == 0.0f)
@ -863,27 +863,27 @@ void ColladaAppMesh::getMorphVertexData(const domMorph* morph, F32 time, const M
if (uv2s_array)
targetUv2s.set(uv2s_array, vertTuples.size());
getVertexData(targetGeoms[iTarget], time, objectOffset, targetPoints, targetNorms, targetColors, targetUvs, targetUv2s, false);
getVertexData(targetGeoms[iTarget], time, objOffset, targetPoints, targetNorms, targetColors, targetUvs, targetUv2s, false);
// Combine with base geometry
for (int iVert = 0; iVert < vertTuples.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 (int iVert = 0; iVert < vertTuples.size(); iVert++)
for (S32 iVert = 0; iVert < vertTuples.size(); iVert++)
uv2s_array[iVert] += targetUv2s[iVert] * targetWeights[iTarget];
}
if (colors_array) {
for (int iVert = 0; iVert < vertTuples.size(); iVert++)
for (S32 iVert = 0; iVert < vertTuples.size(); iVert++)
colors_array[iVert] += targetColors[iVert] * (F32)targetWeights[iTarget];
}
}
}
void ColladaAppMesh::lockMesh(F32 t, const MatrixF& objectOffset)
void ColladaAppMesh::lockMesh(F32 t, const MatrixF& objOffset)
{
// Find the geometry element for this mesh. Could be one of 3 things:
// 1) a simple static mesh (Collada <geometry> element)
@ -923,10 +923,10 @@ void ColladaAppMesh::lockMesh(F32 t, const MatrixF& objectOffset)
// Now get the vertex data at the specified time
if (geometry->getElementType() == COLLADA_TYPE::GEOMETRY) {
getPrimitives(daeSafeCast<domGeometry>(geometry));
getVertexData(daeSafeCast<domGeometry>(geometry), t, objectOffset, points, normals, colors, uvs, uv2s, 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, objectOffset, points, normals, colors, uvs, uv2s);
getMorphVertexData(daeSafeCast<domMorph>(geometry), t, objOffset, points, normals, colors, uvs, uv2s);
}
else {
daeErrorHandler::get()->handleWarning(avar("Unsupported geometry type "
@ -963,7 +963,7 @@ void ColladaAppMesh::lookupSkinData()
// vertex may have multiple [bone, weight] pairs in the array)
Vector<U32> vindicesOffset;
const domInt* vindices = (domInt*)weights_v.getRaw(0);
for (int iWeight = 0; iWeight < weights_vcount.getCount(); iWeight++) {
for (S32 iWeight = 0; iWeight < weights_vcount.getCount(); iWeight++) {
// Store the offset into the vindices array for this vertex
vindicesOffset.push_back(vindices - (domInt*)weights_v.getRaw(0));
vindices += (weights_vcount[iWeight]*2); // 2 indices [bone, weight] per vert
@ -971,14 +971,14 @@ void ColladaAppMesh::lookupSkinData()
// Set vertex weights
bool tooManyWeightsWarning = false;
for (int iVert = 0; iVert < vertsPerFrame; 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[vertTuples[iVert].vertex];
S32 nonZeroWeightCount = 0;
for (int iWeight = 0; iWeight < vcount[vertTuples[iVert].vertex]; iWeight++) {
for (S32 iWeight = 0; iWeight < vcount[vertTuples[iVert].vertex]; iWeight++) {
S32 bIndex = vindices[iWeight*2];
F32 bWeight = streams.weights.getFloatValue( vindices[iWeight*2 + 1] );
@ -1027,12 +1027,12 @@ void ColladaAppMesh::lookupSkinData()
}
// Normalize vertex weights (force weights for each vert to sum to 1)
int iWeight = 0;
S32 iWeight = 0;
while (iWeight < weight.size()) {
// Find the last weight with the same vertex number, and sum all weights for
// that vertex
F32 invTotalWeight = 0;
int iLast;
S32 iLast;
for (iLast = iWeight; iLast < weight.size(); iLast++) {
if (vertexIndex[iLast] != vertexIndex[iWeight])
break;
@ -1048,7 +1048,7 @@ void ColladaAppMesh::lookupSkinData()
// Add dummy AppNodes to allow Collada joints to be mapped to 3space nodes
bones.setSize(streams.joints.size());
initialTransforms.setSize(streams.joints.size());
for (int iJoint = 0; iJoint < streams.joints.size(); iJoint++)
for (S32 iJoint = 0; iJoint < streams.joints.size(); iJoint++)
{
const char* jointName = streams.joints.getStringValue(iJoint);
@ -1056,7 +1056,7 @@ void ColladaAppMesh::lookupSkinData()
const domNode* joint = 0;
if (instanceCtrl->getSkeleton_array().getCount()) {
// Search for the node using the <skeleton> as the base element
for (int iSkel = 0; iSkel < instanceCtrl->getSkeleton_array().getCount(); iSkel++) {
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());

View file

@ -109,11 +109,11 @@ protected:
bool checkGeometryType(const daeElement* element);
void getPrimitives(const domGeometry* geometry);
void getVertexData( const domGeometry* geometry, F32 time, const MatrixF& objectOffset,
void getVertexData( const domGeometry* geometry, F32 time, const MatrixF& objOffset,
Vector<Point3F>& points, Vector<Point3F>& norms, Vector<ColorI>& colors,
Vector<Point2F>& uvs, Vector<Point2F>& uv2s, bool appendValues);
void getMorphVertexData( const domMorph* morph, F32 time, const MatrixF& objectOffset,
void getMorphVertexData( const domMorph* morph, F32 time, const MatrixF& objOffset,
Vector<Point3F>& points, Vector<Point3F>& norms, Vector<ColorI>& colors,
Vector<Point2F>& uvs, Vector<Point2F>& uv2s );
@ -211,8 +211,8 @@ public:
/// Generate the vertex, normal and triangle data for the mesh.
///
/// @param time Time at which to generate the mesh data
/// @param objectOffset Transform to apply to the generated data (bounds transform)
void lockMesh(F32 time, const MatrixF& objectOffset);
/// @param objOffset Transform to apply to the generated data (bounds transform)
void lockMesh(F32 time, const MatrixF& objOffset);
/// Get the transform of this mesh at a certain time
///

View file

@ -90,7 +90,7 @@ ColladaAppNode::ColladaAppNode(const domNode* node, ColladaAppNode* parent)
dFree( properties );
// Create vector of transform elements
for (int iChild = 0; iChild < node->getContents().getCount(); iChild++) {
for (S32 iChild = 0; iChild < node->getContents().getCount(); iChild++) {
switch (node->getContents()[iChild]->getElementType()) {
case COLLADA_TYPE::TRANSLATE:
case COLLADA_TYPE::ROTATE:
@ -109,7 +109,7 @@ ColladaAppNode::ColladaAppNode(const domNode* node, ColladaAppNode* parent)
void ColladaAppNode::buildChildList()
{
// Process children: collect <node> and <instance_node> elements
for (int iChild = 0; iChild < p_domNode->getContents().getCount(); iChild++) {
for (S32 iChild = 0; iChild < p_domNode->getContents().getCount(); iChild++) {
daeElement* child = p_domNode->getContents()[iChild];
switch (child->getElementType()) {
@ -139,7 +139,7 @@ void ColladaAppNode::buildChildList()
void ColladaAppNode::buildMeshList()
{
// Process children: collect <instance_geometry> and <instance_controller> elements
for (int iChild = 0; iChild < p_domNode->getContents().getCount(); iChild++) {
for (S32 iChild = 0; iChild < p_domNode->getContents().getCount(); iChild++) {
daeElement* child = p_domNode->getContents()[iChild];
switch (child->getElementType()) {
@ -167,7 +167,7 @@ bool ColladaAppNode::animatesTransform(const AppSequence* appSeq)
{
// Check if any of this node's transform elements are animated during the
// sequence interval
for (int iTxfm = 0; iTxfm < nodeTransforms.size(); iTxfm++) {
for (S32 iTxfm = 0; iTxfm < nodeTransforms.size(); iTxfm++) {
if (nodeTransforms[iTxfm].isAnimated(appSeq->getStart(), appSeq->getEnd()))
return true;
}
@ -227,7 +227,7 @@ MatrixF ColladaAppNode::getTransform(F32 time)
}
// Multiply by local node transform elements
for (int iTxfm = 0; iTxfm < nodeTransforms.size(); iTxfm++) {
for (S32 iTxfm = 0; iTxfm < nodeTransforms.size(); iTxfm++) {
MatrixF mat(true);

View file

@ -74,7 +74,7 @@ F32 ColladaAppSequence::getBlendRefTime()
void ColladaAppSequence::setActive(bool active)
{
for (int iAnim = 0; iAnim < getClip()->getInstance_animation_array().getCount(); iAnim++) {
for (S32 iAnim = 0; iAnim < getClip()->getInstance_animation_array().getCount(); iAnim++) {
domAnimation* anim = daeSafeCast<domAnimation>(getClip()->getInstance_animation_array()[iAnim]->getUrl().getElement());
if (anim)
setAnimationActive(anim, active);
@ -84,7 +84,7 @@ void ColladaAppSequence::setActive(bool active)
void ColladaAppSequence::setAnimationActive(const domAnimation* anim, bool active)
{
// Enabled/disable data channels for this animation
for (int iChannel = 0; iChannel < anim->getChannel_array().getCount(); iChannel++) {
for (S32 iChannel = 0; iChannel < anim->getChannel_array().getCount(); iChannel++) {
domChannel* channel = anim->getChannel_array()[iChannel];
AnimData* animData = reinterpret_cast<AnimData*>(channel->getUserData());
if (animData)
@ -92,6 +92,6 @@ void ColladaAppSequence::setAnimationActive(const domAnimation* anim, bool activ
}
// Recurse into child animations
for (int iAnim = 0; iAnim < anim->getAnimation_array().getCount(); iAnim++)
for (S32 iAnim = 0; iAnim < anim->getAnimation_array().getCount(); iAnim++)
setAnimationActive(anim->getAnimation_array()[iAnim], active);
}

View file

@ -59,8 +59,8 @@ protected:
template<class T> const domTechnique* findExtraTechnique(const T* element, const char* name) const
{
if (element) {
for (int iExt = 0; iExt < element->getExtra_array().getCount(); iExt++) {
for (int iTech = 0; iTech < element->getExtra_array()[iExt]->getTechnique_array().getCount(); iTech++) {
for (S32 iExt = 0; iExt < element->getExtra_array().getCount(); iExt++) {
for (S32 iTech = 0; iTech < element->getExtra_array()[iExt]->getTechnique_array().getCount(); iTech++) {
if (dStrEqual(element->getExtra_array()[iExt]->getTechnique_array()[iTech]->getProfile(), name))
return element->getExtra_array()[iExt]->getTechnique_array()[iTech];
}
@ -75,7 +75,7 @@ protected:
const domCommon_color_or_texture_type_complexType::domTexture* element, const char* name) const
{
if (element && element->getExtra()) {
for (int iTech = 0; iTech < element->getExtra()->getTechnique_array().getCount(); iTech++) {
for (S32 iTech = 0; iTech < element->getExtra()->getTechnique_array().getCount(); iTech++) {
if (dStrEqual(element->getExtra()->getTechnique_array()[iTech]->getProfile(), name))
return element->getExtra()->getTechnique_array()[iTech];
}
@ -88,7 +88,7 @@ protected:
{
if (pTechnique) {
// search the technique contents for the desired parameter
for (int iParam = 0; iParam < pTechnique->getContents().getCount(); 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;
@ -290,7 +290,7 @@ public:
// Torque profile
pTechnique = findExtraTechnique(clip, "Torque");
GET_EXTRA_PARAM(num_triggers, 0);
for (int iTrigger = 0; iTrigger < num_triggers; iTrigger++) {
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);

View file

@ -50,7 +50,7 @@ static void processNode(GuiTreeViewCtrl* tree, domNode* node, S32 parentID, Scen
S32 nodeID = tree->insertItem(parentID, _GetNameOrId(node), "node", "", 0, 0);
// Update mesh and poly counts
for (int i = 0; i < node->getContents().getCount(); i++)
for (S32 i = 0; i < node->getContents().getCount(); i++)
{
domGeometry* geom = 0;
const char* elemName = "";
@ -178,13 +178,13 @@ ConsoleFunction( enumColladaForImport, bool, 3, 3,
SceneStats stats;
// Query DOM for shape summary details
for (int i = 0; i < root->getLibrary_visual_scenes_array().getCount(); i++)
for (S32 i = 0; i < root->getLibrary_visual_scenes_array().getCount(); i++)
{
const domLibrary_visual_scenes* libScenes = root->getLibrary_visual_scenes_array()[i];
for (int j = 0; j < libScenes->getVisual_scene_array().getCount(); j++)
for (S32 j = 0; j < libScenes->getVisual_scene_array().getCount(); j++)
{
const domVisual_scene* visualScene = libScenes->getVisual_scene_array()[j];
for (int k = 0; k < visualScene->getNode_array().getCount(); k++)
for (S32 k = 0; k < visualScene->getNode_array().getCount(); k++)
processNode(tree, visualScene->getNode_array()[k], nodesID, stats);
}
}

View file

@ -215,11 +215,11 @@ ConsoleFunction( loadColladaLights, bool, 2, 4,
// First grab all of the top-level nodes
Vector<ColladaAppNode*> sceneNodes;
for (int iSceneLib = 0; iSceneLib < root->getLibrary_visual_scenes_array().getCount(); iSceneLib++) {
for (S32 iSceneLib = 0; iSceneLib < root->getLibrary_visual_scenes_array().getCount(); iSceneLib++) {
const domLibrary_visual_scenes* libScenes = root->getLibrary_visual_scenes_array()[iSceneLib];
for (int iScene = 0; iScene < libScenes->getVisual_scene_array().getCount(); iScene++) {
for (S32 iScene = 0; iScene < libScenes->getVisual_scene_array().getCount(); iScene++) {
const domVisual_scene* visualScene = libScenes->getVisual_scene_array()[iScene];
for (int iNode = 0; iNode < visualScene->getNode_array().getCount(); iNode++)
for (S32 iNode = 0; iNode < visualScene->getNode_array().getCount(); iNode++)
sceneNodes.push_back(new ColladaAppNode(visualScene->getNode_array()[iNode]));
}
}

View file

@ -50,6 +50,15 @@
#include "core/util/zip/zipVolume.h"
#include "gfx/bitmap/gBitmap.h"
MODULE_BEGIN( ColladaShapeLoader )
MODULE_INIT_AFTER( ShapeLoader )
MODULE_INIT
{
TSShapeLoader::addFormat("Collada", "dae");
TSShapeLoader::addFormat("Google Earth", "kmz");
}
MODULE_END;
//
static DAE sDAE; // Collada model database (holds the last loaded file)
static Torque::Path sLastPath; // Path of the last loaded Collada file
@ -96,8 +105,8 @@ ColladaShapeLoader::ColladaShapeLoader(domCOLLADA* _root)
ColladaShapeLoader::~ColladaShapeLoader()
{
// Delete all of the animation channels
for (int iAnim = 0; iAnim < animations.size(); iAnim++) {
for (int iChannel = 0; iChannel < animations[iAnim]->size(); iChannel++)
for (S32 iAnim = 0; iAnim < animations.size(); iAnim++) {
for (S32 iChannel = 0; iChannel < animations[iAnim]->size(); iChannel++)
delete (*animations[iAnim])[iChannel];
delete animations[iAnim];
}
@ -113,7 +122,7 @@ void ColladaShapeLoader::processAnimation(const domAnimation* anim, F32& maxEndT
const char* sSKEWNames[] = { ".ROTATEX", ".ROTATEY", ".ROTATEZ", ".AROUNDX", ".AROUNDY", ".AROUNDZ", ".ANGLE", "" };
const char* sNullNames[] = { "" };
for (int iChannel = 0; iChannel < anim->getChannel_array().getCount(); iChannel++) {
for (S32 iChannel = 0; iChannel < anim->getChannel_array().getCount(); iChannel++) {
// Get the animation elements: <channel>, <sampler>
domChannel* channel = anim->getChannel_array()[iChannel];
@ -150,7 +159,7 @@ void ColladaShapeLoader::processAnimation(const domAnimation* anim, F32& maxEndT
channel->setUserData(targetChannels->last());
AnimData& data = *targetChannels->last();
for (int iInput = 0; iInput < sampler->getInput_array().getCount(); iInput++) {
for (S32 iInput = 0; iInput < sampler->getInput_array().getCount(); iInput++) {
const domInputLocal* input = sampler->getInput_array()[iInput];
const domSource* source = daeSafeCast<domSource>(input->getSource().getElement());
@ -219,7 +228,7 @@ void ColladaShapeLoader::processAnimation(const domAnimation* anim, F32& maxEndT
}
// Process child animations
for (int iAnim = 0; iAnim < anim->getAnimation_array().getCount(); iAnim++)
for (S32 iAnim = 0; iAnim < anim->getAnimation_array().getCount(); iAnim++)
processAnimation(anim->getAnimation_array()[iAnim], maxEndTime, minFrameTime);
}
@ -227,20 +236,20 @@ void ColladaShapeLoader::enumerateScene()
{
// Get animation clips
Vector<const domAnimation_clip*> animationClips;
for (int iClipLib = 0; iClipLib < root->getLibrary_animation_clips_array().getCount(); iClipLib++) {
for (S32 iClipLib = 0; iClipLib < root->getLibrary_animation_clips_array().getCount(); iClipLib++) {
const domLibrary_animation_clips* libraryClips = root->getLibrary_animation_clips_array()[iClipLib];
for (int iClip = 0; iClip < libraryClips->getAnimation_clip_array().getCount(); iClip++)
for (S32 iClip = 0; iClip < libraryClips->getAnimation_clip_array().getCount(); 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 (int iSeq = 0; iSeq < appSequences.size(); iSeq++) {
for (S32 iSeq = 0; iSeq < appSequences.size(); iSeq++) {
ColladaAppSequence* appSeq = dynamic_cast<ColladaAppSequence*>(appSequences[iSeq]);
F32 maxEndTime = 0;
F32 minFrameTime = 1000.0f;
for (int iAnim = 0; iAnim < appSeq->getClip()->getInstance_animation_array().getCount(); iAnim++) {
for (S32 iAnim = 0; iAnim < appSeq->getClip()->getInstance_animation_array().getCount(); iAnim++) {
domAnimation* anim = daeSafeCast<domAnimation>(appSeq->getClip()->getInstance_animation_array()[iAnim]->getUrl().getElement());
if (anim)
processAnimation(anim, maxEndTime, minFrameTime);
@ -256,11 +265,11 @@ void ColladaShapeLoader::enumerateScene()
// First grab all of the top-level nodes
Vector<domNode*> sceneNodes;
for (int iSceneLib = 0; iSceneLib < root->getLibrary_visual_scenes_array().getCount(); iSceneLib++) {
for (S32 iSceneLib = 0; iSceneLib < root->getLibrary_visual_scenes_array().getCount(); iSceneLib++) {
const domLibrary_visual_scenes* libScenes = root->getLibrary_visual_scenes_array()[iSceneLib];
for (int iScene = 0; iScene < libScenes->getVisual_scene_array().getCount(); iScene++) {
for (S32 iScene = 0; iScene < libScenes->getVisual_scene_array().getCount(); iScene++) {
const domVisual_scene* visualScene = libScenes->getVisual_scene_array()[iScene];
for (int iNode = 0; iNode < visualScene->getNode_array().getCount(); iNode++)
for (S32 iNode = 0; iNode < visualScene->getNode_array().getCount(); iNode++)
sceneNodes.push_back(visualScene->getNode_array()[iNode]);
}
}
@ -272,10 +281,10 @@ void ColladaShapeLoader::enumerateScene()
case ColladaUtils::ImportOptions::DetectDTS:
// Check for a baseXX->startXX hierarchy at the top-level, if we find
// one, use trailing numbers for LOD, otherwise use a single size
for (int iNode = 0; singleDetail && (iNode < sceneNodes.size()); iNode++) {
for (S32 iNode = 0; singleDetail && (iNode < sceneNodes.size()); iNode++) {
domNode* node = sceneNodes[iNode];
if (dStrStartsWith(_GetNameOrId(node), "base")) {
for (int iChild = 0; iChild < node->getNode_array().getCount(); iChild++) {
for (S32 iChild = 0; iChild < node->getNode_array().getCount(); iChild++) {
domNode* child = node->getNode_array()[iChild];
if (dStrStartsWith(_GetNameOrId(child), "start")) {
singleDetail = false;
@ -484,7 +493,7 @@ void updateMaterialsScript(const Torque::Path &path, bool copyTextures = false)
// If importing a sketchup file, the paths will point inside the KMZ so we need to cache them.
if (copyTextures)
{
for (int iMat = 0; iMat < persistMgr.getDirtyList().size(); iMat++)
for (S32 iMat = 0; iMat < persistMgr.getDirtyList().size(); iMat++)
{
Material *mat = dynamic_cast<Material*>( persistMgr.getDirtyList()[iMat].getObject() );

View file

@ -84,7 +84,7 @@ const domProfile_COMMON* ColladaUtils::findEffectCommonProfile(const domEffect*
if (effect) {
// Find the COMMON profile
const domFx_profile_abstract_Array& profiles = effect->getFx_profile_abstract_array();
for (int iProfile = 0; iProfile < profiles.getCount(); iProfile++) {
for (S32 iProfile = 0; iProfile < profiles.getCount(); iProfile++) {
if (profiles[iProfile]->getElementType() == COLLADA_TYPE::PROFILE_COMMON)
return daeSafeCast<domProfile_COMMON>(profiles[iProfile]);
}
@ -245,7 +245,7 @@ BasePrimitive* BasePrimitive::get(const daeElement* element)
// Collada animation curves
/// Determine which elements are being targeted
void AnimData::parseTargetString(const char* target, int fullCount, const char* elements[])
void AnimData::parseTargetString(const char* target, S32 fullCount, const char* elements[])
{
// Assume targeting all elements at offset 0
targetValueCount = fullCount;
@ -253,7 +253,7 @@ void AnimData::parseTargetString(const char* target, int fullCount, const char*
// Check for array syntax: (n) or (n)(m)
if (const char* p = dStrchr(target, '(')) {
int indN, indM;
S32 indN, indM;
if (dSscanf(p, "(%d)(%d)", &indN, &indM) == 2) {
targetValueOffset = (indN * 4) + indM; // @todo: 4x4 matrix only
targetValueCount = 1;
@ -265,7 +265,7 @@ void AnimData::parseTargetString(const char* target, int fullCount, const char*
}
else if (const char* p = dStrrchr(target, '.')) {
// Check for named elements
for (int iElem = 0; elements[iElem][0] != 0; iElem++) {
for (S32 iElem = 0; elements[iElem][0] != 0; iElem++) {
if (!dStrcmp(p, elements[iElem])) {
targetValueOffset = iElem;
targetValueCount = 1;
@ -278,9 +278,9 @@ void AnimData::parseTargetString(const char* target, int fullCount, const char*
/// Solve the cubic spline B(s) = param for s
F32 AnimData::invertParamCubic(F32 param, F32 x0, F32 x1, F32 x2, F32 x3) const
{
const double INVERTPARAMCUBIC_TOL = 1.0e-09;
const double INVERTPARAMCUBIC_SMALLERTOL = 1.0e-20;
const double INVERTPARAMCUBIC_MAXIT = 100;
const F64 INVERTPARAMCUBIC_TOL = 1.0e-09;
const F64 INVERTPARAMCUBIC_SMALLERTOL = 1.0e-20;
const F64 INVERTPARAMCUBIC_MAXIT = 100;
// check input value for outside range
if ((param - x0) < INVERTPARAMCUBIC_SMALLERTOL)
@ -295,12 +295,12 @@ F32 AnimData::invertParamCubic(F32 param, F32 x0, F32 x1, F32 x2, F32 x3) const
F32 v = 1.0f;
while (iterations < INVERTPARAMCUBIC_MAXIT) {
double a = (x0 + x1)*0.5f;
double b = (x1 + x2)*0.5f;
double c = (x2 + x3)*0.5f;
double d = (a + b)*0.5f;
double e = (b + c)*0.5f;
double f = (d + e)*0.5f;
F64 a = (x0 + x1)*0.5f;
F64 b = (x1 + x2)*0.5f;
F64 c = (x2 + x3)*0.5f;
F64 d = (a + b)*0.5f;
F64 e = (b + c)*0.5f;
F64 f = (d + e)*0.5f;
if (mFabs(f - param) < INVERTPARAMCUBIC_TOL)
break;
@ -344,7 +344,7 @@ void AnimData::interpValue(F32 t, U32 offset, double* value) const
t = mClampF(t, curveStart, curveEnd);
// find the index of the input keyframe BEFORE 't'
int index;
S32 index;
for (index = 0; index < input.size()-2; index++) {
if (input.getFloatValue(index + 1) > t)
break;
@ -470,7 +470,7 @@ void AnimData::interpValue(F32 t, U32 offset, const char** value) const
t = mClampF(t, curveStart, curveEnd);
// find the index of the input keyframe BEFORE 't'
int index;
S32 index;
for (index = 0; index < input.size()-2; index++) {
if (input.getFloatValue(index + 1) > t)
break;
@ -487,9 +487,9 @@ void AnimData::interpValue(F32 t, U32 offset, const char** value) const
static void conditioner_fixupTextureSIDs(domCOLLADA* root)
{
for (int iLib = 0; iLib < root->getLibrary_effects_array().getCount(); iLib++) {
for (S32 iLib = 0; iLib < root->getLibrary_effects_array().getCount(); iLib++) {
domLibrary_effects* lib = root->getLibrary_effects_array()[iLib];
for (int iEffect = 0; iEffect < lib->getEffect_array().getCount(); iEffect++) {
for (S32 iEffect = 0; iEffect < lib->getEffect_array().getCount(); iEffect++) {
domEffect* effect = lib->getEffect_array()[iEffect];
const domCommon_color_or_texture_type_complexType* diffuse = findEffectDiffuse(effect);
if (!diffuse || !diffuse->getTexture())
@ -542,9 +542,9 @@ static void conditioner_fixupTextureSIDs(domCOLLADA* root)
static void conditioner_fixupImageURIs(domCOLLADA* root)
{
for (int iLib = 0; iLib < root->getLibrary_images_array().getCount(); iLib++) {
for (S32 iLib = 0; iLib < root->getLibrary_images_array().getCount(); iLib++) {
domLibrary_images* lib = root->getLibrary_images_array()[iLib];
for (int iImage = 0; iImage < lib->getImage_array().getCount(); iImage++) {
for (S32 iImage = 0; iImage < lib->getImage_array().getCount(); iImage++) {
domImage* image = lib->getImage_array()[iImage];
if (image->getInit_from()) {
xsAnyURI& uri = image->getInit_from()->getValue();
@ -595,7 +595,7 @@ static void conditioner_fixupTransparency(domCOLLADA* root)
// Get the <authoring_tool> string
const char *authoringTool = "";
if (const domAsset* asset = root->getAsset()) {
for (int iContrib = 0; iContrib < asset->getContributor_array().getCount(); iContrib++) {
for (S32 iContrib = 0; iContrib < asset->getContributor_array().getCount(); iContrib++) {
const domAsset::domContributor* contrib = asset->getContributor_array()[iContrib];
if (contrib->getAuthoring_tool()) {
authoringTool = contrib->getAuthoring_tool()->getValue();
@ -608,7 +608,7 @@ static void conditioner_fixupTransparency(domCOLLADA* root)
bool invertTransparency = false;
const char *toolNames[] = { "FBX COLLADA exporter", "Google SketchUp",
"Illusoft Collada Exporter", "FCollada" };
for (int iName = 0; iName < (sizeof(toolNames)/sizeof(toolNames[0])); iName++) {
for (S32 iName = 0; iName < (sizeof(toolNames)/sizeof(toolNames[0])); iName++) {
if (dStrstr(authoringTool, toolNames[iName])) {
invertTransparency = true;
break;
@ -619,9 +619,9 @@ static void conditioner_fixupTransparency(domCOLLADA* root)
return;
// Invert transparency as required for each effect
for (int iLib = 0; iLib < root->getLibrary_effects_array().getCount(); iLib++) {
for (S32 iLib = 0; iLib < root->getLibrary_effects_array().getCount(); iLib++) {
domLibrary_effects* lib = root->getLibrary_effects_array()[iLib];
for (int iEffect = 0; iEffect < lib->getEffect_array().getCount(); iEffect++) {
for (S32 iEffect = 0; iEffect < lib->getEffect_array().getCount(); iEffect++) {
domEffect* effect = lib->getEffect_array()[iEffect];
// Find the common profile
@ -658,9 +658,9 @@ static void conditioner_fixupTransparency(domCOLLADA* root)
static void conditioner_checkBindShapeMatrix(domCOLLADA* root)
{
for (int iLib = 0; iLib < root->getLibrary_controllers_array().getCount(); iLib++) {
for (S32 iLib = 0; iLib < root->getLibrary_controllers_array().getCount(); iLib++) {
domLibrary_controllers* lib = root->getLibrary_controllers_array().get(iLib);
for (int iCon = 0; iCon < lib->getController_array().getCount(); iCon++) {
for (S32 iCon = 0; iCon < lib->getController_array().getCount(); iCon++) {
domController* con = lib->getController_array().get(iCon);
if (con->getSkin() && con->getSkin()->getBind_shape_matrix()) {
@ -677,14 +677,14 @@ static void conditioner_checkBindShapeMatrix(domCOLLADA* root)
static void conditioner_fixupVertexWeightJoints(domCOLLADA* root)
{
for (int iLib = 0; iLib < root->getLibrary_controllers_array().getCount(); iLib++) {
for (S32 iLib = 0; iLib < root->getLibrary_controllers_array().getCount(); iLib++) {
domLibrary_controllers* lib = root->getLibrary_controllers_array().get(iLib);
for (int iCon = 0; iCon < lib->getController_array().getCount(); iCon++) {
for (S32 iCon = 0; iCon < lib->getController_array().getCount(); iCon++) {
domController* con = lib->getController_array().get(iCon);
if (con->getSkin() && con->getSkin()->getVertex_weights())
{
domInputLocalOffset_Array& vw_inputs = con->getSkin()->getVertex_weights()->getInput_array();
for (int vInput = 0; vInput < vw_inputs.getCount(); vInput++) {
for (S32 vInput = 0; vInput < vw_inputs.getCount(); vInput++) {
domInputLocalOffset *vw_input = vw_inputs.get(vInput);
if (dStrEqual(vw_input->getSemantic(), "JOINT")) {
@ -695,7 +695,7 @@ static void conditioner_fixupVertexWeightJoints(domCOLLADA* root)
// Copy the value from the <joints> JOINTS input instead
domInputLocal_Array& joint_inputs = con->getSkin()->getJoints()->getInput_array();
for (int jInput = 0; jInput < joint_inputs.getCount(); jInput++) {
for (S32 jInput = 0; jInput < joint_inputs.getCount(); jInput++) {
domInputLocal *joint_input = joint_inputs.get(jInput);
if (dStrEqual(joint_input->getSemantic(), "JOINT")) {
@ -714,16 +714,16 @@ static void conditioner_fixupVertexWeightJoints(domCOLLADA* root)
static void conditioner_createDefaultClip(domCOLLADA* root)
{
// Check if the document has any <animation_clip>s
for (int iLib = 0; iLib < root->getLibrary_animation_clips_array().getCount(); iLib++) {
for (S32 iLib = 0; iLib < root->getLibrary_animation_clips_array().getCount(); iLib++) {
if (root->getLibrary_animation_clips_array()[iLib]->getAnimation_clip_array().getCount())
return;
}
// Get all top-level <animation>s into an array
domAnimation_Array animations;
for (int iAnimLib = 0; iAnimLib < root->getLibrary_animations_array().getCount(); iAnimLib++) {
for (S32 iAnimLib = 0; iAnimLib < root->getLibrary_animations_array().getCount(); iAnimLib++) {
const domLibrary_animations* libraryAnims = root->getLibrary_animations_array()[iAnimLib];
for (int iAnim = 0; iAnim < libraryAnims->getAnimation_array().getCount(); iAnim++)
for (S32 iAnim = 0; iAnim < libraryAnims->getAnimation_array().getCount(); iAnim++)
animations.append(libraryAnims->getAnimation_array()[iAnim]);
}
@ -748,7 +748,7 @@ static void conditioner_createDefaultClip(domCOLLADA* root)
// Add all top_level animations to the clip (sub-animations will be included
// when the clip is procesed)
for (int iAnim = 0; iAnim < animations.getCount(); iAnim++) {
for (S32 iAnim = 0; iAnim < animations.getCount(); iAnim++) {
if (!animations[iAnim]->getId())
animations[iAnim]->setId(avar("dummy-animation-id%d", iAnim));
CREATE_ELEMENT(animation_clip, instance_animation, domInstanceWithExtra)
@ -767,7 +767,7 @@ static void conditioner_createDefaultClip(domCOLLADA* root)
static void conditioner_fixupAnimation(domAnimation* anim)
{
for (int iChannel = 0; iChannel < anim->getChannel_array().getCount(); iChannel++) {
for (S32 iChannel = 0; iChannel < anim->getChannel_array().getCount(); iChannel++) {
// Get the animation elements: <channel>, <sampler>
domChannel* channel = anim->getChannel_array()[iChannel];
@ -848,7 +848,7 @@ static void conditioner_fixupAnimation(domAnimation* anim)
}
// Process child animations
for (int iAnim = 0; iAnim < anim->getAnimation_array().getCount(); iAnim++)
for (S32 iAnim = 0; iAnim < anim->getAnimation_array().getCount(); iAnim++)
conditioner_fixupAnimation(anim->getAnimation_array()[iAnim]);
}
@ -893,9 +893,9 @@ void ColladaUtils::applyConditioners(domCOLLADA* root)
// 2) Some exporters generate visibility animations but don't add the FCOLLADA
// extension, so the target doesn't actually exist! Detect this situation
// and add the extension manually so the animation still works.
for (int iLib = 0; iLib < root->getLibrary_animations_array().getCount(); iLib++) {
for (S32 iLib = 0; iLib < root->getLibrary_animations_array().getCount(); iLib++) {
const domLibrary_animations* lib = root->getLibrary_animations_array()[iLib];
for (int iAnim = 0; iAnim < lib->getAnimation_array().getCount(); iAnim++)
for (S32 iAnim = 0; iAnim < lib->getAnimation_array().getCount(); iAnim++)
conditioner_fixupAnimation(lib->getAnimation_array()[iAnim]);
}
}
@ -946,7 +946,7 @@ void ColladaUtils::exportColladaHeader(TiXmlElement* rootNode)
TiXmlElement* authoringToolNode = new TiXmlElement("authoring_tool");
contributorNode->LinkEndChild(authoringToolNode);
TiXmlText* authorText = new TiXmlText(avar("%s %s Interior Exporter", getEngineProductString(), getVersionString()));
TiXmlText* authorText = new TiXmlText(avar("%s %s Object Exporter", getEngineProductString(), getVersionString()));
authoringToolNode->LinkEndChild(authorText);
TiXmlElement* commentsNode = new TiXmlElement("comments");

View file

@ -185,7 +185,7 @@ template<> inline MatrixF vecToMatrixF<domRotate>(const domListOfFloats& vec)
template<> inline MatrixF vecToMatrixF<domMatrix>(const domListOfFloats& vec)
{
MatrixF mat;
for (int i = 0; i < 16; i++)
for (S32 i = 0; i < 16; i++)
mat[i] = vec[i];
return mat;
}
@ -332,7 +332,7 @@ public:
// If no input params were specified, just map the source params directly
if (!offsets.size()) {
for (int iParam = 0; iParam < accessor->getParam_array().getCount(); iParam++)
for (S32 iParam = 0; iParam < accessor->getParam_array().getCount(); iParam++)
offsets.push_back(iParam);
}
@ -348,9 +348,9 @@ public:
//------------------------------------------------------
// Get a pointer to the start of a group of values (index advances by stride)
//template<class T> T getArrayData(int index) const { return 0; }
//template<class T> T getArrayData(S32 index) const { return 0; }
const double* getStringArrayData(int index) const
const double* getStringArrayData(S32 index) const
{
if ((index >= 0) && (index < size())) {
if (source->getFloat_array())
@ -361,9 +361,9 @@ public:
//------------------------------------------------------
// Read a single value from the source array
//template<class T> T getValue(int index) const { return T; }
//template<class T> T getValue(S32 index) const { return T; }
const char* getStringValue(int index) const
const char* getStringValue(S32 index) const
{
if ((index >= 0) && (index < size())) {
// could be plain strings or IDREFs
@ -375,7 +375,7 @@ public:
return "";
}
F32 getFloatValue(int index) const
F32 getFloatValue(S32 index) const
{
F32 value(0);
if (const double* data = getStringArrayData(index))
@ -383,7 +383,7 @@ public:
return value;
}
Point2F getPoint2FValue(int index) const
Point2F getPoint2FValue(S32 index) const
{
Point2F value(0, 0);
if (const double* data = getStringArrayData(index))
@ -391,7 +391,7 @@ public:
return value;
}
Point3F getPoint3FValue(int index) const
Point3F getPoint3FValue(S32 index) const
{
Point3F value(1, 0, 0);
if (const double* data = getStringArrayData(index))
@ -399,7 +399,7 @@ public:
return value;
}
ColorI getColorIValue(int index) const
ColorI getColorIValue(S32 index) const
{
ColorI value(255, 255, 255, 255);
if (const double* data = getStringArrayData(index))
@ -413,11 +413,11 @@ public:
return value;
}
MatrixF getMatrixFValue(int index) const
MatrixF getMatrixFValue(S32 index) const
{
MatrixF value(true);
if (const double* data = getStringArrayData(index)) {
for (int i = 0; i < 16; i++)
for (S32 i = 0; i < 16; i++)
value[i] = data[i];
}
return value;
@ -430,6 +430,8 @@ public:
class BasePrimitive
{
public:
virtual ~BasePrimitive() { }
/// Return true if the element is a geometric primitive type
static bool isPrimitive(const daeElement* element)
{
@ -486,7 +488,7 @@ public:
// Determine stride
stride = 0;
for (int iInput = 0; iInput < getInputs().getCount(); iInput++) {
for (S32 iInput = 0; iInput < getInputs().getCount(); iInput++) {
if (getInputs()[iInput]->getOffset() >= stride)
stride = getInputs()[iInput]->getOffset() + 1;
}
@ -524,7 +526,7 @@ template<> inline const domListOfUInts *ColladaPrimitive<domTristrips>::getTrian
// Convert strips to triangles
pTriangleData = new domListOfUInts();
for (int iStrip = 0; iStrip < primitive->getCount(); iStrip++) {
for (S32 iStrip = 0; iStrip < primitive->getCount(); iStrip++) {
domP* P = primitive->getP_array()[iStrip];
@ -537,7 +539,7 @@ template<> inline const domListOfUInts *ColladaPrimitive<domTristrips>::getTrian
// Convert the strip back to a triangle list
domUint* v0 = pSrcData;
for (int iTri = 0; iTri < numTriangles; iTri++, v0 += stride) {
for (S32 iTri = 0; iTri < numTriangles; iTri++, v0 += stride) {
if (iTri & 0x1)
{
// CW triangle
@ -565,7 +567,7 @@ template<> inline const domListOfUInts *ColladaPrimitive<domTrifans>::getTriangl
// Convert strips to triangles
pTriangleData = new domListOfUInts();
for (int iStrip = 0; iStrip < primitive->getCount(); iStrip++) {
for (S32 iStrip = 0; iStrip < primitive->getCount(); iStrip++) {
domP* P = primitive->getP_array()[iStrip];
@ -578,7 +580,7 @@ template<> inline const domListOfUInts *ColladaPrimitive<domTrifans>::getTriangl
// Convert the fan back to a triangle list
domUint* v0 = pSrcData + stride;
for (int iTri = 0; iTri < numTriangles; iTri++, v0 += stride) {
for (S32 iTri = 0; iTri < numTriangles; iTri++, v0 += stride) {
pTriangleData->appendArray(stride, pSrcData); // shared vertex
pTriangleData->appendArray(stride, v0); // previous vertex
pTriangleData->appendArray(stride, v0+stride); // current vertex
@ -597,7 +599,7 @@ template<> inline const domListOfUInts *ColladaPrimitive<domPolygons>::getTriang
// Convert polygons to triangles
pTriangleData = new domListOfUInts();
for (int iPoly = 0; iPoly < primitive->getCount(); iPoly++) {
for (S32 iPoly = 0; iPoly < primitive->getCount(); iPoly++) {
domP* P = primitive->getP_array()[iPoly];
@ -612,7 +614,7 @@ template<> inline const domListOfUInts *ColladaPrimitive<domPolygons>::getTriang
// converting the polygon to triangles.
domUint* v0 = pSrcData;
pSrcData += stride;
for (int iTri = 0; iTri < numPoints-2; iTri++) {
for (S32 iTri = 0; iTri < numPoints-2; iTri++) {
pTriangleData->appendArray(stride, v0);
pTriangleData->appendArray(stride*2, pSrcData);
pSrcData += stride;
@ -636,7 +638,7 @@ template<> inline const domListOfUInts *ColladaPrimitive<domPolylist>::getTriang
const domListOfUInts& vcount = primitive->getVcount()->getValue();
U32 expectedCount = 0;
for (int iPoly = 0; iPoly < vcount.getCount(); iPoly++)
for (S32 iPoly = 0; iPoly < vcount.getCount(); iPoly++)
expectedCount += vcount[iPoly];
expectedCount *= stride;
@ -648,13 +650,13 @@ template<> inline const domListOfUInts *ColladaPrimitive<domPolylist>::getTriang
}
domUint* pSrcData = &(primitive->getP()->getValue()[0]);
for (int iPoly = 0; iPoly < vcount.getCount(); iPoly++) {
for (S32 iPoly = 0; iPoly < vcount.getCount(); iPoly++) {
// Use a simple tri-fan (centered at the first point) method of
// converting the polygon to triangles.
domUint* v0 = pSrcData;
pSrcData += stride;
for (int iTri = 0; iTri < vcount[iPoly]-2; iTri++) {
for (S32 iTri = 0; iTri < vcount[iPoly]-2; iTri++) {
pTriangleData->appendArray(stride, v0);
pTriangleData->appendArray(stride*2, pSrcData);
pSrcData += stride;
@ -671,7 +673,7 @@ template<> inline const domListOfUInts *ColladaPrimitive<domPolylist>::getTriang
template<typename T> inline T convert(const char* value) { return value; }
template<> inline bool convert(const char* value) { return dAtob(value); }
template<> inline S32 convert(const char* value) { return dAtoi(value); }
template<> inline double convert(const char* value) { return dAtof(value); }
template<> inline F64 convert(const char* value) { return dAtof(value); }
template<> inline F32 convert(const char* value) { return convert<double>(value); }
//-----------------------------------------------------------------------------
@ -713,7 +715,7 @@ struct AnimData
AnimData() : enabled(false) { }
void parseTargetString(const char* target, int fullCount, const char* elements[]);
void parseTargetString(const char* target, S32 fullCount, const char* elements[]);
F32 invertParamCubic(F32 param, F32 x0, F32 x1, F32 x2, F32 x3) const;
void interpValue(F32 t, U32 offset, double* value) const;
@ -757,7 +759,7 @@ struct AnimatedElement
// Animate the value
const AnimChannels* channels = AnimData::getAnimChannels(element);
if (channels && (time >= 0)) {
for (int iChannel = 0; iChannel < channels->size(); iChannel++) {
for (S32 iChannel = 0; iChannel < channels->size(); iChannel++) {
const AnimData* animData = (*channels)[iChannel];
if (animData->enabled)
animData->interpValue(time, 0, &value);
@ -787,10 +789,10 @@ template<class T> struct AnimatedElementList : public AnimatedElement<T>
// Animate the vector
const AnimChannels* channels = AnimData::getAnimChannels(this->element);
if (channels && (time >= 0)) {
for (int iChannel = 0; iChannel < channels->size(); iChannel++) {
for (S32 iChannel = 0; iChannel < channels->size(); iChannel++) {
const AnimData* animData = (*channels)[iChannel];
if (animData->enabled) {
for (int iValue = 0; iValue < animData->targetValueCount; iValue++)
for (S32 iValue = 0; iValue < animData->targetValueCount; iValue++)
animData->interpValue(time, iValue, &vec[animData->targetValueOffset + iValue]);
}
}

View file

@ -57,9 +57,15 @@ BaseMatInstance* InstancingMaterialHook::getInstancingMat( BaseMatInstance *matI
FeatureSet features( matInst->getRequestedFeatures() );
features.addFeature( MFT_UseInstancing );
// Allow for named texture assignments
Material::sAllowTextureTargetAssignment = true;
if ( !instMat->init( features, matInst->getVertexFormat() ) )
SAFE_DELETE( instMat );
// Turn back off named texture assignments
Material::sAllowTextureTargetAssignment = false;
hook->mMatInst = instMat;
}

View file

@ -21,6 +21,7 @@
//-----------------------------------------------------------------------------
#include "platform/platform.h"
#include "console/engineAPI.h"
#include "ts/loader/tsShapeLoader.h"
#include "core/volume.h"
@ -30,13 +31,23 @@
#include "ts/tsShapeInstance.h"
#include "ts/tsMaterialList.h"
MODULE_BEGIN( ShapeLoader )
MODULE_INIT_AFTER( GFX )
MODULE_INIT
{
TSShapeLoader::addFormat("Torque DTS", "dts");
TSShapeLoader::addFormat("Torque DSQ", "dsq");
}
MODULE_END;
const F32 TSShapeLoader::DefaultTime = -1.0f;
const double TSShapeLoader::MinFrameRate = 15.0f;
const double TSShapeLoader::MaxFrameRate = 60.0f;
const double TSShapeLoader::AppGroundFrameRate = 10.0f;
const F64 TSShapeLoader::MinFrameRate = 15.0f;
const F64 TSShapeLoader::MaxFrameRate = 60.0f;
const F64 TSShapeLoader::AppGroundFrameRate = 10.0f;
Torque::Path TSShapeLoader::shapePath;
Vector<TSShapeLoader::ShapeFormat> TSShapeLoader::smFormats;
//------------------------------------------------------------------------------
// Utility functions
@ -102,7 +113,7 @@ void TSShapeLoader::generateNodeTransform(AppNode* node, F32 t, bool blend, F32
//-----------------------------------------------------------------------------
void TSShapeLoader::updateProgress(int major, const char* msg, int numMinor, int minor)
void TSShapeLoader::updateProgress(S32 major, const char* msg, S32 numMinor, S32 minor)
{
// Calculate progress value
F32 progress = (F32)major / NumLoadPhases;
@ -229,7 +240,7 @@ bool cmpShapeName(const String& key, const Vector<String>& names, void* arg1, vo
String getUniqueName(const char* name, NameCmpFunc isNameUnique, const Vector<String>& names, void* arg1=0, void* arg2=0)
{
const int MAX_ITERATIONS = 0x10000; // maximum of 4 characters (A-P) will be appended
const S32 MAX_ITERATIONS = 0x10000; // maximum of 4 characters (A-P) will be appended
String suffix;
for (S32 i = 0; i < MAX_ITERATIONS; i++)
@ -336,7 +347,7 @@ void TSShapeLoader::recurseSubshape(AppNode* appNode, S32 parentIndex, bool recu
// Create children
if (recurseChildren)
{
for (int iChild = 0; iChild < appNode->getNumChildNodes(); iChild++)
for (S32 iChild = 0; iChild < appNode->getNumChildNodes(); iChild++)
recurseSubshape(appNode->getChildNode(iChild), myIndex, true);
}
}
@ -500,9 +511,9 @@ void TSShapeLoader::generateObjects()
void TSShapeLoader::generateSkins()
{
Vector<AppMesh*> skins;
for (int iObject = 0; iObject < shape->objects.size(); iObject++)
for (S32 iObject = 0; iObject < shape->objects.size(); iObject++)
{
for (int iMesh = 0; iMesh < shape->objects[iObject].numMeshes; iMesh++)
for (S32 iMesh = 0; iMesh < shape->objects[iObject].numMeshes; iMesh++)
{
AppMesh* mesh = appMeshes[shape->objects[iObject].startMeshIndex + iMesh];
if (mesh->isSkin())
@ -510,7 +521,7 @@ void TSShapeLoader::generateSkins()
}
}
for (int iSkin = 0; iSkin < skins.size(); iSkin++)
for (S32 iSkin = 0; iSkin < skins.size(); iSkin++)
{
updateProgress(Load_GenerateSkins, "Generating skins...", skins.size(), iSkin);
@ -524,11 +535,11 @@ void TSShapeLoader::generateSkins()
// Map bones to nodes
skin->nodeIndex.setSize(skin->bones.size());
for (int iBone = 0; iBone < skin->bones.size(); iBone++)
for (S32 iBone = 0; iBone < skin->bones.size(); iBone++)
{
// Find the node that matches this bone
skin->nodeIndex[iBone] = -1;
for (int iNode = 0; iNode < appNodes.size(); iNode++)
for (S32 iNode = 0; iNode < appNodes.size(); iNode++)
{
if (appNodes[iNode]->isEqual(skin->bones[iBone]))
{
@ -551,7 +562,7 @@ void TSShapeLoader::generateSkins()
void TSShapeLoader::generateDefaultStates()
{
// Generate default object states (includes initial geometry)
for (int iObject = 0; iObject < shape->objects.size(); iObject++)
for (S32 iObject = 0; iObject < shape->objects.size(); iObject++)
{
updateProgress(Load_GenerateDefaultStates, "Generating initial mesh and node states...",
shape->objects.size(), iObject);
@ -559,7 +570,7 @@ void TSShapeLoader::generateDefaultStates()
TSShape::Object& obj = shape->objects[iObject];
// Calculate the objectOffset for each mesh at T=0
for (int iMesh = 0; iMesh < obj.numMeshes; iMesh++)
for (S32 iMesh = 0; iMesh < obj.numMeshes; iMesh++)
{
AppMesh* appMesh = appMeshes[obj.startMeshIndex + iMesh];
AppNode* appNode = obj.nodeIndex >= 0 ? appNodes[obj.nodeIndex] : boundsNode;
@ -576,7 +587,7 @@ void TSShapeLoader::generateDefaultStates()
}
// Generate default node transforms
for (int iNode = 0; iNode < appNodes.size(); iNode++)
for (S32 iNode = 0; iNode < appNodes.size(); iNode++)
{
// Determine the default translation and rotation for the node
QuatF rot, srot;
@ -610,7 +621,7 @@ void TSShapeLoader::generateObjectState(TSShape::Object& obj, F32 t, bool addFra
void TSShapeLoader::generateFrame(TSShape::Object& obj, F32 t, bool addFrame, bool addMatFrame)
{
for (int iMesh = 0; iMesh < obj.numMeshes; iMesh++)
for (S32 iMesh = 0; iMesh < obj.numMeshes; iMesh++)
{
AppMesh* appMesh = appMeshes[obj.startMeshIndex + iMesh];
@ -690,7 +701,7 @@ void TSShapeLoader::generateMaterialList()
{
// Install the materials into the material list
shape->materialList = new TSMaterialList;
for (int iMat = 0; iMat < AppMesh::appMaterials.size(); iMat++)
for (S32 iMat = 0; iMat < AppMesh::appMaterials.size(); iMat++)
{
updateProgress(Load_GenerateMaterials, "Generating materials...", AppMesh::appMaterials.size(), iMat);
@ -705,7 +716,7 @@ void TSShapeLoader::generateMaterialList()
void TSShapeLoader::generateSequences()
{
for (int iSeq = 0; iSeq < appSequences.size(); iSeq++)
for (S32 iSeq = 0; iSeq < appSequences.size(); iSeq++)
{
updateProgress(Load_GenerateSequences, "Generating sequences...", appSequences.size(), iSeq);
@ -783,14 +794,14 @@ void TSShapeLoader::setNodeMembership(TSShape::Sequence& seq, const AppSequence*
void TSShapeLoader::setRotationMembership(TSShape::Sequence& seq)
{
for (int iNode = 0; iNode < appNodes.size(); iNode++)
for (S32 iNode = 0; iNode < appNodes.size(); iNode++)
{
// Check if any of the node rotations are different to
// the default rotation
QuatF defaultRot;
shape->defaultRotations[iNode].getQuatF(&defaultRot);
for (int iFrame = 0; iFrame < seq.numKeyframes; iFrame++)
for (S32 iFrame = 0; iFrame < seq.numKeyframes; iFrame++)
{
if (nodeRotCache[iNode][iFrame] != defaultRot)
{
@ -803,13 +814,13 @@ void TSShapeLoader::setRotationMembership(TSShape::Sequence& seq)
void TSShapeLoader::setTranslationMembership(TSShape::Sequence& seq)
{
for (int iNode = 0; iNode < appNodes.size(); iNode++)
for (S32 iNode = 0; iNode < appNodes.size(); iNode++)
{
// Check if any of the node translations are different to
// the default translation
Point3F& defaultTrans = shape->defaultTranslations[iNode];
for (int iFrame = 0; iFrame < seq.numKeyframes; iFrame++)
for (S32 iFrame = 0; iFrame < seq.numKeyframes; iFrame++)
{
if (!nodeTransCache[iNode][iFrame].equal(defaultTrans))
{
@ -828,10 +839,10 @@ void TSShapeLoader::setScaleMembership(TSShape::Sequence& seq)
U32 alignedScaleCount = 0;
U32 uniformScaleCount = 0;
for (int iNode = 0; iNode < appNodes.size(); iNode++)
for (S32 iNode = 0; iNode < appNodes.size(); iNode++)
{
// Check if any of the node scales are not the unit scale
for (int iFrame = 0; iFrame < seq.numKeyframes; iFrame++)
for (S32 iFrame = 0; iFrame < seq.numKeyframes; iFrame++)
{
Point3F& scale = nodeScaleCache[iNode][iFrame];
if (!unitScale.equal(scale))
@ -865,7 +876,7 @@ void TSShapeLoader::setObjectMembership(TSShape::Sequence& seq, const AppSequenc
seq.frameMatters.clearAll(); // vert animation (morph) (size = objects.size())
seq.matFrameMatters.clearAll(); // UV animation (size = objects.size())
for (int iObject = 0; iObject < shape->objects.size(); iObject++)
for (S32 iObject = 0; iObject < shape->objects.size(); iObject++)
{
if (!appMeshes[shape->objects[iObject].startMeshIndex])
continue;
@ -883,16 +894,16 @@ void TSShapeLoader::setObjectMembership(TSShape::Sequence& seq, const AppSequenc
void TSShapeLoader::clearNodeTransformCache()
{
// clear out the transform caches
for (int i = 0; i < nodeRotCache.size(); i++)
for (S32 i = 0; i < nodeRotCache.size(); i++)
delete [] nodeRotCache[i];
nodeRotCache.clear();
for (int i = 0; i < nodeTransCache.size(); i++)
for (S32 i = 0; i < nodeTransCache.size(); i++)
delete [] nodeTransCache[i];
nodeTransCache.clear();
for (int i = 0; i < nodeScaleRotCache.size(); i++)
for (S32 i = 0; i < nodeScaleRotCache.size(); i++)
delete [] nodeScaleRotCache[i];
nodeScaleRotCache.clear();
for (int i = 0; i < nodeScaleCache.size(); i++)
for (S32 i = 0; i < nodeScaleCache.size(); i++)
delete [] nodeScaleCache[i];
nodeScaleCache.clear();
}
@ -903,23 +914,23 @@ void TSShapeLoader::fillNodeTransformCache(TSShape::Sequence& seq, const AppSequ
clearNodeTransformCache();
nodeRotCache.setSize(appNodes.size());
for (int i = 0; i < nodeRotCache.size(); i++)
for (S32 i = 0; i < nodeRotCache.size(); i++)
nodeRotCache[i] = new QuatF[seq.numKeyframes];
nodeTransCache.setSize(appNodes.size());
for (int i = 0; i < nodeTransCache.size(); i++)
for (S32 i = 0; i < nodeTransCache.size(); i++)
nodeTransCache[i] = new Point3F[seq.numKeyframes];
nodeScaleRotCache.setSize(appNodes.size());
for (int i = 0; i < nodeScaleRotCache.size(); i++)
for (S32 i = 0; i < nodeScaleRotCache.size(); i++)
nodeScaleRotCache[i] = new QuatF[seq.numKeyframes];
nodeScaleCache.setSize(appNodes.size());
for (int i = 0; i < nodeScaleCache.size(); i++)
for (S32 i = 0; i < nodeScaleCache.size(); i++)
nodeScaleCache[i] = new Point3F[seq.numKeyframes];
// get the node transforms for every frame
for (int iFrame = 0; iFrame < seq.numKeyframes; iFrame++)
for (S32 iFrame = 0; iFrame < seq.numKeyframes; iFrame++)
{
F32 time = appSeq->getStart() + seq.duration * iFrame / getMax(1, seq.numKeyframes - 1);
for (int iNode = 0; iNode < appNodes.size(); iNode++)
for (S32 iNode = 0; iNode < appNodes.size(); iNode++)
{
generateNodeTransform(appNodes[iNode], time, seq.isBlend(), appSeq->getBlendRefTime(),
nodeRotCache[iNode][iFrame], nodeTransCache[iNode][iFrame],
@ -973,9 +984,9 @@ void TSShapeLoader::generateNodeAnimation(TSShape::Sequence& seq)
(seq.flags & TSShape::AlignedScale) ? shape->nodeAlignedScales.size() :
shape->nodeUniformScales.size();
for (int iNode = 0; iNode < appNodes.size(); iNode++)
for (S32 iNode = 0; iNode < appNodes.size(); iNode++)
{
for (int iFrame = 0; iFrame < seq.numKeyframes; iFrame++)
for (S32 iFrame = 0; iFrame < seq.numKeyframes; iFrame++)
{
if (seq.rotationMatters.test(iNode))
addNodeRotation(nodeRotCache[iNode][iFrame], false);
@ -1001,7 +1012,7 @@ void TSShapeLoader::generateObjectAnimation(TSShape::Sequence& seq, const AppSeq
{
seq.baseObjectState = shape->objectStates.size();
for (int iObject = 0; iObject < shape->objects.size(); iObject++)
for (S32 iObject = 0; iObject < shape->objects.size(); iObject++)
{
bool visMatters = seq.visMatters.test(iObject);
bool frameMatters = seq.frameMatters.test(iObject);
@ -1009,7 +1020,7 @@ void TSShapeLoader::generateObjectAnimation(TSShape::Sequence& seq, const AppSeq
if (visMatters || frameMatters || matFrameMatters)
{
for (int iFrame = 0; iFrame < seq.numKeyframes; iFrame++)
for (S32 iFrame = 0; iFrame < seq.numKeyframes; iFrame++)
{
F32 time = appSeq->getStart() + seq.duration * iFrame / getMax(1, seq.numKeyframes - 1);
generateObjectState(shape->objects[iObject], time, frameMatters, matFrameMatters);
@ -1036,7 +1047,7 @@ void TSShapeLoader::generateGroundAnimation(TSShape::Sequence& seq, const AppSeq
zapScale(invStartMat);
invStartMat.inverse();
for (int iFrame = 0; iFrame < seq.numGroundFrames; iFrame++)
for (S32 iFrame = 0; iFrame < seq.numGroundFrames; iFrame++)
{
F32 time = appSeq->getStart() + seq.duration * iFrame / getMax(1, seq.numGroundFrames - 1);
@ -1064,7 +1075,7 @@ void TSShapeLoader::generateFrameTriggers(TSShape::Sequence& seq, const AppSeque
seq.flags |= TSShape::MakePath;
// Add triggers
for (int iTrigger = 0; iTrigger < seq.numTriggers; iTrigger++)
for (S32 iTrigger = 0; iTrigger < seq.numTriggers; iTrigger++)
{
shape->triggers.increment();
appSeq->getTrigger(iTrigger, shape->triggers.last());
@ -1075,7 +1086,7 @@ void TSShapeLoader::generateFrameTriggers(TSShape::Sequence& seq, const AppSeque
// need to mark ourselves as such so that on/off can become off/on when sequence
// is played in reverse...
U32 offTriggers = 0;
for (int iTrigger = 0; iTrigger < seq.numTriggers; iTrigger++)
for (S32 iTrigger = 0; iTrigger < seq.numTriggers; iTrigger++)
{
U32 state = shape->triggers[seq.firstTrigger+iTrigger].state;
if ((state & TSShape::Trigger::StateOn) == 0)
@ -1098,18 +1109,18 @@ void TSShapeLoader::sortDetails()
// Insert NULL meshes where required
for (int iSub = 0; iSub < subshapes.size(); iSub++)
for (S32 iSub = 0; iSub < subshapes.size(); iSub++)
{
Vector<S32> validDetails;
shape->getSubShapeDetails(iSub, validDetails);
for (int iDet = 0; iDet < validDetails.size(); iDet++)
for (S32 iDet = 0; iDet < validDetails.size(); iDet++)
{
TSShape::Detail &detail = shape->details[validDetails[iDet]];
if (detail.subShapeNum >= 0)
detail.objectDetailNum = iDet;
for (int iObj = shape->subShapeFirstObject[iSub];
for (S32 iObj = shape->subShapeFirstObject[iSub];
iObj < (shape->subShapeFirstObject[iSub] + shape->subShapeNumObjects[iSub]);
iObj++)
{
@ -1126,7 +1137,7 @@ void TSShapeLoader::sortDetails()
object.numMeshes++;
// Fixup the start index for the other objects
for (int k = iObj+1; k < shape->objects.size(); k++)
for (S32 k = iObj+1; k < shape->objects.size(); k++)
shape->objects[k].startMeshIndex++;
}
}
@ -1256,17 +1267,67 @@ TSShapeLoader::~TSShapeLoader()
clearNodeTransformCache();
// Clear shared AppMaterial list
for (int iMat = 0; iMat < AppMesh::appMaterials.size(); iMat++)
for (S32 iMat = 0; iMat < AppMesh::appMaterials.size(); iMat++)
delete AppMesh::appMaterials[iMat];
AppMesh::appMaterials.clear();
// Delete Subshapes
delete boundsNode;
for (int iSub = 0; iSub < subshapes.size(); iSub++)
for (S32 iSub = 0; iSub < subshapes.size(); iSub++)
delete subshapes[iSub];
// Delete AppSequences
for (int iSeq = 0; iSeq < appSequences.size(); iSeq++)
for (S32 iSeq = 0; iSeq < appSequences.size(); iSeq++)
delete appSequences[iSeq];
appSequences.clear();
}
// Static functions to handle supported formats for shape loader.
void TSShapeLoader::addFormat(String name, String extension)
{
ShapeFormat newFormat;
newFormat.mName = name;
newFormat.mExtension = extension;
smFormats.push_back(newFormat);
}
String TSShapeLoader::getFormatExtensions()
{
// "*.dsq TAB *.dae TAB
StringBuilder output;
for(U32 n = 0; n < smFormats.size(); ++n)
{
output.append("*.");
output.append(smFormats[n].mExtension);
output.append("\t");
}
return output.end();
}
String TSShapeLoader::getFormatFilters()
{
// "DSQ Files|*.dsq|COLLADA Files|*.dae|"
StringBuilder output;
for(U32 n = 0; n < smFormats.size(); ++n)
{
output.append(smFormats[n].mName);
output.append("|*.");
output.append(smFormats[n].mExtension);
output.append("|");
}
return output.end();
}
DefineConsoleFunction( getFormatExtensions, const char*, ( ),,
"Returns a list of supported shape format extensions separated by tabs."
"Example output: *.dsq TAB *.dae TAB")
{
return Con::getReturnBuffer(TSShapeLoader::getFormatExtensions());
}
DefineConsoleFunction( getFormatFilters, const char*, ( ),,
"Returns a list of supported shape formats in filter form.\n"
"Example output: DSQ Files|*.dsq|COLLADA Files|*.dae|")
{
return Con::getReturnBuffer(TSShapeLoader::getFormatFilters());
}

View file

@ -45,6 +45,19 @@
class TSShapeLoader
{
// Supported Format List
protected:
struct ShapeFormat
{
String mName;
String mExtension;
};
static Vector<ShapeFormat> smFormats;
public:
static void addFormat(String name, String extension);
static String getFormatExtensions();
static String getFormatFilters();
public:
enum eLoadPhases
{
@ -63,7 +76,7 @@ public:
Load_Complete = NumLoadPhases
};
static void updateProgress(int major, const char* msg, int numMinor=0, int minor=0);
static void updateProgress(S32 major, const char* msg, S32 numMinor=0, S32 minor=0);
protected:
struct Subshape
@ -82,9 +95,9 @@ protected:
public:
static const F32 DefaultTime;
static const double MinFrameRate;
static const double MaxFrameRate;
static const double AppGroundFrameRate;
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

View file

@ -293,6 +293,7 @@ void TSShapeInstance::updateTransitionNodeTransforms(TSIntegerSet& transitionNod
transitionNodes.overlap(mTransitionRotationNodes);
transitionNodes.overlap(mTransitionTranslationNodes);
transitionNodes.overlap(mTransitionScaleNodes);
transitionNodes.takeAway(mHandsOffNodes);
// Decompose transforms for nodes affected by the transition. Only need to do
// for blended or scale-animated nodes, as all others are already up to date
@ -578,6 +579,7 @@ void TSShapeInstance::handleBlendSequence(TSThread * thread, S32 a, S32 b)
TSIntegerSet nodeMatters = thread->getSequence()->translationMatters;
nodeMatters.overlap(thread->getSequence()->rotationMatters);
nodeMatters.overlap(thread->getSequence()->scaleMatters);
nodeMatters.takeAway(mHandsOffNodes);
S32 start = nodeMatters.start();
S32 end = b;
for (S32 nodeIndex=start; nodeIndex<end; nodeMatters.next(nodeIndex))

View file

@ -62,12 +62,12 @@ GFXDeclareVertexFormat( ImposterState )
/// .xyz = imposter center
/// .w = billboard corner... damn SM 2.0
Point3F center;
float corner;
F32 corner;
/// .x = scaled half size
/// .y = alpha fade out
float halfSize;
float alpha;
F32 halfSize;
F32 alpha;
/// The rotation encoded as the up
/// and right vectors... cross FTW.

View file

@ -876,18 +876,33 @@ bool TSMesh::castRayRendered( S32 frame, const Point3F & start, const Point3F &
bool TSMesh::addToHull( U32 idx0, U32 idx1, U32 idx2 )
{
Point3F normal;
mCross(mVertexData[idx2].vert()-mVertexData[idx0].vert(),mVertexData[idx1].vert()-mVertexData[idx0].vert(),&normal);
if ( mDot( normal, normal ) < 0.001f )
// calculate the normal of this triangle... remember, we lose precision
// when we subtract two large numbers that are very close to each other,
// so depending on how we calculate the normal, we could get a
// different result. so, we will calculate the normal three different
// ways and take the one that gives us the largest vector before we
// normalize.
Point3F normal1, normal2, normal3;
mCross(mVertexData[idx2].vert()-mVertexData[idx0].vert(),mVertexData[idx1].vert()-mVertexData[idx0].vert(),&normal1);
mCross(mVertexData[idx0].vert()-mVertexData[idx1].vert(),mVertexData[idx2].vert()-mVertexData[idx1].vert(),&normal2);
mCross(mVertexData[idx1].vert()-mVertexData[idx2].vert(),mVertexData[idx0].vert()-mVertexData[idx2].vert(),&normal3);
Point3F normal = normal1;
F32 greatestMagSquared = mDot(normal1, normal1);
F32 magSquared = mDot(normal2, normal2);
if (magSquared > greatestMagSquared)
{
mCross( mVertexData[idx0].vert() - mVertexData[idx1].vert(), mVertexData[idx2].vert() - mVertexData[idx1].vert(), &normal );
if ( mDot( normal, normal ) < 0.001f )
{
mCross( mVertexData[idx1].vert() - mVertexData[idx2].vert(), mVertexData[idx0].vert() - mVertexData[idx2].vert(), &normal );
if ( mDot( normal, normal ) < 0.001f )
return false;
}
normal = normal2;
greatestMagSquared = magSquared;
}
magSquared = mDot(normal3, normal3);
if (magSquared > greatestMagSquared)
{
normal = normal3;
greatestMagSquared = magSquared;
}
if (mDot(normal, normal) < 0.00000001f)
return false;
normal.normalize();
F32 k = mDot( normal, mVertexData[idx0].vert() );
for ( S32 i = 0; i < planeNormals.size(); i++ )
@ -1188,7 +1203,7 @@ void TSSkinMesh::updateSkin( const Vector<MatrixF> &transforms, TSVertexBufferHa
// set up bone transforms
PROFILE_START(TSSkinMesh_UpdateTransforms);
for( int i=0; i<batchData.nodeIndex.size(); i++ )
for( S32 i=0; i<batchData.nodeIndex.size(); i++ )
{
S32 node = batchData.nodeIndex[i];
sBoneTransforms[i].mul( transforms[node], batchData.initialTransforms[i] );
@ -1218,7 +1233,7 @@ void TSSkinMesh::updateSkin( const Vector<MatrixF> &transforms, TSVertexBufferHa
skinnedVert.zero();
skinnedNorm.zero();
for( int tOp = 0; tOp < curVert.transformCount; tOp++ )
for( S32 tOp = 0; tOp < curVert.transformCount; tOp++ )
{
const BatchData::TransformOp &transformOp = curVert.transform[tOp];
@ -1254,6 +1269,7 @@ void TSSkinMesh::updateSkin( const Vector<MatrixF> &transforms, TSVertexBufferHa
// Lock, and skin directly into the final memory destination
outPtr = (U8 *)instanceVB.lock();
if(!outPtr) return;
#endif
// Set position/normal to zero so we can accumulate
zero_vert_normal_bulk(mNumVerts, outPtr, outStride);
@ -1402,7 +1418,7 @@ void TSSkinMesh::createBatchData()
itr != batchOperations.end(); itr++ )
{
const BatchData::BatchedVertex &curTransform = *itr;
for( int i = 0; i < curTransform.transformCount; i++ )
for( S32 i = 0; i < curTransform.transformCount; i++ )
{
const BatchData::TransformOp &transformOp = curTransform.transform[i];
@ -1427,8 +1443,8 @@ void TSSkinMesh::createBatchData()
// Now iterate the resulting operations and convert the vectors to aligned
// memory locations
const int numBatchOps = batchData.transformKeys.size();
for(int i = 0; i < numBatchOps; i++)
const S32 numBatchOps = batchData.transformKeys.size();
for(S32 i = 0; i < numBatchOps; i++)
{
BatchData::BatchedTransform &curTransform = *batchData.transformBatchOperations.retreive(batchData.transformKeys[i]);
const S32 numVerts = curTransform._tmpVec->size();
@ -1446,7 +1462,7 @@ void TSSkinMesh::createBatchData()
}
// Now sort the batch data so that the skin function writes close to linear output
for(int i = 0; i < numBatchOps; i++)
for(S32 i = 0; i < numBatchOps; i++)
{
BatchData::BatchedTransform &curTransform = *batchData.transformBatchOperations.retreive(batchData.transformKeys[i]);
dQsort(curTransform.alignedMem, curTransform.numElements, sizeof(BatchData::BatchedVertWeight), _sort_BatchedVertWeight);
@ -2379,6 +2395,7 @@ void TSMesh::_createVBIB( TSVertexBufferHandle &vb, GFXPrimitiveBufferHandle &pb
// Copy from aligned memory right into GPU memory
U8 *vertData = (U8*)vb.lock();
if(!vertData) return;
#if defined(TORQUE_OS_XENON)
XMemCpyStreaming_WriteCombined( vertData, mVertexData.address(), mVertexData.mem_size() );
#else
@ -2541,7 +2558,7 @@ void TSMesh::assemble( bool skip )
// need to copy to temporary arrays
deleteInputArrays = true;
primIn = new TSDrawPrimitive[szPrimIn];
for (int i = 0; i < szPrimIn; i++)
for (S32 i = 0; i < szPrimIn; i++)
{
primIn[i].start = prim16[i*2];
primIn[i].numElements = prim16[i*2+1];
@ -2900,8 +2917,11 @@ inline void TSMesh::findTangent( U32 index1,
F32 denom = (s1 * t2 - s2 * t1);
if( mFabs( denom ) < 0.0001f )
return; // handle degenerate triangles from strips
{
// handle degenerate triangles from strips
if (denom<0) denom = -0.0001f;
else denom = 0.0001f;
}
F32 r = 1.0f / denom;
Point3F sdir( (t2 * x1 - t1 * x2) * r,
@ -2929,7 +2949,11 @@ inline void TSMesh::findTangent( U32 index1,
void TSMesh::createTangents(const Vector<Point3F> &_verts, const Vector<Point3F> &_norms)
{
U32 numVerts = _verts.size();
if ( numVerts == 0 )
U32 numNorms = _norms.size();
if ( numVerts <= 0 || numNorms <= 0 )
return;
if( numVerts != numNorms)
return;
Vector<Point3F> tan0;

View file

@ -214,7 +214,7 @@ class TSMesh
}
// Vector-like interface
__TSMeshVertexBase &operator[](int idx) const { AssertFatal(idx < numElements, "Out of bounds access!"); return *reinterpret_cast<__TSMeshVertexBase *>(base + idx * vertSz); }
__TSMeshVertexBase &operator[](S32 idx) const { AssertFatal(idx < numElements, "Out of bounds access!"); return *reinterpret_cast<__TSMeshVertexBase *>(base + idx * vertSz); }
__TSMeshVertexBase *address() const { return reinterpret_cast<__TSMeshVertexBase *>(base); }
U32 size() const { return numElements; }
dsize_t mem_size() const { return numElements * vertSz; }

View file

@ -402,7 +402,7 @@ F32 MeshFit::maxDot( const VectorF& v ) const
// Best-fit oriented bounding box
void MeshFit::addBox( const Point3F& sides, const MatrixF& mat )
{
TSMesh* mesh = initMeshFromFile( "core/art/shapes/unit_cube.dts" );
TSMesh* mesh = initMeshFromFile( TSShapeConstructor::getCubeShapePath() );
if ( !mesh )
return;
@ -431,7 +431,7 @@ void MeshFit::fitOBB()
// Best-fit sphere
void MeshFit::addSphere( F32 radius, const Point3F& center )
{
TSMesh* mesh = initMeshFromFile( "core/art/shapes/unit_sphere.dts" );
TSMesh* mesh = initMeshFromFile( TSShapeConstructor::getSphereShapePath() );
if ( !mesh )
return;
@ -460,7 +460,7 @@ void MeshFit::fitSphere()
// Best-fit capsule
void MeshFit::addCapsule( F32 radius, F32 height, const MatrixF& mat )
{
TSMesh* mesh = initMeshFromFile( "core/art/shapes/unit_capsule.dts" );
TSMesh* mesh = initMeshFromFile( TSShapeConstructor::getCapsuleShapePath() );
if ( !mesh )
return;

View file

@ -38,7 +38,7 @@ void zero_vert_normal_bulk_C(const dsize_t count, U8 * __restrict const outPtr,
// TODO: Try prefetch w/ ptr de-reference
for(register int i = 0; i < count; i++)
for(register S32 i = 0; i < count; i++)
{
TSMesh::__TSMeshVertexBase *outElem = reinterpret_cast<TSMesh::__TSMeshVertexBase *>(outData);
outElem->_vert.zero();
@ -60,7 +60,7 @@ void m_matF_x_BatchedVertWeightList_C(const MatrixF &mat,
register Point3F tempPt;
register Point3F tempNrm;
for(register int i = 0; i < count; i++)
for(register S32 i = 0; i < count; i++)
{
const TSSkinMesh::BatchData::BatchedVertWeight &inElem = batch[i];

View file

@ -1170,13 +1170,21 @@ void TSShape::assembleShape()
skip = true;
TSMesh * mesh = TSMesh::assembleMesh(meshType,skip);
if (ptr32)
{
ptr32[i] = skip ? 0 : (S32)mesh;
meshes.push_back(skip ? 0 : mesh);
}
// fill in location of verts, tverts, and normals for detail levels
if (mesh && meshType!=TSMesh::DecalMeshType)
{
TSMesh::smVertsList[i] = mesh->verts.address();
TSMesh::smTVertsList[i] = mesh->tverts.address();
if (smReadVersion >= 26)
{
TSMesh::smTVerts2List[i] = mesh->tverts2.address();
TSMesh::smColorsList[i] = mesh->colors.address();
}
TSMesh::smNormsList[i] = mesh->norms.address();
TSMesh::smEncodedNormsList[i] = mesh->encodedNorms.address();
TSMesh::smDataCopied[i] = !skip; // as long as we didn't skip this mesh, the data should be in shape now
@ -1193,7 +1201,6 @@ void TSShape::assembleShape()
}
}
}
meshes.set(ptr32,numMeshes);
tsalloc.checkGuard();
@ -1220,7 +1227,7 @@ void TSShape::assembleShape()
if (smReadVersion<23)
{
// get detail information about skins...
S32 * detailFirstSkin = tsalloc.getPointer32(numDetails);
S32 * detFirstSkin = tsalloc.getPointer32(numDetails);
S32 * detailNumSkins = tsalloc.getPointer32(numDetails);
tsalloc.checkGuard();
@ -1252,7 +1259,7 @@ void TSShape::assembleShape()
ptr32 = tsalloc.allocShape32(numSkins);
for (i=0; i<numSkins; i++)
{
bool skip = i<detailFirstSkin[skipDL];
bool skip = i<detFirstSkin[skipDL];
TSSkinMesh * skin = (TSSkinMesh*)TSMesh::assembleMesh(TSMesh::SkinMeshType,skip);
if (meshes.address())
{
@ -1281,7 +1288,7 @@ void TSShape::assembleShape()
tsalloc.checkGuard();
// we now have skins in mesh list...add skin objects to object list and patch things up
fixupOldSkins(numMeshes,numSkins,numDetails,detailFirstSkin,detailNumSkins);
fixupOldSkins(numMeshes,numSkins,numDetails,detFirstSkin,detailNumSkins);
}
// allocate storage space for some arrays (filled in during Shape::init)...

View file

@ -597,7 +597,7 @@ class TSShape
/// mem buffer transfer helper (indicate when we don't want to include a particular mesh/decal)
bool checkSkip(S32 meshNum, S32 & curObject, S32 skipDL);
void fixupOldSkins(S32 numMeshes, S32 numSkins, S32 numDetails, S32 * detailFirstSkin, S32 * detailNumSkins);
void fixupOldSkins(S32 numMeshes, S32 numSkins, S32 numDetails, S32 * detFirstSkin, S32 * detailNumSkins);
/// @name Shape Editing
/// @{

View file

@ -213,7 +213,6 @@ void TSShapeAlloc::checkGuard()
bool check32 = checkGuard32();
bool check16 = checkGuard16();
bool check8 = checkGuard8();
AssertFatal(check32,avar("TSShapeAlloc::checkGuard32: found %i, wanted %i",getSaveGuard32(),getPrevGuard32()));
AssertFatal(check16,avar("TSShapeAlloc::checkGuard16: found %i, wanted %i",getSaveGuard16(),getPrevGuard16()));
AssertFatal(check8 ,avar("TSShapeAlloc::checkGuard8: found %i, wanted %i",getSaveGuard8() ,getPrevGuard8()));

View file

@ -74,6 +74,10 @@ EndImplementEnumType;
//-----------------------------------------------------------------------------
String TSShapeConstructor::smCapsuleShapePath("core/art/shapes/unit_capsule.dts");
String TSShapeConstructor::smCubeShapePath("core/art/shapes/unit_cube.dts");
String TSShapeConstructor::smSphereShapePath("core/art/shapes/unit_sphere.dts");
ResourceRegisterPostLoadSignal< TSShape > TSShapeConstructor::_smAutoLoad( &TSShapeConstructor::_onTSShapeLoaded );
ResourceRegisterUnloadSignal< TSShape > TSShapeConstructor::_smAutoUnload( &TSShapeConstructor::_onTSShapeUnloaded );
@ -280,6 +284,23 @@ void TSShapeConstructor::initPersistFields()
Parent::initPersistFields();
}
void TSShapeConstructor::consoleInit()
{
Parent::consoleInit();
Con::addVariable( "$pref::TSShapeConstructor::CapsuleShapePath", TypeRealString, &TSShapeConstructor::smCapsuleShapePath,
"The file path to the capsule shape used by tsMeshFit.\n\n"
"@ingroup MeshFit\n" );
Con::addVariable( "$pref::TSShapeConstructor::CubeShapePath", TypeRealString, &TSShapeConstructor::smCubeShapePath,
"The file path to the cube shape used by tsMeshFit.\n\n"
"@ingroup MeshFit\n" );
Con::addVariable( "$pref::TSShapeConstructor::SphereShapePath", TypeRealString, &TSShapeConstructor::smSphereShapePath,
"The file path to the sphere shape used by tsMeshFit.\n\n"
"@ingroup MeshFit\n" );
}
TSShapeConstructor* TSShapeConstructor::findShapeConstructor(const FileName& path)
{
SimGroup *group;
@ -1195,8 +1216,9 @@ DefineTSShapeConstructorMethod( getMeshName, const char*, ( const char* name, S3
CHECK_INDEX_IN_RANGE( getMeshName, index, objectDetails.size(), "" );
char* returnBuffer = Con::getReturnBuffer(256);
dSprintf(returnBuffer, 256, "%s %d", name, (S32)mShape->details[objectDetails[index]].size);
static const U32 bufSize = 256;
char* returnBuffer = Con::getReturnBuffer(bufSize);
dSprintf(returnBuffer, bufSize, "%s %d", name, (S32)mShape->details[objectDetails[index]].size);
return returnBuffer;
}}
@ -1581,8 +1603,9 @@ DefineTSShapeConstructorMethod( getImposterSettings, const char*, ( S32 index ),
// Return information about the detail level
const TSShape::Detail& det = mShape->details[index];
char* returnBuffer = Con::getReturnBuffer(512);
dSprintf(returnBuffer, 512, "%d\t%d\t%d\t%d\t%d\t%d\t%g",
static const U32 bufSize = 512;
char* returnBuffer = Con::getReturnBuffer(bufSize);
dSprintf(returnBuffer, bufSize, "%d\t%d\t%d\t%d\t%d\t%d\t%g",
(S32)( det.subShapeNum < 0 ), // isImposter
det.bbEquatorSteps,
det.bbPolarSteps,
@ -1706,8 +1729,9 @@ DefineTSShapeConstructorMethod( getSequenceSource, const char*, ( const char* na
GET_SEQUENCE( getSequenceSource, seq, name, "" );
// Return information about the source data for this sequence
char* returnBuffer = Con::getReturnBuffer(512);
dSprintf( returnBuffer, 512, "%s\t%d\t%d\t%d",
static const U32 bufSize = 512;
char* returnBuffer = Con::getReturnBuffer(bufSize);
dSprintf( returnBuffer, bufSize, "%s\t%d\t%d\t%d",
seq->sourceData.from.c_str(), seq->sourceData.start,
seq->sourceData.end, seq->sourceData.total );
return returnBuffer;
@ -1781,8 +1805,9 @@ DefineTSShapeConstructorMethod( getSequenceGroundSpeed, const char*, ( const cha
rot = mat.toEuler();
}
char* returnBuffer = Con::getReturnBuffer(256);
dSprintf( returnBuffer, 256, "%g %g %g %g %g %g",
static const U32 bufSize = 256;
char* returnBuffer = Con::getReturnBuffer(bufSize);
dSprintf( returnBuffer, bufSize, "%g %g %g %g %g %g",
trans.x, trans.y, trans.z, rot.x, rot.y, rot.z );
return returnBuffer;
}}
@ -1875,8 +1900,9 @@ DefineTSShapeConstructorMethod( getSequenceBlend, const char*, ( const char* nam
GET_SEQUENCE( getSequenceBlend, seq, name, "0" );
// Return the blend information (flag reference_sequence reference_frame)
char* returnBuffer = Con::getReturnBuffer(512);
dSprintf( returnBuffer, 512, "%d\t%s\t%d", (int)seq->isBlend(),
static const U32 bufSize = 512;
char* returnBuffer = Con::getReturnBuffer(bufSize);
dSprintf( returnBuffer, bufSize, "%d\t%s\t%d", (int)seq->isBlend(),
seq->sourceData.blendSeq.c_str(), seq->sourceData.blendFrame );
return returnBuffer;
}}
@ -2017,8 +2043,9 @@ DefineTSShapeConstructorMethod( getTrigger, const char*, ( const char* name, S32
if (!(trig.state & TSShape::Trigger::StateOn))
state = -state;
char* returnBuffer = Con::getReturnBuffer(32);
dSprintf(returnBuffer, 32, "%d %d", frame, state);
static const U32 bufSize = 32;
char* returnBuffer = Con::getReturnBuffer(bufSize);
dSprintf(returnBuffer, bufSize, "%d %d", frame, state);
return returnBuffer;
}}

View file

@ -213,13 +213,18 @@ public:
void write(TSShape* shape, Stream& stream, const String& savePath);
};
static const int MaxLegacySequences = 127;
static const S32 MaxLegacySequences = 127;
protected:
FileName mShapePath;
Vector<FileName> mSequences;
ChangeSet mChangeSet;
// Paths to shapes used by MeshFit
static String smCapsuleShapePath;
static String smCubeShapePath;
static String smSphereShapePath;
static bool addSequenceFromField( void *obj, const char *index, const char *data );
static void _onTSShapeLoaded( Resource< TSShape >& shape );
@ -250,6 +255,7 @@ public:
DECLARE_CONOBJECT(TSShapeConstructor);
static void initPersistFields();
static void consoleInit();
static TSShapeConstructor* findShapeConstructor(const FileName& path);
bool onAdd();
@ -261,6 +267,13 @@ public:
void notifyShapeChanged();
/// @name Shape paths for MeshFit
///@{
static const String& getCapsuleShapePath() { return smCapsuleShapePath; }
static const String& getCubeShapePath() { return smCubeShapePath; }
static const String& getSphereShapePath() { return smSphereShapePath; }
///@}
TSShape* getShape() const { return mShape; }
const String& getShapePath() const { return mShapePath; }

View file

@ -155,7 +155,7 @@ S32 TSShape::addDetail(const String& dname, S32 size, S32 subShapeNum)
alphaOut.increment();
// Fixup objectDetailNum in other detail levels
for (int i = index+1; i < details.size(); i++)
for (S32 i = index+1; i < details.size(); i++)
{
if ((details[i].subShapeNum >= 0) &&
((subShapeNum == -1) || (details[i].subShapeNum == subShapeNum)))
@ -1521,7 +1521,7 @@ bool TSShape::addSequence(const Torque::Path& path, const String& fromSeq,
// Check if visibility is animated within the frames to be copied
const F32 defaultVis = srcShape->objectStates[i].vis;
S32 objNum = srcSeq->visMatters.count(i);
for (int iFrame = startFrame; iFrame <= endFrame; iFrame++)
for (S32 iFrame = startFrame; iFrame <= endFrame; iFrame++)
{
if (srcShape->getObjectState(*srcSeq, iFrame, objNum).vis != defaultVis)
{
@ -1600,7 +1600,7 @@ bool TSShape::addSequence(const Torque::Path& path, const String& fromSeq,
// Check if node position is animated within the frames to be copied
const Point3F& defaultTrans = srcShape->defaultTranslations[i];
S32 tranNum = srcSeq->translationMatters.count(i);
for (int iFrame = startFrame; iFrame <= endFrame; iFrame++)
for (S32 iFrame = startFrame; iFrame <= endFrame; iFrame++)
{
if (srcShape->getTranslation(*srcSeq, iFrame, tranNum) != defaultTrans)
{
@ -1615,7 +1615,7 @@ bool TSShape::addSequence(const Torque::Path& path, const String& fromSeq,
// Check if node rotation is animated within the frames to be copied
const QuatF defaultRot = srcShape->defaultRotations[i].getQuatF();
S32 rotNum = srcSeq->rotationMatters.count(i);
for (int iFrame = startFrame; iFrame <= endFrame; iFrame++)
for (S32 iFrame = startFrame; iFrame <= endFrame; iFrame++)
{
QuatF temp;
if (srcShape->getRotation(*srcSeq, iFrame, rotNum, &temp) != defaultRot)
@ -1634,7 +1634,7 @@ bool TSShape::addSequence(const Torque::Path& path, const String& fromSeq,
{
TSScale defaultScale;
defaultScale.identity();
for (int iFrame = startFrame; iFrame <= endFrame; iFrame++)
for (S32 iFrame = startFrame; iFrame <= endFrame; iFrame++)
{
TSScale temp;
if (!(srcShape->getArbitraryScale(*srcSeq, iFrame, scaleNum, &temp) == defaultScale))
@ -1647,7 +1647,7 @@ bool TSShape::addSequence(const Torque::Path& path, const String& fromSeq,
else if (srcSeq->animatesAlignedScale())
{
const Point3F defaultScale(Point3F::One);
for (int iFrame = startFrame; iFrame <= endFrame; iFrame++)
for (S32 iFrame = startFrame; iFrame <= endFrame; iFrame++)
{
if (srcShape->getAlignedScale(*srcSeq, iFrame, scaleNum) != defaultScale)
{
@ -1659,7 +1659,7 @@ bool TSShape::addSequence(const Torque::Path& path, const String& fromSeq,
else if (srcSeq->animatesUniformScale())
{
const F32 defaultScale = 1.0f;
for (int iFrame = startFrame; iFrame <= endFrame; iFrame++)
for (S32 iFrame = startFrame; iFrame <= endFrame; iFrame++)
{
if (srcShape->getUniformScale(*srcSeq, iFrame, scaleNum) != defaultScale)
{

View file

@ -259,8 +259,10 @@ void TSShapeInstance::cloneMaterialList( const FeatureSet *features )
if ( mOwnMaterialList )
return;
Material::sAllowTextureTargetAssignment = true;
mMaterialList = new TSMaterialList(mMaterialList);
initMaterialList( features );
Material::sAllowTextureTargetAssignment = false;
mOwnMaterialList = true;
}
@ -614,6 +616,11 @@ S32 TSShapeInstance::setDetailFromDistance( const SceneRenderState *state, F32 s
F32 pixelRadius = ( mShape->radius / scaledDistance ) * state->getWorldToScreenScale().y * pixelScale;
F32 pixelSize = pixelRadius * smDetailAdjust;
if ( pixelSize < smSmallestVisiblePixelSize ) {
mCurrentDetailLevel = -1;
return mCurrentDetailLevel;
}
if ( pixelSize > smSmallestVisiblePixelSize &&
pixelSize <= mShape->mSmallestVisibleSize )
pixelSize = mShape->mSmallestVisibleSize + 0.01f;

View file

@ -485,8 +485,8 @@ protected:
/// @}
virtual void render( const TSRenderState &rdata );
virtual void render( const TSRenderState &rdata, S32 dl, F32 intraDL = 0.0f );
void render( const TSRenderState &rdata );
void render( const TSRenderState &rdata, S32 dl, F32 intraDL = 0.0f );
void animate() { animate( mCurrentDetailLevel ); }
void animate(S32 dl);

View file

@ -29,7 +29,7 @@
// put old skins into object list
//-------------------------------------------------
void TSShape::fixupOldSkins(S32 numMeshes, S32 numSkins, S32 numDetails, S32 * detailFirstSkin, S32 * detailNumSkins)
void TSShape::fixupOldSkins(S32 numMeshes, S32 numSkins, S32 numDetails, S32 * detFirstSkin, S32 * detailNumSkins)
{
#if !defined(TORQUE_MAX_LIB)
// this method not necessary in exporter, and a couple lines won't compile for exporter
@ -63,9 +63,9 @@ void TSShape::fixupOldSkins(S32 numMeshes, S32 numSkins, S32 numDetails, S32 * d
// find one mesh per detail to add to this object
// don't really need to be versions of the same object
i = 0;
while (i<detailFirstSkin[dl] || detailFirstSkin[dl]<0)
while (i<detFirstSkin[dl] || detFirstSkin[dl]<0)
i++;
for (; i<numSkins && i<detailFirstSkin[dl]+detailNumSkins[dl]; i++)
for (; i<numSkins && i<detFirstSkin[dl]+detailNumSkins[dl]; i++)
{
if (skins[i])
{
@ -77,7 +77,7 @@ void TSShape::fixupOldSkins(S32 numMeshes, S32 numSkins, S32 numDetails, S32 * d
break;
}
}
if (i==numSkins || i==detailFirstSkin[dl]+detailNumSkins[dl])
if (i==numSkins || i==detFirstSkin[dl]+detailNumSkins[dl])
{
skinsCopy.push_back(NULL);
object.numMeshes++;