diff options
author | Teravus Ovares | 2009-04-14 09:03:18 +0000 |
---|---|---|
committer | Teravus Ovares | 2009-04-14 09:03:18 +0000 |
commit | d34d5eb3f7b5eb83e87b7f2fee10a95cad08fcd6 (patch) | |
tree | b6b61d4295ce9ebbdfa52864cb2ef30ee935b06e /OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | |
parent | Thank you, Fly-Man, for a patch that adds the stub to handle the (diff) | |
download | opensim-SC_OLD-d34d5eb3f7b5eb83e87b7f2fee10a95cad08fcd6.zip opensim-SC_OLD-d34d5eb3f7b5eb83e87b7f2fee10a95cad08fcd6.tar.gz opensim-SC_OLD-d34d5eb3f7b5eb83e87b7f2fee10a95cad08fcd6.tar.bz2 opensim-SC_OLD-d34d5eb3f7b5eb83e87b7f2fee10a95cad08fcd6.tar.xz |
* Adding some organization of vehicle type stuff in the ODEPlugin.
* Vehicles do NOT work. This is just organization and a bit of logical code to make doing vehicles easier
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin/ODEPrim.cs')
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 213 |
1 files changed, 30 insertions, 183 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 5e7ec37..8711937 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | |||
@@ -166,10 +166,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
166 | 166 | ||
167 | public volatile bool childPrim = false; | 167 | public volatile bool childPrim = false; |
168 | 168 | ||
169 | private ODEVehicleSettings m_vehicle; | ||
170 | |||
169 | public OdePrim(String primName, OdeScene parent_scene, PhysicsVector pos, PhysicsVector size, | 171 | public OdePrim(String primName, OdeScene parent_scene, PhysicsVector pos, PhysicsVector size, |
170 | Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode) | 172 | Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode) |
171 | { | 173 | { |
172 | _target_velocity = new PhysicsVector(0, 0, 0); | 174 | _target_velocity = new PhysicsVector(0, 0, 0); |
175 | m_vehicle = new ODEVehicleSettings(); | ||
173 | //gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned); | 176 | //gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned); |
174 | ode = dode; | 177 | ode = dode; |
175 | _velocity = new PhysicsVector(); | 178 | _velocity = new PhysicsVector(); |
@@ -308,7 +311,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
308 | if (!childPrim) | 311 | if (!childPrim) |
309 | { | 312 | { |
310 | if (m_isphysical && Body != IntPtr.Zero) | 313 | if (m_isphysical && Body != IntPtr.Zero) |
314 | { | ||
311 | d.BodyEnable(Body); | 315 | d.BodyEnable(Body); |
316 | m_vehicle.Enable(Body, _parent_scene); | ||
317 | } | ||
312 | 318 | ||
313 | m_disabled = false; | 319 | m_disabled = false; |
314 | } | 320 | } |
@@ -319,7 +325,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
319 | m_disabled = true; | 325 | m_disabled = true; |
320 | 326 | ||
321 | if (m_isphysical && Body != IntPtr.Zero) | 327 | if (m_isphysical && Body != IntPtr.Zero) |
328 | { | ||
322 | d.BodyDisable(Body); | 329 | d.BodyDisable(Body); |
330 | m_vehicle.Disable(); | ||
331 | } | ||
323 | } | 332 | } |
324 | 333 | ||
325 | public void enableBody() | 334 | public void enableBody() |
@@ -358,6 +367,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
358 | { | 367 | { |
359 | createAMotor(m_angularlock); | 368 | createAMotor(m_angularlock); |
360 | } | 369 | } |
370 | if (m_vehicle.Type != Vehicle.TYPE_NONE) | ||
371 | { | ||
372 | m_vehicle.Enable(Body, _parent_scene); | ||
373 | } | ||
361 | 374 | ||
362 | _parent_scene.addActivePrim(this); | 375 | _parent_scene.addActivePrim(this); |
363 | } | 376 | } |
@@ -722,7 +735,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
722 | if (Body != IntPtr.Zero) | 735 | if (Body != IntPtr.Zero) |
723 | { | 736 | { |
724 | _parent_scene.remActivePrim(this); | 737 | _parent_scene.remActivePrim(this); |
725 | 738 | m_vehicle.Destroy(); | |
726 | m_collisionCategories &= ~CollisionCategories.Body; | 739 | m_collisionCategories &= ~CollisionCategories.Body; |
727 | m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land); | 740 | m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land); |
728 | 741 | ||
@@ -925,10 +938,16 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
925 | Amotor = IntPtr.Zero; | 938 | Amotor = IntPtr.Zero; |
926 | } | 939 | } |
927 | } | 940 | } |
941 | |||
942 | if (m_vehicle.Type != Vehicle.TYPE_NONE) | ||
943 | { | ||
944 | m_vehicle.Reset(); | ||
945 | } | ||
928 | } | 946 | } |
929 | } | 947 | } |
930 | // Store this for later in case we get turned into a separate body | 948 | // Store this for later in case we get turned into a separate body |
931 | m_angularlock = new PhysicsVector(m_taintAngularLock.X, m_taintAngularLock.Y, m_taintAngularLock.Z); | 949 | m_angularlock = new PhysicsVector(m_taintAngularLock.X, m_taintAngularLock.Y, m_taintAngularLock.Z); |
950 | |||
932 | } | 951 | } |
933 | 952 | ||
934 | private void changelink(float timestep) | 953 | private void changelink(float timestep) |
@@ -1113,7 +1132,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1113 | createAMotor(m_angularlock); | 1132 | createAMotor(m_angularlock); |
1114 | } | 1133 | } |
1115 | d.BodySetPosition(Body, Position.X, Position.Y, Position.Z); | 1134 | d.BodySetPosition(Body, Position.X, Position.Y, Position.Z); |
1116 | 1135 | m_vehicle.Enable(Body, _parent_scene); | |
1117 | _parent_scene.addActivePrim(this); | 1136 | _parent_scene.addActivePrim(this); |
1118 | } | 1137 | } |
1119 | } | 1138 | } |
@@ -1706,6 +1725,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1706 | fy = nmin; | 1725 | fy = nmin; |
1707 | d.BodyAddForce(Body, fx, fy, fz); | 1726 | d.BodyAddForce(Body, fx, fy, fz); |
1708 | } | 1727 | } |
1728 | |||
1729 | m_vehicle.Step(timestep); | ||
1709 | } | 1730 | } |
1710 | else | 1731 | else |
1711 | { | 1732 | { |
@@ -1816,11 +1837,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1816 | 1837 | ||
1817 | public void changesize(float timestamp) | 1838 | public void changesize(float timestamp) |
1818 | { | 1839 | { |
1819 | //if (!_parent_scene.geom_name_map.ContainsKey(prim_geom)) | 1840 | |
1820 | //{ | ||
1821 | // m_taintsize = _size; | ||
1822 | //return; | ||
1823 | //} | ||
1824 | string oldname = _parent_scene.geom_name_map[prim_geom]; | 1841 | string oldname = _parent_scene.geom_name_map[prim_geom]; |
1825 | 1842 | ||
1826 | if (_size.X <= 0) _size.X = 0.01f; | 1843 | if (_size.X <= 0) _size.X = 0.01f; |
@@ -1915,177 +1932,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1915 | m_taintsize = _size; | 1932 | m_taintsize = _size; |
1916 | } | 1933 | } |
1917 | 1934 | ||
1918 | //public void changesize(float timestamp) | 1935 | |
1919 | //{ | ||
1920 | // //if (!_parent_scene.geom_name_map.ContainsKey(prim_geom)) | ||
1921 | // //{ | ||
1922 | // // m_taintsize = _size; | ||
1923 | // //return; | ||
1924 | // //} | ||
1925 | // string oldname = _parent_scene.geom_name_map[prim_geom]; | ||
1926 | |||
1927 | // if (_size.X <= 0) _size.X = 0.01f; | ||
1928 | // if (_size.Y <= 0) _size.Y = 0.01f; | ||
1929 | // if (_size.Z <= 0) _size.Z = 0.01f; | ||
1930 | |||
1931 | // // Cleanup of old prim geometry | ||
1932 | // if (_mesh != null) | ||
1933 | // { | ||
1934 | // // Cleanup meshing here | ||
1935 | // } | ||
1936 | // //kill body to rebuild | ||
1937 | // if (IsPhysical && Body != (IntPtr) 0) | ||
1938 | // { | ||
1939 | // disableBody(); | ||
1940 | // } | ||
1941 | // if (d.SpaceQuery(m_targetSpace, prim_geom)) | ||
1942 | // { | ||
1943 | // _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
1944 | // d.SpaceRemove(m_targetSpace, prim_geom); | ||
1945 | // } | ||
1946 | // d.GeomDestroy(prim_geom); | ||
1947 | // prim_geom = (IntPtr)0; | ||
1948 | // // we don't need to do space calculation because the client sends a position update also. | ||
1949 | |||
1950 | // // Construction of new prim | ||
1951 | // if (_parent_scene.needsMeshing(_pbs)) | ||
1952 | // { | ||
1953 | // float meshlod = _parent_scene.meshSculptLOD; | ||
1954 | |||
1955 | // if (IsPhysical) | ||
1956 | // meshlod = _parent_scene.MeshSculptphysicalLOD; | ||
1957 | // // Don't need to re-enable body.. it's done in SetMesh | ||
1958 | // IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); | ||
1959 | // // createmesh returns null when it's a shape that isn't a cube. | ||
1960 | // if (mesh != null) | ||
1961 | // { | ||
1962 | // setMesh(_parent_scene, mesh); | ||
1963 | // d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | ||
1964 | // d.Quaternion myrot = new d.Quaternion(); | ||
1965 | // myrot.W = _orientation.w; | ||
1966 | // myrot.X = _orientation.X; | ||
1967 | // myrot.Y = _orientation.Y; | ||
1968 | // myrot.Z = _orientation.Z; | ||
1969 | // d.GeomSetQuaternion(prim_geom, ref myrot); | ||
1970 | |||
1971 | // //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z); | ||
1972 | // if (IsPhysical && Body == (IntPtr)0) | ||
1973 | // { | ||
1974 | // // Re creates body on size. | ||
1975 | // // EnableBody also does setMass() | ||
1976 | // enableBody(); | ||
1977 | // d.BodyEnable(Body); | ||
1978 | // } | ||
1979 | // } | ||
1980 | // else | ||
1981 | // { | ||
1982 | // if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1) | ||
1983 | // { | ||
1984 | // if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z) | ||
1985 | // { | ||
1986 | // if (((_size.X / 2f) > 0f) && ((_size.X / 2f) < 1000)) | ||
1987 | // { | ||
1988 | // _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
1989 | // SetGeom(d.CreateSphere(m_targetSpace, _size.X / 2)); | ||
1990 | // } | ||
1991 | // else | ||
1992 | // { | ||
1993 | // m_log.Info("[PHYSICS]: Failed to load a sphere bad size"); | ||
1994 | // _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
1995 | // SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); | ||
1996 | // } | ||
1997 | |||
1998 | // } | ||
1999 | // else | ||
2000 | // { | ||
2001 | // _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
2002 | // SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); | ||
2003 | // } | ||
2004 | // } | ||
2005 | // //else if (_pbs.ProfileShape == ProfileShape.Circle && _pbs.PathCurve == (byte)Extrusion.Straight) | ||
2006 | // //{ | ||
2007 | // //Cyllinder | ||
2008 | // //if (_size.X == _size.Y) | ||
2009 | // //{ | ||
2010 | // // prim_geom = d.CreateCylinder(m_targetSpace, _size.X / 2, _size.Z); | ||
2011 | // //} | ||
2012 | // //else | ||
2013 | // //{ | ||
2014 | // //prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); | ||
2015 | // //} | ||
2016 | // //} | ||
2017 | // else | ||
2018 | // { | ||
2019 | // _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
2020 | // SetGeom(prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); | ||
2021 | // } | ||
2022 | // //prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); | ||
2023 | // d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | ||
2024 | // d.Quaternion myrot = new d.Quaternion(); | ||
2025 | // myrot.W = _orientation.w; | ||
2026 | // myrot.X = _orientation.X; | ||
2027 | // myrot.Y = _orientation.Y; | ||
2028 | // myrot.Z = _orientation.Z; | ||
2029 | // d.GeomSetQuaternion(prim_geom, ref myrot); | ||
2030 | // } | ||
2031 | // } | ||
2032 | // else | ||
2033 | // { | ||
2034 | // if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1) | ||
2035 | // { | ||
2036 | // if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z) | ||
2037 | // { | ||
2038 | // _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
2039 | // SetGeom(d.CreateSphere(m_targetSpace, _size.X / 2)); | ||
2040 | // } | ||
2041 | // else | ||
2042 | // { | ||
2043 | // _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
2044 | // SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); | ||
2045 | // } | ||
2046 | // } | ||
2047 | // //else if (_pbs.ProfileShape == ProfileShape.Circle && _pbs.PathCurve == (byte)Extrusion.Straight) | ||
2048 | // //{ | ||
2049 | // //Cyllinder | ||
2050 | // //if (_size.X == _size.Y) | ||
2051 | // //{ | ||
2052 | // //prim_geom = d.CreateCylinder(m_targetSpace, _size.X / 2, _size.Z); | ||
2053 | // //} | ||
2054 | // //else | ||
2055 | // //{ | ||
2056 | // //prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); | ||
2057 | // //} | ||
2058 | // //} | ||
2059 | // else | ||
2060 | // { | ||
2061 | // _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
2062 | // SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); | ||
2063 | // } | ||
2064 | // d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | ||
2065 | // d.Quaternion myrot = new d.Quaternion(); | ||
2066 | // myrot.W = _orientation.w; | ||
2067 | // myrot.X = _orientation.X; | ||
2068 | // myrot.Y = _orientation.Y; | ||
2069 | // myrot.Z = _orientation.Z; | ||
2070 | // d.GeomSetQuaternion(prim_geom, ref myrot); | ||
2071 | |||
2072 | // //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z); | ||
2073 | // if (IsPhysical && Body == (IntPtr) 0) | ||
2074 | // { | ||
2075 | // // Re creates body on size. | ||
2076 | // // EnableBody also does setMass() | ||
2077 | // enableBody(); | ||
2078 | // d.BodyEnable(Body); | ||
2079 | // } | ||
2080 | // } | ||
2081 | |||
2082 | // _parent_scene.geom_name_map[prim_geom] = oldname; | ||
2083 | |||
2084 | // changeSelectedStatus(timestamp); | ||
2085 | |||
2086 | // resetCollisionAccounting(); | ||
2087 | // m_taintsize = _size; | ||
2088 | //} | ||
2089 | 1936 | ||
2090 | public void changefloatonwater(float timestep) | 1937 | public void changefloatonwater(float timestep) |
2091 | { | 1938 | { |
@@ -2380,23 +2227,23 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2380 | 2227 | ||
2381 | public override int VehicleType | 2228 | public override int VehicleType |
2382 | { | 2229 | { |
2383 | get { return 0; } | 2230 | get { return (int)m_vehicle.Type; } |
2384 | set { return; } | 2231 | set { m_vehicle.ProcessTypeChange((Vehicle)value); } |
2385 | } | 2232 | } |
2386 | 2233 | ||
2387 | public override void VehicleFloatParam(int param, float value) | 2234 | public override void VehicleFloatParam(int param, float value) |
2388 | { | 2235 | { |
2389 | 2236 | m_vehicle.ProcessFloatVehicleParam((Vehicle) param, value); | |
2390 | } | 2237 | } |
2391 | 2238 | ||
2392 | public override void VehicleVectorParam(int param, PhysicsVector value) | 2239 | public override void VehicleVectorParam(int param, PhysicsVector value) |
2393 | { | 2240 | { |
2394 | 2241 | m_vehicle.ProcessVectorVehicleParam((Vehicle) param, value); | |
2395 | } | 2242 | } |
2396 | 2243 | ||
2397 | public override void VehicleRotationParam(int param, Quaternion rotation) | 2244 | public override void VehicleRotationParam(int param, Quaternion rotation) |
2398 | { | 2245 | { |
2399 | 2246 | m_vehicle.ProcessRotationVehicleParam((Vehicle) param, rotation); | |
2400 | } | 2247 | } |
2401 | 2248 | ||
2402 | public override void SetVolumeDetect(int param) | 2249 | public override void SetVolumeDetect(int param) |