Merge pull request #466 from Azaezel/alpha40/bakeOrigintweaks

set prefab and makemesh origins to the biggest model
This commit is contained in:
Brian Roberts 2021-02-15 22:27:59 -06:00 committed by GitHub
commit 30f746416d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3779,12 +3779,28 @@ void WorldEditor::makeSelectionPrefab( const char *filename, bool dontReplaceOri
// Transform from World to Prefab space.
MatrixF fabMat(true);
fabMat.setPosition( mSelected->getCentroid() );
fabMat.inverse();
MatrixF objMat;
SimObject *obj = NULL;
SceneObject *sObj = NULL;
F32 maxLen = 0;
for (S32 i = 0; i < found.size(); i++)
{
obj = found[i];
sObj = dynamic_cast<SceneObject*>(obj);
if (sObj && !(sObj->isGlobalBounds()))
{
if (maxLen < sObj->getWorldBox().len_max())
{
maxLen = sObj->getWorldBox().len_max();
fabMat.setPosition(sObj->getPosition());
}
}
}
fabMat.inverse();
for ( S32 i = 0; i < found.size(); i++ )
{
obj = found[i];
@ -3978,22 +3994,23 @@ bool WorldEditor::makeSelectionAMesh(const char *filename)
}
else
{
orientation.identity();
centroid.zero();
S32 count = 0;
for (S32 i = 0; i < objectList.size(); i++)
SimObject* obj = NULL;
SceneObject* sObj = NULL;
F32 maxLen = 0;
for (S32 i = 0; i < found.size(); i++)
{
SceneObject *pObj = objectList[i];
if (pObj->isGlobalBounds())
continue;
centroid += pObj->getPosition();
count++;
obj = found[i];
sObj = dynamic_cast<SceneObject*>(obj);
if (sObj && !(sObj->isGlobalBounds()))
{
if (maxLen < sObj->getWorldBox().len_max())
{
maxLen = sObj->getWorldBox().len_max();
orientation = sObj->getTransform();
centroid = sObj->getPosition();
}
}
}
centroid /= count;
}
orientation.setPosition(centroid);