From 6355da5df63b05f780579cbb2ff46ae29d3dea79 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Fri, 1 Mar 2024 15:01:47 +0000 Subject: [PATCH] various fixes STB probably shouldn't fail on failed info, just continue. Assimp only add sequences if there are any. Update kork chan asset. --- .../source/gfx/bitmap/loaders/bitmapSTB.cpp | 6 +-- Engine/source/ts/assimp/assimpShapeLoader.cpp | 54 ++++++++++--------- .../shapes/kork_chanShape.asset.taml | 6 --- .../Prototyping/shapes/kork_chanShape.tscript | 30 ++--------- .../shapes/kork_chanShape_shape.asset.taml | 5 ++ .../shapes/kork_chan_image.asset.taml | 3 +- .../shapes/kork_chan_mat.asset.taml | 7 ++- 7 files changed, 44 insertions(+), 67 deletions(-) delete mode 100644 Templates/BaseGame/game/data/Prototyping/shapes/kork_chanShape.asset.taml create mode 100644 Templates/BaseGame/game/data/Prototyping/shapes/kork_chanShape_shape.asset.taml diff --git a/Engine/source/gfx/bitmap/loaders/bitmapSTB.cpp b/Engine/source/gfx/bitmap/loaders/bitmapSTB.cpp index 00ef53891..6eb79895c 100644 --- a/Engine/source/gfx/bitmap/loaders/bitmapSTB.cpp +++ b/Engine/source/gfx/bitmap/loaders/bitmapSTB.cpp @@ -200,8 +200,7 @@ bool sReadSTB(const Torque::Path& path, GBitmap* bitmap) if (!stbErr) stbErr = "Unknown Error!"; - Con::errorf("STB failed to get image info: %s", stbErr); - return false; + Con::errorf("STB get file info: %s", stbErr); } // do this to map 2 channels to 4, 2 channel not supported by gbitmap yet.. @@ -331,8 +330,7 @@ bool sReadStreamSTB(Stream& stream, GBitmap* bitmap, U32 len) if (!stbErr) stbErr = "Unknown Error!"; - Con::errorf("STB failed to get image info: %s", stbErr); - Con::warnf("Going to attempt to load stream anyway."); + Con::errorf("STB get memory info: %s", stbErr); } S32 reqCom = comp; diff --git a/Engine/source/ts/assimp/assimpShapeLoader.cpp b/Engine/source/ts/assimp/assimpShapeLoader.cpp index 908e186f2..8478e4b78 100644 --- a/Engine/source/ts/assimp/assimpShapeLoader.cpp +++ b/Engine/source/ts/assimp/assimpShapeLoader.cpp @@ -261,38 +261,40 @@ void AssimpShapeLoader::processAnimations() Vector ambientChannels; F32 duration = 0.0f; - - for (U32 i = 0; i < mScene->mNumAnimations; ++i) + if (mScene->mNumAnimations > 0) { - aiAnimation* anim = mScene->mAnimations[i]; - for (U32 j = 0; j < anim->mNumChannels; j++) + for (U32 i = 0; i < mScene->mNumAnimations; ++i) { - aiNodeAnim* nodeAnim = anim->mChannels[j]; - // Determine the maximum keyframe time for this animation - F32 maxKeyTime = 0.0f; - for (U32 k = 0; k < nodeAnim->mNumPositionKeys; k++) { - maxKeyTime = getMax(maxKeyTime, (F32)nodeAnim->mPositionKeys[k].mTime); - } - for (U32 k = 0; k < nodeAnim->mNumRotationKeys; k++) { - maxKeyTime = getMax(maxKeyTime, (F32)nodeAnim->mRotationKeys[k].mTime); - } - for (U32 k = 0; k < nodeAnim->mNumScalingKeys; k++) { - maxKeyTime = getMax(maxKeyTime, (F32)nodeAnim->mScalingKeys[k].mTime); - } + aiAnimation* anim = mScene->mAnimations[i]; + for (U32 j = 0; j < anim->mNumChannels; j++) + { + aiNodeAnim* nodeAnim = anim->mChannels[j]; + // Determine the maximum keyframe time for this animation + F32 maxKeyTime = 0.0f; + for (U32 k = 0; k < nodeAnim->mNumPositionKeys; k++) { + maxKeyTime = getMax(maxKeyTime, (F32)nodeAnim->mPositionKeys[k].mTime); + } + for (U32 k = 0; k < nodeAnim->mNumRotationKeys; k++) { + maxKeyTime = getMax(maxKeyTime, (F32)nodeAnim->mRotationKeys[k].mTime); + } + for (U32 k = 0; k < nodeAnim->mNumScalingKeys; k++) { + maxKeyTime = getMax(maxKeyTime, (F32)nodeAnim->mScalingKeys[k].mTime); + } - ambientChannels.push_back(nodeAnim); + ambientChannels.push_back(nodeAnim); - duration = getMax(duration, maxKeyTime); + duration = getMax(duration, maxKeyTime); + } } + + ambientSeq->mNumChannels = ambientChannels.size(); + ambientSeq->mChannels = ambientChannels.address(); + ambientSeq->mDuration = duration; + ambientSeq->mTicksPerSecond = 24.0; + + AssimpAppSequence* defaultAssimpSeq = new AssimpAppSequence(ambientSeq); + appSequences.push_back(defaultAssimpSeq); } - - ambientSeq->mNumChannels = ambientChannels.size(); - ambientSeq->mChannels = ambientChannels.address(); - ambientSeq->mDuration = duration; - ambientSeq->mTicksPerSecond = 24.0; - - AssimpAppSequence* defaultAssimpSeq = new AssimpAppSequence(ambientSeq); - appSequences.push_back(defaultAssimpSeq); } void AssimpShapeLoader::computeBounds(Box3F& bounds) diff --git a/Templates/BaseGame/game/data/Prototyping/shapes/kork_chanShape.asset.taml b/Templates/BaseGame/game/data/Prototyping/shapes/kork_chanShape.asset.taml deleted file mode 100644 index 475aa7543..000000000 --- a/Templates/BaseGame/game/data/Prototyping/shapes/kork_chanShape.asset.taml +++ /dev/null @@ -1,6 +0,0 @@ - diff --git a/Templates/BaseGame/game/data/Prototyping/shapes/kork_chanShape.tscript b/Templates/BaseGame/game/data/Prototyping/shapes/kork_chanShape.tscript index b53ee1f48..4df275dee 100644 --- a/Templates/BaseGame/game/data/Prototyping/shapes/kork_chanShape.tscript +++ b/Templates/BaseGame/game/data/Prototyping/shapes/kork_chanShape.tscript @@ -1,28 +1,8 @@ -//--- OBJECT WRITE BEGIN --- -new TSShapeConstructor(kork_chanShape_fbx) { - baseShapeAsset = "Prototyping:kork_chanShape"; - upAxis = "DEFAULT"; - unit = "-1"; - LODType = "TrailingNumber"; + +singleton TSShapeConstructor(kork_chanShapefbx) +{ + baseShapeAsset = ":kork_chanShape_shape"; singleDetailSize = "0"; - IgnoreNodeScale = "0"; - AdjustCenter = "0"; - AdjustFloor = "0"; - forceUpdateMaterials = "0"; - convertLeftHanded = "0"; - calcTangentSpace = "0"; - genUVCoords = "0"; - transformUVCoords = "0"; - flipUVCoords = "1"; - findInstances = "0"; - limitBoneWeights = "0"; - JoinIdenticalVerts = "1"; - reverseWindingOrder = "1"; - invertNormals = "0"; - removeRedundantMats = "1"; - animTiming = "Seconds"; + neverImportMat = "DefaultMaterial ColorEffect*"; animFPS = "2"; - canSave = "1"; - canSaveDynamicFields = "1"; }; -//--- OBJECT WRITE END --- diff --git a/Templates/BaseGame/game/data/Prototyping/shapes/kork_chanShape_shape.asset.taml b/Templates/BaseGame/game/data/Prototyping/shapes/kork_chanShape_shape.asset.taml new file mode 100644 index 000000000..ec589dd35 --- /dev/null +++ b/Templates/BaseGame/game/data/Prototyping/shapes/kork_chanShape_shape.asset.taml @@ -0,0 +1,5 @@ + diff --git a/Templates/BaseGame/game/data/Prototyping/shapes/kork_chan_image.asset.taml b/Templates/BaseGame/game/data/Prototyping/shapes/kork_chan_image.asset.taml index db20da923..88c5b7a6f 100644 --- a/Templates/BaseGame/game/data/Prototyping/shapes/kork_chan_image.asset.taml +++ b/Templates/BaseGame/game/data/Prototyping/shapes/kork_chan_image.asset.taml @@ -1,4 +1,3 @@ + imageFile="@assetFile=kork_chan.png"/> diff --git a/Templates/BaseGame/game/data/Prototyping/shapes/kork_chan_mat.asset.taml b/Templates/BaseGame/game/data/Prototyping/shapes/kork_chan_mat.asset.taml index c6b7a02b1..39a276210 100644 --- a/Templates/BaseGame/game/data/Prototyping/shapes/kork_chan_mat.asset.taml +++ b/Templates/BaseGame/game/data/Prototyping/shapes/kork_chan_mat.asset.taml @@ -5,12 +5,11 @@ + doubleSided="true" + originalAssetName="kork_chan_mat"> + DiffuseMapAsset="Prototyping:kork_chan_image"/>