* Added ability to create new prim on existing prim (rezzing prim from inventory on other prim coming soon). No more new prim buried in the ground by accident.

* The prim are at the absolute position of the prim you rezzed it on top of + (0,0,0.5) for now.
afrisby
Teravus Ovares 2007-12-28 05:25:21 +00:00
parent 9b36c6c3ad
commit 67bbed8202
6 changed files with 128 additions and 61 deletions

View File

@ -332,7 +332,7 @@ namespace OpenSim.Framework
public delegate void UUIDNameRequest(LLUUID id, IClientAPI remote_client);
public delegate void AddNewPrim(LLUUID ownerID, LLVector3 pos, LLQuaternion rot, PrimitiveBaseShape shape);
public delegate void AddNewPrim(LLUUID ownerID, LLVector3 RayEnd, LLQuaternion rot, PrimitiveBaseShape shape, byte bypassRaycast, LLVector3 RayStart, LLUUID RayTargetID, byte RayEndIsIntersection);
public delegate void RequestGodlikePowers(LLUUID AgentID, LLUUID SessionID, LLUUID token, IClientAPI remote_client);

View File

@ -46,6 +46,8 @@ namespace OpenSim.Framework
private static object XferLock = new object();
private static Dictionary<LLUUID, string> capsURLS = new Dictionary<LLUUID, string>();
#region Vector Equasions
public static double GetDistanceTo(LLVector3 a, LLVector3 b)
{
float dx = a.X - b.X;
@ -53,6 +55,16 @@ namespace OpenSim.Framework
float dz = a.Z - b.Z;
return Math.Sqrt(dx*dx + dy*dy + dz*dz);
}
public static double GetMagnitude(LLVector3 a) {
return Math.Sqrt((a.X * a.X) + (a.Y * a.Y) + (a.Z * a.Z));
}
public static LLVector3 GetNormal(LLVector3 a)
{
float Mag = (float)GetMagnitude(a);
return new LLVector3(a.X / Mag, a.Y / Mag, a.Z / Mag);
}
# endregion
public static ulong UIntsToLong(uint X, uint Y)
{

View File

@ -2534,6 +2534,15 @@ namespace OpenSim.Region.ClientStack
RezObjectPacket rezPacket = (RezObjectPacket) Pack;
if (OnRezObject != null)
{
//rezPacket.RezData.BypassRaycast;
//rezPacket.RezData.RayEnd;
//rezPacket.RezData.RayEndIsIntersection;
//rezPacket.RezData.RayStart;
//rezPacket.RezData.RayTargetID;
//rezPacket.RezData.RemoveItem;
//rezPacket.RezData.RezSelected;
//rezPacket.RezData.FromTaskID;
//MainLog.Instance.Verbose("REZData", rezPacket.ToString());
OnRezObject(this, rezPacket.InventoryData.ItemID, rezPacket.RezData.RayEnd);
}
break;
@ -2713,7 +2722,13 @@ namespace OpenSim.Region.ClientStack
{
ObjectAddPacket addPacket = (ObjectAddPacket) Pack;
PrimitiveBaseShape shape = GetShapeFromAddPacket(addPacket);
OnAddPrim(AgentId, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape);
MainLog.Instance.Verbose("REZData", addPacket.ToString());
//BypassRaycast: 1
//RayStart: <69.79469, 158.2652, 98.40343>
//RayEnd: <61.97724, 141.995, 92.58341>
//RayTargetID: 00000000-0000-0000-0000-000000000000
OnAddPrim(AgentId, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape,addPacket.ObjectData.BypassRaycast,addPacket.ObjectData.RayStart,addPacket.ObjectData.RayTargetID,addPacket.ObjectData.RayEndIsIntersection);
}
break;
case PacketType.ObjectShape:

View File

@ -925,7 +925,89 @@ namespace OpenSim.Region.Environment.Scenes
return myID;
}
public virtual void AddNewPrim(LLUUID ownerID, LLVector3 pos, LLQuaternion rot, PrimitiveBaseShape shape)
public LLVector3 GetNewRezLocation(LLVector3 RayStart, LLVector3 RayEnd, LLUUID RayTargetID, LLQuaternion rot, byte bypassRayCast, byte RayEndIsIntersection)
{
LLVector3 pos = LLVector3.Zero;
if (RayEndIsIntersection == (byte)1)
{
pos = RayEnd;
return pos;
}
if (RayTargetID != LLUUID.Zero)
{
SceneObjectPart target = GetSceneObjectPart(RayTargetID);
if (target != null)
{
pos = target.AbsolutePosition;
//MainLog.Instance.Verbose("RAYTRACE", pos.ToString());
//EntityIntersection rayTracing = null;
//ScenePresence presence = ((ScenePresence)GetScenePresence(ownerID));
//if (presence != null)
//{
//Vector3 CameraPosition = presence.CameraPosition;
//Vector3 rayEnd = new Vector3(pos.X, pos.Y, pos.Z);
//float rayMag = m_innerScene.Vector3Distance(CameraPosition, rayEnd);
//LLVector3 rayDirectionLL = Util.GetNormal(pos);
//Vector3 rayDirection = new Vector3(rayDirectionLL.X, rayDirectionLL.Y, rayDirectionLL.Z);
//Ray rezRay = new Ray(CameraPosition, rayDirection);
//Vector3 RezDirectionFromCamera = rezRay.Direction;
//rayTracing = m_innerScene.GetClosestIntersectingPrim(rezRay);
//}
//if ((rayTracing != null) && (rayTracing.HitTF))
//{
// We raytraced and found a prim in the way of the ground.. so
// We will rez the object somewhere close to the prim. Better math needed. This is a Stub
//Vector3 Newpos = new Vector3(rayTracing.obj.AbsolutePosition.X,rayTracing.obj.AbsolutePosition.Y,rayTracing.obj.AbsolutePosition.Z);
//Vector3 Newpos = rayTracing.ipoint;
//Vector3 NewScale =
//new Vector3(rayTracing.obj.Scale.X, rayTracing.obj.Scale.Y, rayTracing.obj.Scale.Z);
//Quaternion ParentRot = rayTracing.obj.ParentGroup.Rotation;
//Quaternion ParentRot = new Quaternion(primParentRot.W,primParentRot.X,primParentRot.Y,primParentRot.Z);
//LLQuaternion primLocalRot = rayTracing.obj.RotationOffset;
//Quaternion LocalRot = new Quaternion(primLocalRot.W, primLocalRot.X, primLocalRot.Y, primLocalRot.Z);
//Quaternion NewRot = LocalRot * ParentRot;
//Vector3 RezPoint = Newpos;
//MainLog.Instance.Verbose("REZINFO", "Possible Rez Point:" + RezPoint.ToString());
//pos = new LLVector3(RezPoint.x, RezPoint.y, RezPoint.z);
//}
return pos;
}
else
{
// fall back to our stupid functionality
pos = RayEnd;
return pos;
}
}
else
{
// fall back to our stupid functionality
pos = RayEnd;
return pos;
}
}
public virtual void AddNewPrim(LLUUID ownerID, LLVector3 RayEnd, LLQuaternion rot, PrimitiveBaseShape shape,
byte bypassRaycast, LLVector3 RayStart, LLUUID RayTargetID,
byte RayEndIsIntersection)
{
// What we're *supposed* to do is raytrace from the camera position given by the client to the nearest collision
// in the direction the client supplies (the ground level that we clicked)
@ -933,53 +1015,17 @@ namespace OpenSim.Region.Environment.Scenes
// Test it if you like. The console will write where it guesses a collision took place. if it thinks one did.
// It's wrong many times though.
LLVector3 pos = GetNewRezLocation(RayStart, RayEnd, RayTargetID, rot, bypassRaycast, RayEndIsIntersection);
if (PermissionsMngr.CanRezObject(ownerID, pos))
{
EntityIntersection rayTracing = null;
ScenePresence presence = ((ScenePresence) GetScenePresence(ownerID));
if (presence != null)
{
Vector3 CameraPosition = presence.CameraPosition;
Vector3 rayEnd = new Vector3(pos.X, pos.Y, pos.Z);
float raydistance = m_innerScene.Vector3Distance(CameraPosition, rayEnd);
Vector3 rayDirection = new Vector3(rayEnd.x/raydistance, rayEnd.y/raydistance, rayEnd.z/raydistance);
Ray rezRay = new Ray(CameraPosition, rayDirection);
Vector3 RezDirectionFromCamera = rezRay.Direction;
rayTracing = m_innerScene.GetClosestIntersectingPrim(rezRay);
}
if ((rayTracing != null) && (rayTracing.HitTF))
{
// We raytraced and found a prim in the way of the ground.. so
// We will rez the object somewhere close to the prim. Better math needed. This is a Stub
//Vector3 Newpos = new Vector3(rayTracing.obj.AbsolutePosition.X,rayTracing.obj.AbsolutePosition.Y,rayTracing.obj.AbsolutePosition.Z);
Vector3 Newpos = rayTracing.ipoint;
Vector3 NewScale =
new Vector3(rayTracing.obj.Scale.X, rayTracing.obj.Scale.Y, rayTracing.obj.Scale.Z);
Quaternion ParentRot = rayTracing.obj.ParentGroup.Rotation;
//Quaternion ParentRot = new Quaternion(primParentRot.W,primParentRot.X,primParentRot.Y,primParentRot.Z);
LLQuaternion primLocalRot = rayTracing.obj.RotationOffset;
Quaternion LocalRot = new Quaternion(primLocalRot.W, primLocalRot.X, primLocalRot.Y, primLocalRot.Z);
Quaternion NewRot = LocalRot*ParentRot;
Vector3 RezPoint = Newpos;
MainLog.Instance.Verbose("REZINFO", "Possible Rez Point:" + RezPoint.ToString());
//pos = new LLVector3(RezPoint.x, RezPoint.y, RezPoint.z);
}
else
{
// rez ON the ground, not IN the ground
pos.Z += 0.25F;
}
SceneObjectGroup sceneOb =
new SceneObjectGroup(this, m_regionHandle, ownerID, PrimIDAllocate(), pos, rot, shape);
@ -1018,7 +1064,7 @@ namespace OpenSim.Region.Environment.Scenes
treeShape.PCode = newTree ? (byte) PCode.NewTree : (byte) PCode.Tree;
treeShape.Scale = scale;
treeShape.State = (byte) treeType;
AddNewPrim(LLUUID.Random(), position, rotation, treeShape);
AddNewPrim(LLUUID.Random(), position, rotation, treeShape,(byte)1,LLVector3.Zero,LLUUID.Zero,(byte)1);
}
public void RemovePrim(uint localID, LLUUID avatar_deleter)

View File

@ -694,19 +694,22 @@ namespace OpenSim.Region.Environment.Scenes
EntityIntersection returnresult = new EntityIntersection();
Vector3 vAbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z);
Vector3 vScale = new Vector3(Scale.X, Scale.Y, Scale.Z);
Quaternion qRotation =
new Quaternion(RotationOffset.W, RotationOffset.X, RotationOffset.Y, RotationOffset.Z);
Quaternion worldRotation = (qRotation*parentrot);
Matrix3 worldRotM = worldRotation.ToRotationMatrix();
//Quaternion worldRotation = (qRotation*parentrot);
//Matrix3 worldRotM = worldRotation.ToRotationMatrix();
Vector3 rOrigin = iray.Origin;
Vector3 rDirection = iray.Direction;
//rDirection = rDirection.Normalize();
// Buidling the first part of the Quadratic equation
Vector3 r2ndDirection = rDirection*rDirection;
float itestPart1 = r2ndDirection.x + r2ndDirection.y + r2ndDirection.z;

View File

@ -299,10 +299,7 @@ namespace OpenSim.Region.Physics.OdePlugin
p2.PhysicsActorType == (int) ActorTypes.Prim))
{
if (p2.PhysicsActorType == (int) ActorTypes.Agent)
{ if (p1.IsPhysical)
{
int q = 1;
}
{
p2.CollidingObj = true;
//contacts[i].depth = 0.003f;
p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 2.5f);
@ -313,18 +310,12 @@ namespace OpenSim.Region.Physics.OdePlugin
}
else
{
if (p1.IsPhysical)
{
int q = 1;
}
contacts[i].depth = 0.0000000f;
//contacts[i].depth = 0.0000000f;
}
if (p1.PhysicsActorType == (int) ActorTypes.Agent)
{
if (p2.IsPhysical)
{
int q = 1;
}
p1.CollidingObj = true;
//contacts[i].depth = 0.003f;
p1.Velocity = p1.Velocity + new PhysicsVector(0, 0, 2.5f);