* This completes ObjectDuplicateOnRay.
* In English, that means that Copy Selection works now, including Copy Centers and Copy Rotates.0.6.0-stable
parent
c62f081380
commit
8a93358405
|
@ -1399,7 +1399,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Duplicate the given object.
|
/// Duplicate the given object, Fire and Forget, No rotation, no return wrapper
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="originalPrim"></param>
|
/// <param name="originalPrim"></param>
|
||||||
/// <param name="offset"></param>
|
/// <param name="offset"></param>
|
||||||
|
@ -1408,6 +1408,18 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
//m_log.DebugFormat("[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", originalPrim, offset, AgentID);
|
//m_log.DebugFormat("[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", originalPrim, offset, AgentID);
|
||||||
|
|
||||||
|
SceneObjectGroup dupe = DuplicateObject(originalPrim, offset, flags, AgentID, GroupID, Quaternion.Zero);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Duplicate the given object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="originalPrim"></param>
|
||||||
|
/// <param name="offset"></param>
|
||||||
|
/// <param name="flags"></param>
|
||||||
|
protected internal SceneObjectGroup DuplicateObject(uint originalPrim, LLVector3 offset, uint flags, LLUUID AgentID, LLUUID GroupID, Quaternion rot)
|
||||||
|
{
|
||||||
|
//m_log.DebugFormat("[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", originalPrim, offset, AgentID);
|
||||||
|
|
||||||
List<EntityBase> EntityList = GetEntities();
|
List<EntityBase> EntityList = GetEntities();
|
||||||
|
|
||||||
SceneObjectGroup originPrim = null;
|
SceneObjectGroup originPrim = null;
|
||||||
|
@ -1445,16 +1457,22 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
m_numPrim += copy.Children.Count;
|
m_numPrim += copy.Children.Count;
|
||||||
|
|
||||||
|
if (rot != Quaternion.Zero)
|
||||||
|
{
|
||||||
|
copy.UpdateGroupRotation(new LLQuaternion(rot.x, rot.y, rot.z, rot.w));
|
||||||
|
}
|
||||||
|
|
||||||
copy.StartScripts();
|
copy.StartScripts();
|
||||||
copy.ScheduleGroupForFullUpdate();
|
copy.ScheduleGroupForFullUpdate();
|
||||||
|
return copy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_log.WarnFormat("[SCENE]: Attempted to duplicate nonexistant prim id {0}", GroupID);
|
m_log.WarnFormat("[SCENE]: Attempted to duplicate nonexistant prim id {0}", GroupID);
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Calculates the distance between two Vector3s
|
/// Calculates the distance between two Vector3s
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1759,7 +1759,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
LLVector3 pos;
|
LLVector3 pos;
|
||||||
const bool frontFacesOnly = true;
|
const bool frontFacesOnly = true;
|
||||||
|
//m_log.Info("HITTARGET: " + RayTargetObj.ToString() + ", COPYTARGET: " + localID.ToString());
|
||||||
SceneObjectPart target = GetSceneObjectPart(localID);
|
SceneObjectPart target = GetSceneObjectPart(localID);
|
||||||
SceneObjectPart target2 = GetSceneObjectPart(RayTargetObj);
|
SceneObjectPart target2 = GetSceneObjectPart(RayTargetObj);
|
||||||
|
|
||||||
|
@ -1781,10 +1781,10 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
Ray NewRay = new Ray(AXOrigin, AXdirection);
|
Ray NewRay = new Ray(AXOrigin, AXdirection);
|
||||||
|
|
||||||
// Ray Trace against target here
|
// Ray Trace against target here
|
||||||
EntityIntersection ei = target.TestIntersectionOBB(NewRay, new Quaternion(1, 0, 0, 0), frontFacesOnly, false);
|
EntityIntersection ei = target2.TestIntersectionOBB(NewRay, new Quaternion(1, 0, 0, 0), frontFacesOnly, CopyCenters);
|
||||||
|
|
||||||
// Un-comment out the following line to Get Raytrace results printed to the console.
|
// Un-comment out the following line to Get Raytrace results printed to the console.
|
||||||
// m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
|
//m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
|
||||||
float ScaleOffset = 0.5f;
|
float ScaleOffset = 0.5f;
|
||||||
|
|
||||||
// If we hit something
|
// If we hit something
|
||||||
|
@ -1801,32 +1801,22 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
LLVector3 offset = (normal * (ScaleOffset / 2f));
|
LLVector3 offset = (normal * (ScaleOffset / 2f));
|
||||||
pos = (intersectionpoint + offset);
|
pos = (intersectionpoint + offset);
|
||||||
|
|
||||||
if (CopyCenters)
|
|
||||||
{
|
|
||||||
// now we cast a ray from inside the prim(absolute position) to one of it's faces along the face normal.
|
|
||||||
LLVector3 direction2 = LLVector3.Norm(pos - target2.AbsolutePosition);
|
|
||||||
Vector3 AXOrigin2 = new Vector3(target2.AbsolutePosition.X, target2.AbsolutePosition.Y, target2.AbsolutePosition.Z);
|
|
||||||
Vector3 AXdirection2 = new Vector3(direction2.X, direction2.Y, direction2.Z); //ei.AAfaceNormal;
|
|
||||||
Ray NewRay2 = new Ray(AXOrigin2, AXdirection2);
|
|
||||||
EntityIntersection ei2 = target.TestIntersectionOBB(NewRay2, new Quaternion(1, 0, 0, 0), false, CopyCenters);
|
|
||||||
if (ei2.HitTF)
|
|
||||||
{
|
|
||||||
//m_log.Info("[RAYTRACERESULTS]: Hit:" + ei2.HitTF.ToString() + " Point: " + ei2.ipoint.ToString() + " Normal: " + ei2.normal.ToString());
|
|
||||||
pos = new LLVector3(ei2.ipoint.x,ei2.ipoint.y,ei2.ipoint.z);
|
|
||||||
normal.X = ei2.normal.x;
|
|
||||||
normal.Y = ei2.normal.y;
|
|
||||||
normal.Z = ei2.normal.z;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the position to the intersection point
|
|
||||||
offset = (normal * (ScaleOffset / 2f));
|
|
||||||
pos = (intersectionpoint + offset);
|
|
||||||
|
|
||||||
// stick in offset format from the original prim
|
// stick in offset format from the original prim
|
||||||
pos = pos - target2.ParentGroup.AbsolutePosition;
|
pos = pos - target.ParentGroup.AbsolutePosition;
|
||||||
|
if (CopyRotates)
|
||||||
|
{
|
||||||
|
LLQuaternion worldRot = target2.GetWorldRotation();
|
||||||
|
|
||||||
|
SceneObjectGroup obj = m_innerScene.DuplicateObject(localID, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID, new Quaternion(worldRot.W,worldRot.X,worldRot.Y,worldRot.Z));
|
||||||
|
//obj.Rotation = new Quaternion(worldRot.W, worldRot.X, worldRot.Y, worldRot.Z);
|
||||||
|
//obj.UpdateGroupRotation(worldRot);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
m_innerScene.DuplicateObject(localID, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID);
|
m_innerScene.DuplicateObject(localID, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1352,14 +1352,14 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
AmBb = FaceB[i] - FaceC[i];
|
AmBb = FaceB[i] - FaceC[i];
|
||||||
d = normals[i].Dot(FaceB[i]);
|
d = normals[i].Dot(FaceB[i]);
|
||||||
|
|
||||||
if (faceCenters)
|
//if (faceCenters)
|
||||||
{
|
//{
|
||||||
c = normals[i].Dot(normals[i]);
|
// c = normals[i].Dot(normals[i]);
|
||||||
}
|
//}
|
||||||
else
|
//else
|
||||||
{
|
//{
|
||||||
c = iray.Direction.Dot(normals[i]);
|
c = iray.Direction.Dot(normals[i]);
|
||||||
}
|
//}
|
||||||
if (c == 0)
|
if (c == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1375,21 +1375,21 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
if (iray.Direction.Dot(normals[i]) < 0 || !frontFacesOnly)
|
if (iray.Direction.Dot(normals[i]) < 0 || !frontFacesOnly)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (faceCenters)
|
//if (faceCenters)
|
||||||
{ //(FaceA[i] + FaceB[i] + FaceC[1] + FaceD[i]) / 4f;
|
//{ //(FaceA[i] + FaceB[i] + FaceC[1] + FaceD[i]) / 4f;
|
||||||
q = iray.Origin + a * normals[i];
|
// q = iray.Origin + a * normals[i];
|
||||||
}
|
//}
|
||||||
else
|
//else
|
||||||
{
|
//{
|
||||||
q = iray.Origin + a * iray.Direction;
|
q = iray.Origin + a * iray.Direction;
|
||||||
}
|
//}
|
||||||
|
|
||||||
float distance2 = (float)GetDistanceTo(q, AXpos);
|
float distance2 = (float)GetDistanceTo(q, AXpos);
|
||||||
// Is this the closest hit to the object's origin?
|
// Is this the closest hit to the object's origin?
|
||||||
if (faceCenters)
|
//if (faceCenters)
|
||||||
{
|
//{
|
||||||
distance2 = (float)GetDistanceTo(q, iray.Origin);
|
// distance2 = (float)GetDistanceTo(q, iray.Origin);
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
if (distance2 < returnresult.distance)
|
if (distance2 < returnresult.distance)
|
||||||
|
@ -1397,10 +1397,28 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
returnresult.distance = distance2;
|
returnresult.distance = distance2;
|
||||||
returnresult.HitTF = true;
|
returnresult.HitTF = true;
|
||||||
returnresult.ipoint = q;
|
returnresult.ipoint = q;
|
||||||
m_log.Info("[FACE]:" + i.ToString());
|
//m_log.Info("[FACE]:" + i.ToString());
|
||||||
m_log.Info("[POINT]: " + q.ToString());
|
//m_log.Info("[POINT]: " + q.ToString());
|
||||||
m_log.Info("[DIST]: " + distance2.ToString());
|
//m_log.Info("[DIST]: " + distance2.ToString());
|
||||||
|
if (faceCenters)
|
||||||
|
{
|
||||||
|
returnresult.normal = (AXrot * AAfacenormals[i]);
|
||||||
|
|
||||||
|
Vector3 scaleComponent = AAfacenormals[i];
|
||||||
|
float ScaleOffset = 0.5f;
|
||||||
|
if (scaleComponent.x != 0) ScaleOffset = AXscale.x;
|
||||||
|
if (scaleComponent.y != 0) ScaleOffset = AXscale.y;
|
||||||
|
if (scaleComponent.z != 0) ScaleOffset = AXscale.z;
|
||||||
|
ScaleOffset = Math.Abs(ScaleOffset);
|
||||||
|
Vector3 offset = (returnresult.normal * ScaleOffset);
|
||||||
|
returnresult.ipoint = (AXpos + offset );
|
||||||
|
|
||||||
|
///pos = (intersectionpoint + offset);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
returnresult.normal = normals[i];
|
returnresult.normal = normals[i];
|
||||||
|
}
|
||||||
returnresult.AAfaceNormal = AAfacenormals[i];
|
returnresult.AAfaceNormal = AAfacenormals[i];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue