From 08819bcbea9012d67cc4cb44e4d7ec7e5837bac6 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 19 Jul 2009 02:32:02 +0000 Subject: * Created a way that the OpenSimulator scene can ask the physics scene to do a raycast test safely. * Test for prim obstructions between the avatar and camera. If there are obstructions, inform the client to move the camera closer. This makes it so that walls and objects don't obstruct your view while you're moving around. Try walking inside a hollowed tori. You'll see how much easier it is now because your camera automatically moves closer so you can still see. * Created a way to know if the user's camera is alt + cammed or just following the avatar. * Changes IClientAPI interface by adding SendCameraConstraint(Vector4 CameraConstraint) --- OpenSim/Region/Physics/Manager/PhysicsScene.cs | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'OpenSim/Region/Physics/Manager') diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs index 410707b..95699fb 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs @@ -36,6 +36,8 @@ namespace OpenSim.Region.Physics.Manager { public delegate void physicsCrash(); + public delegate void RaycastCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance); + public abstract class PhysicsScene { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -152,6 +154,39 @@ namespace OpenSim.Region.Physics.Manager public abstract bool IsThreaded { get; } + /// + /// True if the physics plugin supports raycasting against the physics scene + /// + public virtual bool SupportsRayCast() + { + return false; + } + + /// + /// Queue a raycast against the physics scene. + /// The provided callback method will be called when the raycast is complete + /// + /// Many physics engines don't support collision testing at the same time as + /// manipulating the physics scene, so we queue the request up and callback + /// a custom method when the raycast is complete. + /// This allows physics engines that give an immediate result to callback immediately + /// and ones that don't, to callback when it gets a result back. + /// + /// ODE for example will not allow you to change the scene while collision testing or + /// it asserts, 'opteration not valid for locked space'. This includes adding a ray to the scene. + /// + /// This is named RayCastWorld to not conflict with modrex's Raycast method. + /// + /// Origin of the ray + /// Direction of the ray + /// Length of ray in meters + /// Method to call when the raycast is complete + public virtual void RaycastWorld( Vector3 position, Vector3 direction, float length, RaycastCallback retMethod) + { + if (retMethod != null) + retMethod(false, Vector3.Zero, 0, 999999999999f); + } + private class NullPhysicsScene : PhysicsScene { private static int m_workIndicator; @@ -240,6 +275,7 @@ namespace OpenSim.Region.Physics.Manager Dictionary returncolliders = new Dictionary(); return returncolliders; } + } } public delegate void JointMoved(PhysicsJoint joint); -- cgit v1.1