diff options
author | UbitUmarov | 2015-10-20 19:33:15 +0100 |
---|---|---|
committer | UbitUmarov | 2015-10-20 19:33:15 +0100 |
commit | f6891b36beed2667ba0ca7e874f671ce122f5f76 (patch) | |
tree | f933b688eb970056650a9117c61bd76b9d8b5e19 | |
parent | move ugly convertion of axis locks 3 bit flags to a wasted vector3 down to P... (diff) | |
download | opensim-SC-f6891b36beed2667ba0ca7e874f671ce122f5f76.zip opensim-SC-f6891b36beed2667ba0ca7e874f671ce122f5f76.tar.gz opensim-SC-f6891b36beed2667ba0ca7e874f671ce122f5f76.tar.bz2 opensim-SC-f6891b36beed2667ba0ca7e874f671ce122f5f76.tar.xz |
stop using a vector3 to store axis locks 3bit flags in ubOde
-rw-r--r-- | OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs | 6 | ||||
-rw-r--r-- | OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs | 78 |
2 files changed, 46 insertions, 38 deletions
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs index 0d9f974..55619c0 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs | |||
@@ -539,7 +539,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
539 | 539 | ||
540 | } | 540 | } |
541 | 541 | ||
542 | public override void LockAngularMotion(Vector3 axis) | 542 | public override void LockAngularMotion(byte axislocks) |
543 | { | 543 | { |
544 | 544 | ||
545 | } | 545 | } |
@@ -1743,7 +1743,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
1743 | { | 1743 | { |
1744 | } | 1744 | } |
1745 | 1745 | ||
1746 | private void changeAngularLock(Vector3 arg) | 1746 | private void changeAngularLock(byte arg) |
1747 | { | 1747 | { |
1748 | } | 1748 | } |
1749 | 1749 | ||
@@ -1892,7 +1892,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
1892 | break; | 1892 | break; |
1893 | 1893 | ||
1894 | case changes.AngLock: | 1894 | case changes.AngLock: |
1895 | changeAngularLock((Vector3)arg); | 1895 | changeAngularLock((byte)arg); |
1896 | break; | 1896 | break; |
1897 | 1897 | ||
1898 | case changes.Size: | 1898 | case changes.Size: |
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs index 1c215c1..7d57cb4 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs | |||
@@ -74,6 +74,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
74 | private bool m_lastdoneSelected; | 74 | private bool m_lastdoneSelected; |
75 | internal bool m_outbounds; | 75 | internal bool m_outbounds; |
76 | 76 | ||
77 | private byte m_angularlocks = 0; | ||
78 | |||
77 | private Quaternion m_lastorientation; | 79 | private Quaternion m_lastorientation; |
78 | private Quaternion _orientation; | 80 | private Quaternion _orientation; |
79 | 81 | ||
@@ -85,7 +87,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
85 | private Vector3 m_rotationalVelocity; | 87 | private Vector3 m_rotationalVelocity; |
86 | private Vector3 _size; | 88 | private Vector3 _size; |
87 | private Vector3 _acceleration; | 89 | private Vector3 _acceleration; |
88 | private Vector3 m_angularlock = Vector3.One; | ||
89 | private IntPtr Amotor; | 90 | private IntPtr Amotor; |
90 | 91 | ||
91 | private Vector3 m_force; | 92 | private Vector3 m_force; |
@@ -981,21 +982,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
981 | AddChange(changes.DeLink, null); | 982 | AddChange(changes.DeLink, null); |
982 | } | 983 | } |
983 | 984 | ||
984 | public override void LockAngularMotion(Vector3 axis) | 985 | public override void LockAngularMotion(byte axislock) |
985 | { | 986 | { |
986 | // reverse the zero/non zero values for ODE. | ||
987 | if (axis.IsFinite()) | ||
988 | { | ||
989 | axis.X = (axis.X > 0) ? 1f : 0f; | ||
990 | axis.Y = (axis.Y > 0) ? 1f : 0f; | ||
991 | axis.Z = (axis.Z > 0) ? 1f : 0f; | ||
992 | // m_log.DebugFormat("[axislock]: <{0},{1},{2}>", axis.X, axis.Y, axis.Z); | 987 | // m_log.DebugFormat("[axislock]: <{0},{1},{2}>", axis.X, axis.Y, axis.Z); |
993 | AddChange(changes.AngLock, axis); | 988 | AddChange(changes.AngLock, axislock); |
994 | } | 989 | |
995 | else | ||
996 | { | ||
997 | m_log.WarnFormat("[PHYSICS]: Got NaN locking axis from Scene on Object {0}", Name); | ||
998 | } | ||
999 | } | 990 | } |
1000 | 991 | ||
1001 | public override void SubscribeEvents(int ms) | 992 | public override void SubscribeEvents(int ms) |
@@ -1297,7 +1288,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
1297 | } | 1288 | } |
1298 | } | 1289 | } |
1299 | 1290 | ||
1300 | private void createAMotor(Vector3 axis) | 1291 | private void createAMotor(byte axislock) |
1301 | { | 1292 | { |
1302 | if (Body == IntPtr.Zero) | 1293 | if (Body == IntPtr.Zero) |
1303 | return; | 1294 | return; |
@@ -1308,11 +1299,28 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
1308 | Amotor = IntPtr.Zero; | 1299 | Amotor = IntPtr.Zero; |
1309 | } | 1300 | } |
1310 | 1301 | ||
1311 | int axisnum = 3 - (int)(axis.X + axis.Y + axis.Z); | 1302 | int axisnum = 0; |
1303 | bool axisX = false; | ||
1304 | bool axisY = false; | ||
1305 | bool axisZ = false; | ||
1306 | if((axislock & 0x02) != 0) | ||
1307 | { | ||
1308 | axisnum++; | ||
1309 | axisX = true; | ||
1310 | } | ||
1311 | if((axislock & 0x04) != 0) | ||
1312 | { | ||
1313 | axisnum++; | ||
1314 | axisY = true; | ||
1315 | } | ||
1316 | if((axislock & 0x08) != 0) | ||
1317 | { | ||
1318 | axisnum++; | ||
1319 | axisZ = true; | ||
1320 | } | ||
1312 | 1321 | ||
1313 | if (axisnum <= 0) | 1322 | if(axisnum == 0) |
1314 | return; | 1323 | return; |
1315 | |||
1316 | // stop it | 1324 | // stop it |
1317 | d.BodySetTorque(Body, 0, 0, 0); | 1325 | d.BodySetTorque(Body, 0, 0, 0); |
1318 | d.BodySetAngularVel(Body, 0, 0, 0); | 1326 | d.BodySetAngularVel(Body, 0, 0, 0); |
@@ -1336,10 +1344,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
1336 | 1344 | ||
1337 | int i = 0; | 1345 | int i = 0; |
1338 | int j = 0; | 1346 | int j = 0; |
1339 | if (axis.X == 0) | 1347 | if (axisX) |
1340 | { | 1348 | { |
1341 | ax = (new Vector3(1, 0, 0)) * curr; // rotate world X to current local X | 1349 | ax = (new Vector3(1, 0, 0)) * curr; // rotate world X to current local X |
1342 | // ODE should do this with axis relative to body 1 but seems to fail | ||
1343 | d.JointSetAMotorAxis(Amotor, 0, 0, ax.X, ax.Y, ax.Z); | 1350 | d.JointSetAMotorAxis(Amotor, 0, 0, ax.X, ax.Y, ax.Z); |
1344 | d.JointSetAMotorAngle(Amotor, 0, 0); | 1351 | d.JointSetAMotorAngle(Amotor, 0, 0); |
1345 | d.JointSetAMotorParam(Amotor, (int)d.JointParam.LoStop, 0f); | 1352 | d.JointSetAMotorParam(Amotor, (int)d.JointParam.LoStop, 0f); |
@@ -1347,6 +1354,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
1347 | d.JointSetAMotorParam(Amotor, (int)d.JointParam.Vel, 0); | 1354 | d.JointSetAMotorParam(Amotor, (int)d.JointParam.Vel, 0); |
1348 | d.JointSetAMotorParam(Amotor, (int)d.JointParam.FudgeFactor, 0.0001f); | 1355 | d.JointSetAMotorParam(Amotor, (int)d.JointParam.FudgeFactor, 0.0001f); |
1349 | d.JointSetAMotorParam(Amotor, (int)d.JointParam.Bounce, 0f); | 1356 | d.JointSetAMotorParam(Amotor, (int)d.JointParam.Bounce, 0f); |
1357 | d.JointSetAMotorParam(Amotor, (int)d.JointParam.CFM, 0f); | ||
1350 | d.JointSetAMotorParam(Amotor, (int)d.JointParam.FMax, 5e8f); | 1358 | d.JointSetAMotorParam(Amotor, (int)d.JointParam.FMax, 5e8f); |
1351 | d.JointSetAMotorParam(Amotor, (int)d.JointParam.StopCFM, 0f); | 1359 | d.JointSetAMotorParam(Amotor, (int)d.JointParam.StopCFM, 0f); |
1352 | d.JointSetAMotorParam(Amotor, (int)d.JointParam.StopERP, 0.8f); | 1360 | d.JointSetAMotorParam(Amotor, (int)d.JointParam.StopERP, 0.8f); |
@@ -1354,7 +1362,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
1354 | j = 256; // move to next axis set | 1362 | j = 256; // move to next axis set |
1355 | } | 1363 | } |
1356 | 1364 | ||
1357 | if (axis.Y == 0) | 1365 | if (axisY) |
1358 | { | 1366 | { |
1359 | ax = (new Vector3(0, 1, 0)) * curr; | 1367 | ax = (new Vector3(0, 1, 0)) * curr; |
1360 | d.JointSetAMotorAxis(Amotor, i, 0, ax.X, ax.Y, ax.Z); | 1368 | d.JointSetAMotorAxis(Amotor, i, 0, ax.X, ax.Y, ax.Z); |
@@ -1364,6 +1372,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
1364 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.Vel, 0); | 1372 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.Vel, 0); |
1365 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.FudgeFactor, 0.0001f); | 1373 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.FudgeFactor, 0.0001f); |
1366 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.Bounce, 0f); | 1374 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.Bounce, 0f); |
1375 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.CFM, 0f); | ||
1367 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.FMax, 5e8f); | 1376 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.FMax, 5e8f); |
1368 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.StopCFM, 0f); | 1377 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.StopCFM, 0f); |
1369 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.StopERP, 0.8f); | 1378 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.StopERP, 0.8f); |
@@ -1371,7 +1380,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
1371 | j += 256; | 1380 | j += 256; |
1372 | } | 1381 | } |
1373 | 1382 | ||
1374 | if (axis.Z == 0) | 1383 | if (axisZ) |
1375 | { | 1384 | { |
1376 | ax = (new Vector3(0, 0, 1)) * curr; | 1385 | ax = (new Vector3(0, 0, 1)) * curr; |
1377 | d.JointSetAMotorAxis(Amotor, i, 0, ax.X, ax.Y, ax.Z); | 1386 | d.JointSetAMotorAxis(Amotor, i, 0, ax.X, ax.Y, ax.Z); |
@@ -1381,6 +1390,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
1381 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.Vel, 0); | 1390 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.Vel, 0); |
1382 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.FudgeFactor, 0.0001f); | 1391 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.FudgeFactor, 0.0001f); |
1383 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.Bounce, 0f); | 1392 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.Bounce, 0f); |
1393 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.CFM, 0f); | ||
1384 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.FMax, 5e8f); | 1394 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.FMax, 5e8f); |
1385 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.StopCFM, 0f); | 1395 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.StopCFM, 0f); |
1386 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.StopERP, 0.8f); | 1396 | d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.StopERP, 0.8f); |
@@ -1430,8 +1440,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
1430 | else if (x < 0.001f || y < 0.001f || z < 0.001f) | 1440 | else if (x < 0.001f || y < 0.001f || z < 0.001f) |
1431 | m_log.WarnFormat("[PHYSICS]: small prim geo {0},size {1}, AABBsize <{2},{3},{4}, mesh {5} at {6}", | 1441 | m_log.WarnFormat("[PHYSICS]: small prim geo {0},size {1}, AABBsize <{2},{3},{4}, mesh {5} at {6}", |
1432 | Name, _size.ToString(), x, y, z, _pbs.SculptEntry ? _pbs.SculptTexture.ToString() : "primMesh", _position.ToString()); | 1442 | Name, _size.ToString(), x, y, z, _pbs.SculptEntry ? _pbs.SculptTexture.ToString() : "primMesh", _position.ToString()); |
1433 | |||
1434 | // | ||
1435 | */ | 1443 | */ |
1436 | 1444 | ||
1437 | } | 1445 | } |
@@ -1869,9 +1877,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
1869 | } | 1877 | } |
1870 | 1878 | ||
1871 | // The body doesn't already have a finite rotation mode set here | 1879 | // The body doesn't already have a finite rotation mode set here |
1872 | if ((!m_angularlock.ApproxEquals(Vector3.One, 0.0f)) && _parent == null) | 1880 | if (m_angularlocks != 0 && _parent == null) |
1873 | { | 1881 | { |
1874 | createAMotor(m_angularlock); | 1882 | createAMotor(m_angularlocks); |
1875 | } | 1883 | } |
1876 | 1884 | ||
1877 | if (m_isSelected || m_disabled) | 1885 | if (m_isSelected || m_disabled) |
@@ -2427,7 +2435,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
2427 | { | 2435 | { |
2428 | } | 2436 | } |
2429 | 2437 | ||
2430 | private void changeAngularLock(Vector3 newLock) | 2438 | private void changeAngularLock(byte newLocks) |
2431 | { | 2439 | { |
2432 | // do we have a Physical object? | 2440 | // do we have a Physical object? |
2433 | if (Body != IntPtr.Zero) | 2441 | if (Body != IntPtr.Zero) |
@@ -2436,9 +2444,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
2436 | //If we have a parent then we're not authorative here | 2444 | //If we have a parent then we're not authorative here |
2437 | if (_parent == null) | 2445 | if (_parent == null) |
2438 | { | 2446 | { |
2439 | if (!newLock.ApproxEquals(Vector3.One, 0f)) | 2447 | if (newLocks != 0) |
2440 | { | 2448 | { |
2441 | createAMotor(newLock); | 2449 | createAMotor(newLocks); |
2442 | } | 2450 | } |
2443 | else | 2451 | else |
2444 | { | 2452 | { |
@@ -2451,7 +2459,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
2451 | } | 2459 | } |
2452 | } | 2460 | } |
2453 | // Store this for later in case we get turned into a separate body | 2461 | // Store this for later in case we get turned into a separate body |
2454 | m_angularlock = newLock; | 2462 | m_angularlocks = newLocks; |
2455 | } | 2463 | } |
2456 | 2464 | ||
2457 | private void changeLink(OdePrim NewParent) | 2465 | private void changeLink(OdePrim NewParent) |
@@ -2742,8 +2750,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
2742 | myrot.W = newOri.W; | 2750 | myrot.W = newOri.W; |
2743 | d.GeomSetQuaternion(prim_geom, ref myrot); | 2751 | d.GeomSetQuaternion(prim_geom, ref myrot); |
2744 | _orientation = newOri; | 2752 | _orientation = newOri; |
2745 | if (Body != IntPtr.Zero && !m_angularlock.ApproxEquals(Vector3.One, 0f)) | 2753 | if (Body != IntPtr.Zero && m_angularlocks != 0) |
2746 | createAMotor(m_angularlock); | 2754 | createAMotor(m_angularlocks); |
2747 | } | 2755 | } |
2748 | if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body)) | 2756 | if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body)) |
2749 | { | 2757 | { |
@@ -2795,8 +2803,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
2795 | myrot.W = newOri.W; | 2803 | myrot.W = newOri.W; |
2796 | d.GeomSetQuaternion(prim_geom, ref myrot); | 2804 | d.GeomSetQuaternion(prim_geom, ref myrot); |
2797 | _orientation = newOri; | 2805 | _orientation = newOri; |
2798 | if (Body != IntPtr.Zero && !m_angularlock.ApproxEquals(Vector3.One, 0f)) | 2806 | if (Body != IntPtr.Zero && m_angularlocks != 0) |
2799 | createAMotor(m_angularlock); | 2807 | createAMotor(m_angularlocks); |
2800 | } | 2808 | } |
2801 | if (_position != newPos) | 2809 | if (_position != newPos) |
2802 | { | 2810 | { |
@@ -3805,7 +3813,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
3805 | break; | 3813 | break; |
3806 | 3814 | ||
3807 | case changes.AngLock: | 3815 | case changes.AngLock: |
3808 | changeAngularLock((Vector3)arg); | 3816 | changeAngularLock((byte)arg); |
3809 | break; | 3817 | break; |
3810 | 3818 | ||
3811 | case changes.Size: | 3819 | case changes.Size: |