Skip to content

Commit 24ea89f

Browse files
authored
Fix for incorrecly over writing textures, get metalness, roughness and clear coat values. (#8385)
1 parent b4118a0 commit 24ea89f

File tree

6 files changed

+118
-149
lines changed

6 files changed

+118
-149
lines changed

addons/ofxAssimp/src/Source/ofxAssimpSrcBone.cpp

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -24,99 +24,6 @@ void SrcBone::setAiBone(aiBone* aAiBone, aiNode* aAiNode) {
2424
mAiMatrix = mAiNode->mTransformation;
2525
}
2626

27-
////--------------------------------------------------------------
28-
//void SrcBone::update() {
29-
// if( mAiNode == nullptr ) {
30-
// ofLogWarning("SrcBone::update mAiNode nullptr!!!");
31-
// return;
32-
// }
33-
//
34-
//// if( mAiBone == nullptr ) {
35-
//// ofLogWarning("SrcBone::update mAiBone nullptr!!!");
36-
//// return;
37-
//// }
38-
//
39-
//// if( bRoot ) {
40-
//// std::cout << "Bone: " << getName() << " has parent: " << (getParent() != nullptr) << " | " << ofGetFrameNum() << std::endl;
41-
//// }
42-
// // update //
43-
//// mAiMatrix = mAiBone->mOffsetMatrix;
44-
// mAiMatrix = mAiNode->mTransformation;
45-
//
46-
//// mAiMatrixGlobal = mAiNode->mTransformation;
47-
//// mBoneLocalTransform = glmMat4ToAiMatrix4x4(mAiMatrix);
48-
// // and now append all node transformations down the parent chain until we're back at mesh coordinates again
49-
//// if( bRoot ) {
50-
//// const aiNode* tempNode = mAiNode;
51-
//// aiNode* node = scene->mRootNode->FindNode(mAiBone->mName);
52-
//// const aiNode* tempNode = mAiNode->mParent;
53-
//// while(tempNode) {
54-
////// aiMatrix4x4 m = tempNode->mTransformation;
55-
////// m.Transpose();
56-
//// // check your matrix multiplication order here!!!
57-
////// mAiMatrix = m * mAiMatrix;//boneMatrices[a];
58-
////// ofLogNotice("SrcBone name: ") << getName() << " parent: " << tempNode->mName.data;
59-
////// mAiMatrixGlobal = tempNode->mTransformation * mAiMatrixGlobal;
60-
//// mAiMatrixGlobal = tempNode->mTransformation * mAiMatrixGlobal;
61-
//// // boneMatrices[a] = boneMatrices[a] * tempNode->mTransformation;
62-
////// mAiMatrix = tempNode->mTransformation * mAiMatrix;
63-
////// mAiMatrix = mAiMatrix * tempNode->mTransformation;
64-
//// tempNode = tempNode->mParent;
65-
//// }
66-
//// mAiMatrix = aGlobalInv * mAiMatrix;
67-
//// } else {
68-
//// mAiMatrix = mAiNode->mTransformation * mAiMatrix;
69-
//// mAiMatrix = mAiMatrix * mAiNode->mTransformation;
70-
//// }
71-
// if( bRoot) {
72-
//// mAiMatrix = mAiMatrixGlobal;
73-
// }
74-
//
75-
//// mAiMatrix *= (mOffsetMatrix);
76-
//
77-
//// aiVector3t<float> tAiScale;
78-
//// aiQuaterniont<float> tAiRotation;
79-
//// aiVector3t<float> tAiPosition;
80-
////
81-
//// // this is the local matrix
82-
//// mAiMatrix.Decompose( tAiScale, tAiRotation, tAiPosition );
83-
////
84-
//// glm::vec3 tpos = glm::vec3( tAiPosition.x, tAiPosition.y, tAiPosition.z );
85-
//// glm::quat tquat = glm::quat(tAiRotation.w, tAiRotation.x, tAiRotation.y, tAiRotation.z);
86-
////// glm::quat tquat = glm::quat(tAiRotation.x, tAiRotation.y, tAiRotation.z, tAiRotation.w);
87-
//// glm::vec3 tscale = glm::vec3( tAiScale.x, tAiScale.y, tAiScale.z );
88-
////
89-
////// if( bRoot ) {
90-
////// std::cout << "Bone: " << getName() << " tscale: " << tscale << " | " << ofGetFrameNum() << std::endl;
91-
////// }
92-
////
93-
////// if(bRoot) {
94-
////// setGlobalPosition( tpos );
95-
////// setGlobalOrientation( tquat );
96-
////// setScale( tscale );
97-
////// } else {
98-
//// setPositionOrientationScale( tpos, tquat, tscale );
99-
//// setPosition(tpos);
100-
//// setOrientation(tquat);
101-
//// setScale(tscale);
102-
//
103-
//// setGlobalPosition(tpos);
104-
//// setGlobalOrientation(tquat);
105-
//// setScale(tscale);
106-
//
107-
//// mPos = getGlobalPosition();
108-
//// }
109-
//
110-
//// for(auto it = childBones.begin(); it != childBones.end(); ++it ) {
111-
//// it->second->update();
112-
//// }
113-
//// for( auto& kid : childBones ) {
114-
//// kid->update();
115-
//// }
116-
//
117-
//// getGlobalTransformMatrix();
118-
//}
119-
12027
//--------------------------------------------------------------
12128
std::shared_ptr<ofxAssimp::SrcBone> SrcBone::getBone( aiNode* aAiNode ) {
12229
std::shared_ptr<ofxAssimp::SrcBone> tbone;
@@ -130,13 +37,6 @@ std::shared_ptr<ofxAssimp::SrcBone> SrcBone::getBone( aiNode* aAiNode ) {
13037
//--------------------------------------------------------------
13138
void SrcBone::findBoneRecursive( aiNode* aAiNode, std::shared_ptr<SrcBone>& returnBone ) {
13239
if( !returnBone ) {
133-
// for(auto it = childBones.begin(); it != childBones.end(); ++it ) {
134-
// if( it->second->getAiNode() == aAiNode ) {
135-
// returnBone = (it->second);
136-
// break;
137-
// }
138-
// it->second->findBoneRecursive( aAiNode, returnBone );
139-
// }
14040
for(auto& kid : childBones ) {
14141
if( kid->getAiNode() == aAiNode ) {
14242
returnBone = kid;//(it->second);
@@ -150,9 +50,6 @@ void SrcBone::findBoneRecursive( aiNode* aAiNode, std::shared_ptr<SrcBone>& retu
15050
//--------------------------------------------------------------
15151
unsigned int SrcBone::getNumBones() {
15252
unsigned int ttotal = childBones.size();
153-
// for(auto it = childBones.begin(); it != childBones.end(); ++it ) {
154-
// ttotal += it->second->getNumBones();
155-
// }
15653
for(auto& kid : childBones ) {
15754
ttotal += kid->getNumBones();
15855
}

addons/ofxAssimp/src/Source/ofxAssimpSrcScene.cpp

Lines changed: 79 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,13 @@ void SrcScene::processMeshes(aiNode* anode, std::shared_ptr<SrcNode> aSrcNode) {
324324
for(unsigned int i = 0; i < anode->mNumMeshes; i++) {
325325
unsigned int meshIndex = anode->mMeshes[i];
326326
if( meshIndex >= mSrcMeshes.size() ) {
327-
ofLogError("SrcScene::processNodesRecursive") << " mesh index out of range: " << meshIndex << " / " << mSrcMeshes.size() << " num in scene: " << scene->mNumMeshes;
327+
ofLogError("ofxAssimp::Scene::processNodesRecursive") << " mesh index out of range: " << meshIndex << " / " << mSrcMeshes.size() << " num in scene: " << scene->mNumMeshes;
328328
continue;
329329
}
330330
if( mSrcMeshes[meshIndex] ) {
331-
ofLogWarning("SrcScene::processNodesRecursive") << " hmm we already have a SrcMesh at index: " << meshIndex << " " << anode->mName.data;
331+
ofLogWarning("ofxAssimp::SrcScene::processNodesRecursive") << " hmm we already have a SrcMesh at index: " << meshIndex << " " << anode->mName.data;
332332
} else {
333-
ofLogNotice("SrcScene::processNodesRecursive") << " going to process mesh: " << scene->mMeshes[meshIndex]->mName.data << " from node: " << anode->mName.data << " num scene meshes: " << scene->mNumMeshes;
333+
ofLogVerbose("ofxAssimp::SrcScene::processNodesRecursive") << " going to process mesh: " << scene->mMeshes[meshIndex]->mName.data << " from node: " << anode->mName.data << " num scene meshes: " << scene->mNumMeshes;
334334
// ok, open slot for a src mesh //
335335
auto srcMesh = std::make_shared<ofxAssimp::SrcMesh>();
336336
srcMesh->setAiMesh(scene->mMeshes[meshIndex], anode );
@@ -497,7 +497,7 @@ void SrcScene::processKeyframes(std::shared_ptr<ofxAssimp::SrcNode> aSrcNode, ai
497497
keyCollection.clear();
498498
keyCollection.setup( aNodeAnim, anim.getDurationInTicks() );
499499

500-
// ofLogNotice("SrcScene processKeyframes: ") << aSrcNode->getName() << " node anim: " << aNodeAnim->mNodeName.data << " node anim num pos keyframes: " << aNodeAnim->mNumPositionKeys << " scale: " << aNodeAnim->mNumScalingKeys << " rot: " << aNodeAnim->mNumRotationKeys;
500+
// ofLogNotice("ofxAssimp::SrcScene processKeyframes: ") << aSrcNode->getName() << " node anim: " << aNodeAnim->mNodeName.data << " node anim num pos keyframes: " << aNodeAnim->mNumPositionKeys << " scale: " << aNodeAnim->mNumScalingKeys << " rot: " << aNodeAnim->mNumRotationKeys;
501501

502502
double startTime = 0.0; // seconds
503503
double endTime = anim.getDurationInTicks();// seconds;
@@ -570,6 +570,7 @@ void SrcScene::loadGLResources(std::shared_ptr<ofxAssimp::SrcMesh> aSrcMesh, aiM
570570

571571
if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_EMISSIVE, &tcolor)){
572572
auto col = ofxAssimp::Utils::aiColorToOfColor(tcolor);
573+
ofLogVerbose("ofxAssimp::SrcScene") << "setting emissive color: " << col;
573574
aSrcMesh->material->setEmissiveColor(col);
574575
}
575576

@@ -586,6 +587,35 @@ void SrcScene::loadGLResources(std::shared_ptr<ofxAssimp::SrcMesh> aSrcMesh, aiM
586587
aSrcMesh->blendMode=OF_BLENDMODE_ADD;
587588
}
588589
}
590+
591+
float metallic = 0.f;
592+
if( AI_SUCCESS == aiGetMaterialFloat(mtl, AI_MATKEY_METALLIC_FACTOR, &metallic) ) {
593+
ofLogVerbose("ofxAssimp::SrcScene") << " setting metallic value: " << metallic;
594+
aSrcMesh->material->setMetallic(metallic);
595+
}
596+
597+
float roughness = 0.f;
598+
if( AI_SUCCESS == aiGetMaterialFloat(mtl, AI_MATKEY_ROUGHNESS_FACTOR, &roughness) ) {
599+
ofLogVerbose("ofxAssimp::SrcScene") << " setting roughness value: " << roughness;
600+
aSrcMesh->material->setRoughness(roughness);
601+
}
602+
603+
float clearcoatFactor = 0.f;
604+
if( AI_SUCCESS == aiGetMaterialFloat(mtl, AI_MATKEY_CLEARCOAT_FACTOR, &clearcoatFactor) ) {
605+
ofLogVerbose("ofxAssimp::SrcScene") << " setting clearcoat value: " << clearcoatFactor;
606+
aSrcMesh->material->setClearCoatStrength(clearcoatFactor);
607+
if( clearcoatFactor > 0.0f ) {
608+
aSrcMesh->material->setClearCoatEnabled(true);
609+
} else {
610+
aSrcMesh->material->setClearCoatEnabled(false);
611+
}
612+
}
613+
614+
float clearcoatRoughFactor = 0.f;
615+
if( AI_SUCCESS == aiGetMaterialFloat(mtl, AI_MATKEY_CLEARCOAT_ROUGHNESS_FACTOR, &clearcoatRoughFactor) ) {
616+
ofLogVerbose("ofxAssimp::SrcScene") << " setting clearcoat roughness value: " << clearcoatRoughFactor;
617+
aSrcMesh->material->setClearCoatRoughness(clearcoatRoughFactor);
618+
}
589619
}
590620

591621
// Culling
@@ -615,11 +645,19 @@ void SrcScene::loadGLResources(std::shared_ptr<ofxAssimp::SrcMesh> aSrcMesh, aiM
615645
for(int d = 0; d <= AI_TEXTURE_TYPE_MAX; d++){
616646
if(AI_SUCCESS == mtl->GetTexture((aiTextureType)d, texIndex, &texPath, NULL, NULL, NULL, NULL, &texMapMode[0])){
617647

648+
// getTextureTypeAsString(const ofMaterialTextureType & aMaterialTextureType)
649+
auto matType = ofxAssimp::Texture::ofTextureTypeForAiType( (aiTextureType)d );
650+
auto texTypeString = ofMaterial::getTextureTypeAsString(matType);
618651
//this is a solution to support older versions of assimp. see the weak defination above
619652
if( aiTextureTypeToString ){
620653
ofLogVerbose("ofxAssimp::SrcScene") << "loadGLResource(): loading " << aiTextureTypeToString((aiTextureType)d) << " image from \"" << texPath.data << "\"";
621654
}
622655

656+
if( matType == OF_MATERIAL_TEXTURE_NONE ) {
657+
ofLogWarning("ofxAssimp::SrcScene") << "unable to detect texture type: " << texPath.data;
658+
continue;
659+
}
660+
623661
bool bWrap = (texMapMode[0]==aiTextureMapMode_Wrap);
624662

625663
std::string texPathStr = texPath.C_Str();
@@ -657,26 +695,22 @@ void SrcScene::loadGLResources(std::shared_ptr<ofxAssimp::SrcMesh> aSrcMesh, aiM
657695
}
658696
#endif
659697

698+
699+
660700
bool bTextureAlreadyExists = false;
661-
if(mAssimpTextures.count(realPath)){
701+
// if(mAssimpTextures.count(realPath)){
702+
if(mTextureCacheMap.count(realPath)) {
662703
bTextureAlreadyExists = true;
663704
}
664705

665706
if(bTextureAlreadyExists) {
666-
// ofxAssimpTexture assimpTexture;
667-
// assimpTexture.setup(*textures[realPath].get(), realPath, bWrap);
668-
// assimpTexture.setTextureType((aiTextureType)d);
669-
auto assimpTexture = mAssimpTextures[realPath];
670-
aSrcMesh->addTexture(assimpTexture);
671-
672707
ofLogVerbose("ofxAssimp::SrcScene") << "loadGLResource(): texture already loaded: \""
673-
<< mFile.getFileName() + "\" from \"" << realPath.string() << "\"" << " adding texture as " << assimpTexture->getAiTextureTypeAsString() ;
708+
<< mFile.getFileName() + "\" from \"" << realPath.string() << "\"" << " adding texture as " << texTypeString;
674709
} else {
675-
// shared_ptr<ofTexture> texture = std::make_shared<ofTexture>();
676-
auto assimpTexture = std::make_shared<ofxAssimp::Texture>();
710+
shared_ptr<ofTexture> texture = std::make_shared<ofTexture>();
711+
// auto assimpTexture = std::make_shared<ofxAssimp::Texture>();
677712

678713
if( bHasEmbeddedTexture ){
679-
680714
#ifndef TARGET_LINUX_ARM
681715
auto embeddedTexture = scene->GetEmbeddedTexture(ogPath.c_str());
682716

@@ -691,34 +725,49 @@ void SrcScene::loadGLResources(std::shared_ptr<ofxAssimp::SrcMesh> aSrcMesh, aiM
691725

692726
ofLogVerbose("ofxAssimp::SrcScene") << "loadGLResource() texture size is " << tmp.getWidth() << "x" << tmp.getHeight();
693727

694-
assimpTexture->getTextureRef().loadData(tmp.getPixels());
728+
// assimpTexture->getTextureRef().loadData(tmp.getPixels());
729+
texture->loadData(tmp.getPixels());
695730
}else{
696731
//uncompressed texture - might need swizzling from argb to rgba?
697732
auto glFormat = getGLFormatFromAiFormat(embeddedTexture->achFormatHint);
698-
assimpTexture->getTextureRef().loadData((const uint8_t *)embeddedTexture->pcData, embeddedTexture->mWidth, embeddedTexture->mHeight, glFormat);
733+
// assimpTexture->getTextureRef().loadData((const uint8_t *)embeddedTexture->pcData, embeddedTexture->mWidth, embeddedTexture->mHeight, glFormat);
734+
texture->loadData((const uint8_t *)embeddedTexture->pcData, embeddedTexture->mWidth, embeddedTexture->mHeight, glFormat);
699735
}
700736
#endif
701737
}else{
702-
// ofLoadImage(*texture.get(), realPath);
703-
ofLoadImage(assimpTexture->getTextureRef(), realPath );
738+
// ofLoadImage(assimpTexture->getTextureRef(), realPath );
739+
ofLoadImage(*texture, realPath);
704740
}
705741

706-
if(assimpTexture && assimpTexture->getTextureRef().isAllocated()){
707-
// ofxAssimpTexture tmpTex;
708-
// tmpTex.setup(*texture.get(), realPath, bWrap);
709-
assimpTexture->setup( realPath, bWrap );
710-
assimpTexture->setAiTextureType((aiTextureType)d);
711-
mAssimpTextures[realPath] = assimpTexture;
712-
ofLogNotice( "ofxAssimp::SrcScene") << " assimpTexture type: " << assimpTexture->getAiTextureTypeAsString() << " path: " << assimpTexture->getTexturePath();
713-
// tmpTex.setTextureType((aiTextureType)d);
714-
aSrcMesh->addTexture( assimpTexture );
715-
716-
ofLogVerbose("ofxAssimp::SrcScene") << "loadGLResource(): texture " << assimpTexture->getAiTextureTypeAsString() << " loaded, dimensions: " << assimpTexture->getTextureRef().getWidth() << "x" << assimpTexture->getTextureRef().getHeight();
742+
if(texture && texture->isAllocated()){
743+
mTextureCacheMap[realPath] = texture;
744+
ofLogVerbose("ofxAssimp::SrcScene") << "loadGLResource(): texture " << texTypeString << " loaded, dimensions: " << texture->getWidth() << "x" << texture->getHeight();
717745
}else{
718746
ofLogError("ofxAssimp::SrcScene") << "loadGLResource(): couldn't load texture: \""
719747
<< mFile.getFileName() + "\" from \"" << realPath.string() << "\"";
720748
}
721749
}
750+
751+
752+
if(mTextureCacheMap.count(realPath) > 0) {
753+
// create a key using the type of texture and the path
754+
std::string assimpTexKey = texTypeString+"_"+realPath.string();
755+
std::shared_ptr<ofxAssimp::Texture> assimpTexture;
756+
if( mAssimpTextures.count(assimpTexKey) ) {
757+
assimpTexture = mAssimpTextures[assimpTexKey];
758+
} else {
759+
assimpTexture = std::make_shared<ofxAssimp::Texture>();
760+
assimpTexture->setup( realPath, bWrap );
761+
assimpTexture->setAiTextureType((aiTextureType)d);
762+
assimpTexture->setTexture(mTextureCacheMap[realPath]);
763+
mAssimpTextures[assimpTexKey] = assimpTexture;
764+
}
765+
766+
if( assimpTexture ) {
767+
ofLogVerbose("ofxAssimp::SrcScene") << "adding texture type: " << texTypeString << " to mesh: " << aSrcMesh->getName();
768+
aSrcMesh->addTexture( assimpTexture );
769+
}
770+
}
722771
}
723772
}
724773
}

addons/ofxAssimp/src/Source/ofxAssimpSrcScene.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct ImportSettings {
4141
bool fixInfacingNormals = false; // aiProcess_FixInfacingNormals
4242
// bool importLights = false;
4343
bool convertToLeftHanded = true; // aiProcess_ConvertToLeftHanded
44-
44+
bool transformRootNode = true; // orient based on src scene root node, helps with correct orientation
4545
std::vector<std::string> excludeNodesContainingStrings;
4646
unsigned int aiFlags = 0; // ai process flags, ie. aiProcess_FixInfacingNormals
4747
};
@@ -98,7 +98,10 @@ class SrcScene {
9898
ofFile mFile;
9999

100100
std::vector<ofLight> mLights;
101-
std::map<of::filesystem::path, std::shared_ptr<ofxAssimp::Texture> > mAssimpTextures;
101+
// std::map<of::filesystem::path, std::shared_ptr<ofxAssimp::Texture> > mAssimpTextures;
102+
std::map<std::string, std::shared_ptr<ofxAssimp::Texture> > mAssimpTextures;
103+
std::map<of::filesystem::path, std::shared_ptr<ofTexture> > mTextureCacheMap;
104+
102105
std::vector< ofxAssimp::Animation > mAnimations;
103106

104107
std::vector< std::shared_ptr<ofxAssimp::SrcMesh> > mSrcMeshes;

addons/ofxAssimp/src/ofxAssimpScene.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ bool Scene::processScene() {
8888
}
8989
}
9090

91+
if( mSrcScene->getImportSettings().transformRootNode && mSrcScene->getAiScene() && mSrcScene->getAiScene()->mRootNode ) {
92+
ofxAssimp::Utils::setOfNodeFromAiMatrix( mSrcScene->getAiScene()->mRootNode->mTransformation, this );
93+
}
94+
9195
std::shared_ptr<ofxAssimp::Node> tempParent;
9296
auto sceneSrcNodes = mSrcScene->getRootNodes();
9397
for( auto sceneSrcNode : sceneSrcNodes ) {
@@ -98,7 +102,7 @@ bool Scene::processScene() {
98102
auto numberOfBones = getNumBones();
99103
// now associate the meshes with the bones
100104
for( auto& modelMesh : mMeshes ) {
101-
ofLogNotice("model mesh") << modelMesh->getName() << " indices: " << modelMesh->getNumIndices() << " vbo: " << modelMesh->vbo->getNumVertices();
105+
ofLogVerbose("ofxAssimp::Scene") << "mesh: " << modelMesh->getName() << " indices: " << modelMesh->getNumIndices() << " vbo: " << modelMesh->vbo->getNumVertices();
102106

103107
auto* mesh = modelMesh->getAiMesh();
104108

@@ -113,13 +117,13 @@ bool Scene::processScene() {
113117
for(unsigned int a = 0; a < mesh->mNumBones; ++a) {
114118
aiBone* bone = mesh->mBones[a];
115119
if( !bone ) {
116-
ofLogError("ofxAssimp::Scene : NULL bone! - ") << a;
120+
ofLogError("ofxAssimp::Scene") << " NULL bone!" << a;
117121
continue;
118122
}
119123
// aiNode* node = scene->mRootNode->FindNode(bone->mName);
120124
aiNode* boneNode = bone->mNode;
121125
if( !boneNode ) {
122-
ofLogError("ofxAssimp::Scene : unable to find scene node for bone!") << bone->mName.data;
126+
ofLogError("ofxAssimp::Scene") << "unable to find scene node for bone!" << bone->mName.data;
123127
continue;
124128
}
125129

@@ -132,7 +136,7 @@ bool Scene::processScene() {
132136
}
133137
}
134138

135-
ofLogNotice("-- Scene::processScene : scale: ") << getScale() << " global Scale: " << getGlobalScale();
139+
ofLogVerbose("ofxAssimp::Scene") << "scene scale: " << getScale() << " global Scale: " << getGlobalScale();
136140

137141
update();
138142
calculateDimensions();
@@ -314,6 +318,7 @@ void Scene::calculateDimensions(){
314318
for( auto& meshHelper : mMeshes ) {
315319
meshHelper->recalculateBounds(true);
316320
mSceneBoundsLocal.include(globalInvMat, meshHelper->getGlobalBounds().getBoundingVerts());
321+
// mSceneBoundsLocal.include(meshHelper->getModelBounds().getBoundingVerts());
317322
}
318323
}
319324

@@ -976,9 +981,9 @@ ofxAssimp::Bounds Scene::getSceneBounds() {
976981
if( mBSceneBoundsDirty ) {
977982
mBSceneBoundsDirty=false;
978983
mSceneBoundsGlobal.clear();
979-
// mSceneBoundsGlobal.include( getGlobalTransformMatrix(), mSceneBoundsLocal.getBoundingVerts() );
980-
// mSceneBoundsGlobal.include( getGlobalTransformMatrix(), {mSceneBoundsLocal.min, mSceneBoundsLocal.max} );
981984
for( auto mesh : mMeshes ) {
985+
// ofLogNotice("Scene::getSceneBounds") << " mesh: " << mesh->getName() << " - has parent: " << ( mesh->getParent() != nullptr ? "yes" : "no" );
986+
mesh->recalculateBounds(true); // force it.
982987
mSceneBoundsGlobal.include( mesh->getGlobalBounds().getBoundingVerts() );
983988
}
984989
}

0 commit comments

Comments
 (0)