mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +00:00
Merge pull request #466 from Azaezel/alpha40/bakeOrigintweaks
set prefab and makemesh origins to the biggest model
This commit is contained in:
commit
30f746416d
1 changed files with 32 additions and 15 deletions
|
|
@ -3779,12 +3779,28 @@ void WorldEditor::makeSelectionPrefab( const char *filename, bool dontReplaceOri
|
||||||
// Transform from World to Prefab space.
|
// Transform from World to Prefab space.
|
||||||
MatrixF fabMat(true);
|
MatrixF fabMat(true);
|
||||||
fabMat.setPosition( mSelected->getCentroid() );
|
fabMat.setPosition( mSelected->getCentroid() );
|
||||||
fabMat.inverse();
|
|
||||||
|
|
||||||
MatrixF objMat;
|
MatrixF objMat;
|
||||||
SimObject *obj = NULL;
|
SimObject *obj = NULL;
|
||||||
SceneObject *sObj = 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++ )
|
for ( S32 i = 0; i < found.size(); i++ )
|
||||||
{
|
{
|
||||||
obj = found[i];
|
obj = found[i];
|
||||||
|
|
@ -3978,22 +3994,23 @@ bool WorldEditor::makeSelectionAMesh(const char *filename)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
orientation.identity();
|
SimObject* obj = NULL;
|
||||||
centroid.zero();
|
SceneObject* sObj = NULL;
|
||||||
|
F32 maxLen = 0;
|
||||||
S32 count = 0;
|
for (S32 i = 0; i < found.size(); i++)
|
||||||
|
|
||||||
for (S32 i = 0; i < objectList.size(); i++)
|
|
||||||
{
|
{
|
||||||
SceneObject *pObj = objectList[i];
|
obj = found[i];
|
||||||
if (pObj->isGlobalBounds())
|
sObj = dynamic_cast<SceneObject*>(obj);
|
||||||
continue;
|
if (sObj && !(sObj->isGlobalBounds()))
|
||||||
|
{
|
||||||
centroid += pObj->getPosition();
|
if (maxLen < sObj->getWorldBox().len_max())
|
||||||
count++;
|
{
|
||||||
|
maxLen = sObj->getWorldBox().len_max();
|
||||||
|
orientation = sObj->getTransform();
|
||||||
|
centroid = sObj->getPosition();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
centroid /= count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
orientation.setPosition(centroid);
|
orientation.setPosition(centroid);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue