Merge remote-tracking branch 'upstream/development' into test-vcpkg-local

This commit is contained in:
marauder2k7 2026-06-20 19:32:26 +01:00
commit bbf207872e
4 changed files with 61 additions and 15 deletions

View file

@ -79,7 +79,37 @@ const char* AssimpAppMesh::getName(bool allowFixed)
MatrixF AssimpAppMesh::getMeshTransform(F32 time) MatrixF AssimpAppMesh::getMeshTransform(F32 time)
{ {
return appNode->getNodeTransform(time); MatrixF transform = appNode->getNodeTransform(time);
// AssimpAppNode::getTransform() deliberately skips axis correction for the
// bounds node itself, since its (uncorrected) transform is used elsewhere
// as the reference frame the rest of the shape gets normalized against
// (see TSShapeLoader::getLocalNodeMatrix). But if this mesh's geometry was
// hand-modeled as part of the source scene (as opposed to the empty,
// auto-generated bounds node added when none exists), it lives in the same
// source up-axis space as every other mesh and needs the same correction
// baked into its locked vertex data - otherwise it ends up sitting in the
// model's original, unrotated space instead of Torque's Z-up space.
if (appNode->isBounds())
{
MatrixF axisFix = ColladaUtils::getOptions().axisCorrectionMat;
transform.mulL(axisFix);
}
return transform;
}
void AssimpAppMesh::computeBounds(Box3F& bounds)
{
if (appNode->isBounds())
{
bounds = Box3F::Invalid;
for (S32 iVert = 0; iVert < points.size(); iVert++)
bounds.extend(points[iVert]);
return;
}
Parent::computeBounds(bounds);
} }
void AssimpAppMesh::lockMesh(F32 t, const MatrixF& objOffset) void AssimpAppMesh::lockMesh(F32 t, const MatrixF& objOffset)

View file

@ -119,7 +119,7 @@ public:
/// @return The mesh transform at the specified time /// @return The mesh transform at the specified time
MatrixF getMeshTransform(F32 time) override; MatrixF getMeshTransform(F32 time) override;
F32 getVisValue(F32 t) override; F32 getVisValue(F32 t) override;
void computeBounds(Box3F& bounds) override;
static Vector<S32> sMaterialRemap; static Vector<S32> sMaterialRemap;
}; };

View file

@ -84,6 +84,14 @@ MatrixF AssimpAppNode::getTransform(F32 time)
// no parent (ie. root level) => scale by global shape <unit> // no parent (ie. root level) => scale by global shape <unit>
mLastTransform.identity(); mLastTransform.identity();
mLastTransform.scale(ColladaUtils::getOptions().unit * ColladaUtils::getOptions().formatScaleFactor); mLastTransform.scale(ColladaUtils::getOptions().unit * ColladaUtils::getOptions().formatScaleFactor);
if (mScene && mScene->mRootNode)
{
MatrixF sceneRootMat(true);
assimpToTorqueMat(mScene->mRootNode->mTransformation, sceneRootMat);
mLastTransform.mulL(sceneRootMat);
}
if (!isBounds()) if (!isBounds())
{ {
MatrixF axisFix = ColladaUtils::getOptions().axisCorrectionMat; MatrixF axisFix = ColladaUtils::getOptions().axisCorrectionMat;

View file

@ -981,13 +981,21 @@ static bool sReadAssimp(const Torque::Path &path, TSShape*& res_shape)
// Allow TSShapeConstructor object to override properties // Allow TSShapeConstructor object to override properties
ColladaUtils::getOptions().reset(); ColladaUtils::getOptions().reset();
TSShapeConstructor* tscon = TSShapeConstructor::findShapeConstructorByFilename(path.getFullPath()); TSShapeConstructor* tscon = TSShapeConstructor::findShapeConstructorByFilename(path.getFullPath());
bool autoDetectUpAxis = true;
if (tscon) if (tscon)
{ {
ColladaUtils::getOptions() = tscon->mOptions; ColladaUtils::getOptions() = tscon->mOptions;
autoDetectUpAxis = (tscon->mOptions.upAxis == UPAXISTYPE_COUNT);
} }
AssimpShapeLoader loader; AssimpShapeLoader loader;
TSShape* tss = loader.generateShape(path); TSShape* tss = loader.generateShape(path);
if (tscon && autoDetectUpAxis)
{
tscon->mOptions = ColladaUtils::getOptions();
}
if (tss) if (tss)
{ {
TSShapeLoader::updateProgress(TSShapeLoader::Load_Complete, "Import complete"); TSShapeLoader::updateProgress(TSShapeLoader::Load_Complete, "Import complete");