change/fix rez position and rotation on llRezObject and llRezAtRoot

avinationmerge
UbitUmarov 2014-11-27 23:32:24 +00:00
parent 6bebb9206c
commit e8d67af3e1
1 changed files with 49 additions and 2 deletions

View File

@ -2492,6 +2492,10 @@ namespace OpenSim.Region.Framework.Scenes
} }
SceneObjectGroup sog; SceneObjectGroup sog;
bool fixrot = false;
Quaternion netRot = Quaternion.Identity;
// position adjust // position adjust
if (totalPrims > 1) // nothing to do on a single prim if (totalPrims > 1) // nothing to do on a single prim
{ {
@ -2506,17 +2510,50 @@ namespace OpenSim.Region.Framework.Scenes
orot = sog.RootPart.GetWorldRotation(); orot = sog.RootPart.GetWorldRotation();
else else
orot = rot.Value; orot = rot.Value;
// possible should be bbox, but geometric center looks better
Vector3 off = sog.GetGeometricCenter(); Vector3 off = sog.GetGeometricCenter();
// Vector3 off = bbox * 0.5f;
off *= orot; off *= orot;
pos -= off; pos -= off;
} }
} }
else
{
//veclist[] are relative to bbox corner with min X,Y and Z
// rez at root, and rot will be referenced to first object in list
if (rot == null)
{
// use original rotations
if (atRoot)
pos -= veclist[0];
else
pos -= bbox / 2;
}
else
{
fixrot = true;
sog = objlist[0];
netRot = Quaternion.Conjugate(sog.RootPart.GetWorldRotation());
netRot = netRot * rot.Value;
Vector3 off;
if (atRoot)
off = veclist[0];
else
off = bbox / 2;
off *= netRot;
pos -= off;
}
}
} }
for (int i = 0; i < objlist.Count; i++) for (int i = 0; i < objlist.Count; i++)
{ {
SceneObjectGroup group = objlist[i]; SceneObjectGroup group = objlist[i];
Vector3 curpos = pos + veclist[i]; Vector3 curpos;
if(fixrot)
curpos = pos + veclist[i] * netRot;
else
curpos = pos + veclist[i];
if (group.IsAttachment == false && group.RootPart.Shape.State != 0) if (group.IsAttachment == false && group.RootPart.Shape.State != 0)
{ {
@ -2525,7 +2562,17 @@ namespace OpenSim.Region.Framework.Scenes
} }
group.FromPartID = sourcePart.UUID; group.FromPartID = sourcePart.UUID;
AddNewSceneObject(group, true, curpos, rot, vel); if( i == 0)
AddNewSceneObject(group, true, curpos, rot, vel);
else
{
Quaternion crot = objlist[i].RootPart.GetWorldRotation();
if (fixrot)
{
crot *= netRot;
}
AddNewSceneObject(group, true, curpos, crot, vel);
}
// We can only call this after adding the scene object, since the scene object references the scene // We can only call this after adding the scene object, since the scene object references the scene
// to find out if scripts should be activated at all. // to find out if scripts should be activated at all.