diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 162 |
1 files changed, 92 insertions, 70 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 6a4365c..aeeb4dd 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -46,12 +46,10 @@ public sealed class BSPrim : BSPhysObject | |||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | private static readonly string LogHeader = "[BULLETS PRIM]"; | 47 | private static readonly string LogHeader = "[BULLETS PRIM]"; |
48 | 48 | ||
49 | private PrimitiveBaseShape _pbs; | 49 | // _size is what the user passed. Scale is what we pass to the physics engine with the mesh. |
50 | 50 | // Often Scale is unity because the meshmerizer will apply _size when creating the mesh. | |
51 | // _size is what the user passed. _scale is what we pass to the physics engine with the mesh. | ||
52 | // Often _scale is unity because the meshmerizer will apply _size when creating the mesh. | ||
53 | private OMV.Vector3 _size; // the multiplier for each mesh dimension as passed by the user | 51 | private OMV.Vector3 _size; // the multiplier for each mesh dimension as passed by the user |
54 | private OMV.Vector3 _scale; // the multiplier for each mesh dimension for the mesh as created by the meshmerizer | 52 | // private OMV.Vector3 _scale; // the multiplier for each mesh dimension for the mesh as created by the meshmerizer |
55 | 53 | ||
56 | private bool _grabbed; | 54 | private bool _grabbed; |
57 | private bool _isSelected; | 55 | private bool _isSelected; |
@@ -98,12 +96,12 @@ public sealed class BSPrim : BSPhysObject | |||
98 | _physicsActorType = (int)ActorTypes.Prim; | 96 | _physicsActorType = (int)ActorTypes.Prim; |
99 | _position = pos; | 97 | _position = pos; |
100 | _size = size; | 98 | _size = size; |
101 | _scale = new OMV.Vector3(1f, 1f, 1f); // the scale will be set by CreateGeom depending on object type | 99 | Scale = new OMV.Vector3(1f, 1f, 1f); // the scale will be set by CreateGeom depending on object type |
102 | _orientation = rotation; | 100 | _orientation = rotation; |
103 | _buoyancy = 1f; | 101 | _buoyancy = 1f; |
104 | _velocity = OMV.Vector3.Zero; | 102 | _velocity = OMV.Vector3.Zero; |
105 | _rotationalVelocity = OMV.Vector3.Zero; | 103 | _rotationalVelocity = OMV.Vector3.Zero; |
106 | _pbs = pbs; | 104 | BaseShape = pbs; |
107 | _isPhysical = pisPhysical; | 105 | _isPhysical = pisPhysical; |
108 | _isVolumeDetect = false; | 106 | _isVolumeDetect = false; |
109 | _friction = PhysicsScene.Params.defaultFriction; // TODO: compute based on object material | 107 | _friction = PhysicsScene.Params.defaultFriction; // TODO: compute based on object material |
@@ -160,33 +158,32 @@ public sealed class BSPrim : BSPhysObject | |||
160 | get { return _size; } | 158 | get { return _size; } |
161 | set { | 159 | set { |
162 | _size = value; | 160 | _size = value; |
163 | PhysicsScene.TaintedObject("BSPrim.setSize", delegate() | 161 | ForceBodyShapeRebuild(false); |
164 | { | ||
165 | _mass = CalculateMass(); // changing size changes the mass | ||
166 | // Since _size changed, the mesh needs to be rebuilt. If rebuilt, all the correct | ||
167 | // scale and margins are set. | ||
168 | CreateGeomAndObject(true); | ||
169 | // DetailLog("{0},BSPrim.setSize,size={1},scale={2},mass={3},physical={4}", LocalID, _size, _scale, _mass, IsPhysical); | ||
170 | }); | ||
171 | } | 162 | } |
172 | } | 163 | } |
173 | // Scale is what we set in the physics engine. It is different than 'size' in that | 164 | // Scale is what we set in the physics engine. It is different than 'size' in that |
174 | // 'size' can be encorporated into the mesh. In that case, the scale is <1,1,1>. | 165 | // 'size' can be encorporated into the mesh. In that case, the scale is <1,1,1>. |
175 | public OMV.Vector3 Scale | 166 | public override OMV.Vector3 Scale { get; set; } |
176 | { | 167 | |
177 | get { return _scale; } | ||
178 | set { _scale = value; } | ||
179 | } | ||
180 | public override PrimitiveBaseShape Shape { | 168 | public override PrimitiveBaseShape Shape { |
181 | set { | 169 | set { |
182 | _pbs = value; | 170 | BaseShape = value; |
183 | PhysicsScene.TaintedObject("BSPrim.setShape", delegate() | 171 | ForceBodyShapeRebuild(false); |
184 | { | ||
185 | _mass = CalculateMass(); // changing the shape changes the mass | ||
186 | CreateGeomAndObject(true); | ||
187 | }); | ||
188 | } | 172 | } |
189 | } | 173 | } |
174 | public override bool ForceBodyShapeRebuild(bool inTaintTime) | ||
175 | { | ||
176 | BSScene.TaintCallback rebuildOperation = delegate() | ||
177 | { | ||
178 | _mass = CalculateMass(); // changing the shape changes the mass | ||
179 | CreateGeomAndObject(true); | ||
180 | }; | ||
181 | if (inTaintTime) | ||
182 | rebuildOperation(); | ||
183 | else | ||
184 | PhysicsScene.TaintedObject("BSPrim.ForceBodyShapeRebuild", rebuildOperation); | ||
185 | return true; | ||
186 | } | ||
190 | public override bool Grabbed { | 187 | public override bool Grabbed { |
191 | set { _grabbed = value; | 188 | set { _grabbed = value; |
192 | } | 189 | } |
@@ -325,9 +322,9 @@ public sealed class BSPrim : BSPhysObject | |||
325 | } | 322 | } |
326 | 323 | ||
327 | // A version of the sanity check that also makes sure a new position value is | 324 | // A version of the sanity check that also makes sure a new position value is |
328 | // pushed back to the physics engine. This routine would be used by anyone | 325 | // pushed to the physics engine. This routine would be used by anyone |
329 | // who is not already pushing the value. | 326 | // who is not already pushing the value. |
330 | private bool PositionSanityCheck2(bool inTaintTime) | 327 | private bool PositionSanityCheck(bool inTaintTime) |
331 | { | 328 | { |
332 | bool ret = false; | 329 | bool ret = false; |
333 | if (PositionSanityCheck()) | 330 | if (PositionSanityCheck()) |
@@ -337,7 +334,7 @@ public sealed class BSPrim : BSPhysObject | |||
337 | BSScene.TaintCallback sanityOperation = delegate() | 334 | BSScene.TaintCallback sanityOperation = delegate() |
338 | { | 335 | { |
339 | DetailLog("{0},BSPrim.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation); | 336 | DetailLog("{0},BSPrim.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation); |
340 | BulletSimAPI.SetObjectTranslation(PhysicsScene.WorldID, LocalID, _position, _orientation); | 337 | ForcePosition = _position; |
341 | }; | 338 | }; |
342 | if (inTaintTime) | 339 | if (inTaintTime) |
343 | sanityOperation(); | 340 | sanityOperation(); |
@@ -547,13 +544,13 @@ public sealed class BSPrim : BSPhysObject | |||
547 | } | 544 | } |
548 | 545 | ||
549 | // An object is static (does not move) if selected or not physical | 546 | // An object is static (does not move) if selected or not physical |
550 | private bool IsStatic | 547 | public override bool IsStatic |
551 | { | 548 | { |
552 | get { return _isSelected || !IsPhysical; } | 549 | get { return _isSelected || !IsPhysical; } |
553 | } | 550 | } |
554 | 551 | ||
555 | // An object is solid if it's not phantom and if it's not doing VolumeDetect | 552 | // An object is solid if it's not phantom and if it's not doing VolumeDetect |
556 | public bool IsSolid | 553 | public override bool IsSolid |
557 | { | 554 | { |
558 | get { return !IsPhantom && !_isVolumeDetect; } | 555 | get { return !IsPhantom && !_isVolumeDetect; } |
559 | } | 556 | } |
@@ -631,6 +628,12 @@ public sealed class BSPrim : BSPhysObject | |||
631 | BulletSimAPI.SetMassProps2(BSBody.ptr, 0f, OMV.Vector3.Zero); | 628 | BulletSimAPI.SetMassProps2(BSBody.ptr, 0f, OMV.Vector3.Zero); |
632 | // There is no inertia in a static object | 629 | // There is no inertia in a static object |
633 | BulletSimAPI.UpdateInertiaTensor2(BSBody.ptr); | 630 | BulletSimAPI.UpdateInertiaTensor2(BSBody.ptr); |
631 | // Set collision detection parameters | ||
632 | if (PhysicsScene.Params.ccdMotionThreshold > 0f) | ||
633 | { | ||
634 | BulletSimAPI.SetCcdMotionThreshold2(BSBody.ptr, PhysicsScene.Params.ccdMotionThreshold); | ||
635 | BulletSimAPI.SetCcdSweepSphereRadius2(BSBody.ptr, PhysicsScene.Params.ccdSweptSphereRadius); | ||
636 | } | ||
634 | // There can be special things needed for implementing linksets | 637 | // There can be special things needed for implementing linksets |
635 | Linkset.MakeStatic(this); | 638 | Linkset.MakeStatic(this); |
636 | // The activation state is 'disabled' so Bullet will not try to act on it. | 639 | // The activation state is 'disabled' so Bullet will not try to act on it. |
@@ -662,6 +665,13 @@ public sealed class BSPrim : BSPhysObject | |||
662 | BulletSimAPI.SetMassProps2(BSBody.ptr, _mass, inertia); | 665 | BulletSimAPI.SetMassProps2(BSBody.ptr, _mass, inertia); |
663 | BulletSimAPI.UpdateInertiaTensor2(BSBody.ptr); | 666 | BulletSimAPI.UpdateInertiaTensor2(BSBody.ptr); |
664 | 667 | ||
668 | // Set collision detection parameters | ||
669 | if (PhysicsScene.Params.ccdMotionThreshold > 0f) | ||
670 | { | ||
671 | BulletSimAPI.SetCcdMotionThreshold2(BSBody.ptr, PhysicsScene.Params.ccdMotionThreshold); | ||
672 | BulletSimAPI.SetCcdSweepSphereRadius2(BSBody.ptr, PhysicsScene.Params.ccdSweptSphereRadius); | ||
673 | } | ||
674 | |||
665 | // Various values for simulation limits | 675 | // Various values for simulation limits |
666 | BulletSimAPI.SetDamping2(BSBody.ptr, PhysicsScene.Params.linearDamping, PhysicsScene.Params.angularDamping); | 676 | BulletSimAPI.SetDamping2(BSBody.ptr, PhysicsScene.Params.linearDamping, PhysicsScene.Params.angularDamping); |
667 | BulletSimAPI.SetDeactivationTime2(BSBody.ptr, PhysicsScene.Params.deactivationTime); | 677 | BulletSimAPI.SetDeactivationTime2(BSBody.ptr, PhysicsScene.Params.deactivationTime); |
@@ -813,13 +823,20 @@ public sealed class BSPrim : BSPhysObject | |||
813 | _buoyancy = value; | 823 | _buoyancy = value; |
814 | PhysicsScene.TaintedObject("BSPrim.setBuoyancy", delegate() | 824 | PhysicsScene.TaintedObject("BSPrim.setBuoyancy", delegate() |
815 | { | 825 | { |
816 | // DetailLog("{0},BSPrim.SetBuoyancy,taint,buoy={1}", LocalID, _buoyancy); | 826 | ForceBuoyancy = _buoyancy; |
817 | // Buoyancy is faked by changing the gravity applied to the object | ||
818 | float grav = PhysicsScene.Params.gravity * (1f - _buoyancy); | ||
819 | BulletSimAPI.SetGravity2(BSBody.ptr, new OMV.Vector3(0f, 0f, grav)); | ||
820 | }); | 827 | }); |
821 | } | 828 | } |
822 | } | 829 | } |
830 | public override float ForceBuoyancy { | ||
831 | get { return _buoyancy; } | ||
832 | set { | ||
833 | _buoyancy = value; | ||
834 | // DetailLog("{0},BSPrim.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy); | ||
835 | // Buoyancy is faked by changing the gravity applied to the object | ||
836 | float grav = PhysicsScene.Params.gravity * (1f - _buoyancy); | ||
837 | BulletSimAPI.SetGravity2(BSBody.ptr, new OMV.Vector3(0f, 0f, grav)); | ||
838 | } | ||
839 | } | ||
823 | 840 | ||
824 | // Used for MoveTo | 841 | // Used for MoveTo |
825 | public override OMV.Vector3 PIDTarget { | 842 | public override OMV.Vector3 PIDTarget { |
@@ -907,19 +924,19 @@ public sealed class BSPrim : BSPhysObject | |||
907 | float tmp; | 924 | float tmp; |
908 | 925 | ||
909 | float returnMass = 0; | 926 | float returnMass = 0; |
910 | float hollowAmount = (float)_pbs.ProfileHollow * 2.0e-5f; | 927 | float hollowAmount = (float)BaseShape.ProfileHollow * 2.0e-5f; |
911 | float hollowVolume = hollowAmount * hollowAmount; | 928 | float hollowVolume = hollowAmount * hollowAmount; |
912 | 929 | ||
913 | switch (_pbs.ProfileShape) | 930 | switch (BaseShape.ProfileShape) |
914 | { | 931 | { |
915 | case ProfileShape.Square: | 932 | case ProfileShape.Square: |
916 | // default box | 933 | // default box |
917 | 934 | ||
918 | if (_pbs.PathCurve == (byte)Extrusion.Straight) | 935 | if (BaseShape.PathCurve == (byte)Extrusion.Straight) |
919 | { | 936 | { |
920 | if (hollowAmount > 0.0) | 937 | if (hollowAmount > 0.0) |
921 | { | 938 | { |
922 | switch (_pbs.HollowShape) | 939 | switch (BaseShape.HollowShape) |
923 | { | 940 | { |
924 | case HollowShape.Square: | 941 | case HollowShape.Square: |
925 | case HollowShape.Same: | 942 | case HollowShape.Same: |
@@ -943,19 +960,19 @@ public sealed class BSPrim : BSPhysObject | |||
943 | } | 960 | } |
944 | } | 961 | } |
945 | 962 | ||
946 | else if (_pbs.PathCurve == (byte)Extrusion.Curve1) | 963 | else if (BaseShape.PathCurve == (byte)Extrusion.Curve1) |
947 | { | 964 | { |
948 | //a tube | 965 | //a tube |
949 | 966 | ||
950 | volume *= 0.78539816339e-2f * (float)(200 - _pbs.PathScaleX); | 967 | volume *= 0.78539816339e-2f * (float)(200 - BaseShape.PathScaleX); |
951 | tmp= 1.0f -2.0e-2f * (float)(200 - _pbs.PathScaleY); | 968 | tmp= 1.0f -2.0e-2f * (float)(200 - BaseShape.PathScaleY); |
952 | volume -= volume*tmp*tmp; | 969 | volume -= volume*tmp*tmp; |
953 | 970 | ||
954 | if (hollowAmount > 0.0) | 971 | if (hollowAmount > 0.0) |
955 | { | 972 | { |
956 | hollowVolume *= hollowAmount; | 973 | hollowVolume *= hollowAmount; |
957 | 974 | ||
958 | switch (_pbs.HollowShape) | 975 | switch (BaseShape.HollowShape) |
959 | { | 976 | { |
960 | case HollowShape.Square: | 977 | case HollowShape.Square: |
961 | case HollowShape.Same: | 978 | case HollowShape.Same: |
@@ -980,13 +997,13 @@ public sealed class BSPrim : BSPhysObject | |||
980 | 997 | ||
981 | case ProfileShape.Circle: | 998 | case ProfileShape.Circle: |
982 | 999 | ||
983 | if (_pbs.PathCurve == (byte)Extrusion.Straight) | 1000 | if (BaseShape.PathCurve == (byte)Extrusion.Straight) |
984 | { | 1001 | { |
985 | volume *= 0.78539816339f; // elipse base | 1002 | volume *= 0.78539816339f; // elipse base |
986 | 1003 | ||
987 | if (hollowAmount > 0.0) | 1004 | if (hollowAmount > 0.0) |
988 | { | 1005 | { |
989 | switch (_pbs.HollowShape) | 1006 | switch (BaseShape.HollowShape) |
990 | { | 1007 | { |
991 | case HollowShape.Same: | 1008 | case HollowShape.Same: |
992 | case HollowShape.Circle: | 1009 | case HollowShape.Circle: |
@@ -1008,10 +1025,10 @@ public sealed class BSPrim : BSPhysObject | |||
1008 | } | 1025 | } |
1009 | } | 1026 | } |
1010 | 1027 | ||
1011 | else if (_pbs.PathCurve == (byte)Extrusion.Curve1) | 1028 | else if (BaseShape.PathCurve == (byte)Extrusion.Curve1) |
1012 | { | 1029 | { |
1013 | volume *= 0.61685027506808491367715568749226e-2f * (float)(200 - _pbs.PathScaleX); | 1030 | volume *= 0.61685027506808491367715568749226e-2f * (float)(200 - BaseShape.PathScaleX); |
1014 | tmp = 1.0f - .02f * (float)(200 - _pbs.PathScaleY); | 1031 | tmp = 1.0f - .02f * (float)(200 - BaseShape.PathScaleY); |
1015 | volume *= (1.0f - tmp * tmp); | 1032 | volume *= (1.0f - tmp * tmp); |
1016 | 1033 | ||
1017 | if (hollowAmount > 0.0) | 1034 | if (hollowAmount > 0.0) |
@@ -1020,7 +1037,7 @@ public sealed class BSPrim : BSPhysObject | |||
1020 | // calculate the hollow volume by it's shape compared to the prim shape | 1037 | // calculate the hollow volume by it's shape compared to the prim shape |
1021 | hollowVolume *= hollowAmount; | 1038 | hollowVolume *= hollowAmount; |
1022 | 1039 | ||
1023 | switch (_pbs.HollowShape) | 1040 | switch (BaseShape.HollowShape) |
1024 | { | 1041 | { |
1025 | case HollowShape.Same: | 1042 | case HollowShape.Same: |
1026 | case HollowShape.Circle: | 1043 | case HollowShape.Circle: |
@@ -1044,7 +1061,7 @@ public sealed class BSPrim : BSPhysObject | |||
1044 | break; | 1061 | break; |
1045 | 1062 | ||
1046 | case ProfileShape.HalfCircle: | 1063 | case ProfileShape.HalfCircle: |
1047 | if (_pbs.PathCurve == (byte)Extrusion.Curve1) | 1064 | if (BaseShape.PathCurve == (byte)Extrusion.Curve1) |
1048 | { | 1065 | { |
1049 | volume *= 0.52359877559829887307710723054658f; | 1066 | volume *= 0.52359877559829887307710723054658f; |
1050 | } | 1067 | } |
@@ -1052,7 +1069,7 @@ public sealed class BSPrim : BSPhysObject | |||
1052 | 1069 | ||
1053 | case ProfileShape.EquilateralTriangle: | 1070 | case ProfileShape.EquilateralTriangle: |
1054 | 1071 | ||
1055 | if (_pbs.PathCurve == (byte)Extrusion.Straight) | 1072 | if (BaseShape.PathCurve == (byte)Extrusion.Straight) |
1056 | { | 1073 | { |
1057 | volume *= 0.32475953f; | 1074 | volume *= 0.32475953f; |
1058 | 1075 | ||
@@ -1060,7 +1077,7 @@ public sealed class BSPrim : BSPhysObject | |||
1060 | { | 1077 | { |
1061 | 1078 | ||
1062 | // calculate the hollow volume by it's shape compared to the prim shape | 1079 | // calculate the hollow volume by it's shape compared to the prim shape |
1063 | switch (_pbs.HollowShape) | 1080 | switch (BaseShape.HollowShape) |
1064 | { | 1081 | { |
1065 | case HollowShape.Same: | 1082 | case HollowShape.Same: |
1066 | case HollowShape.Triangle: | 1083 | case HollowShape.Triangle: |
@@ -1085,11 +1102,11 @@ public sealed class BSPrim : BSPhysObject | |||
1085 | volume *= (1.0f - hollowVolume); | 1102 | volume *= (1.0f - hollowVolume); |
1086 | } | 1103 | } |
1087 | } | 1104 | } |
1088 | else if (_pbs.PathCurve == (byte)Extrusion.Curve1) | 1105 | else if (BaseShape.PathCurve == (byte)Extrusion.Curve1) |
1089 | { | 1106 | { |
1090 | volume *= 0.32475953f; | 1107 | volume *= 0.32475953f; |
1091 | volume *= 0.01f * (float)(200 - _pbs.PathScaleX); | 1108 | volume *= 0.01f * (float)(200 - BaseShape.PathScaleX); |
1092 | tmp = 1.0f - .02f * (float)(200 - _pbs.PathScaleY); | 1109 | tmp = 1.0f - .02f * (float)(200 - BaseShape.PathScaleY); |
1093 | volume *= (1.0f - tmp * tmp); | 1110 | volume *= (1.0f - tmp * tmp); |
1094 | 1111 | ||
1095 | if (hollowAmount > 0.0) | 1112 | if (hollowAmount > 0.0) |
@@ -1097,7 +1114,7 @@ public sealed class BSPrim : BSPhysObject | |||
1097 | 1114 | ||
1098 | hollowVolume *= hollowAmount; | 1115 | hollowVolume *= hollowAmount; |
1099 | 1116 | ||
1100 | switch (_pbs.HollowShape) | 1117 | switch (BaseShape.HollowShape) |
1101 | { | 1118 | { |
1102 | case HollowShape.Same: | 1119 | case HollowShape.Same: |
1103 | case HollowShape.Triangle: | 1120 | case HollowShape.Triangle: |
@@ -1137,26 +1154,26 @@ public sealed class BSPrim : BSPhysObject | |||
1137 | float profileBegin; | 1154 | float profileBegin; |
1138 | float profileEnd; | 1155 | float profileEnd; |
1139 | 1156 | ||
1140 | if (_pbs.PathCurve == (byte)Extrusion.Straight || _pbs.PathCurve == (byte)Extrusion.Flexible) | 1157 | if (BaseShape.PathCurve == (byte)Extrusion.Straight || BaseShape.PathCurve == (byte)Extrusion.Flexible) |
1141 | { | 1158 | { |
1142 | taperX1 = _pbs.PathScaleX * 0.01f; | 1159 | taperX1 = BaseShape.PathScaleX * 0.01f; |
1143 | if (taperX1 > 1.0f) | 1160 | if (taperX1 > 1.0f) |
1144 | taperX1 = 2.0f - taperX1; | 1161 | taperX1 = 2.0f - taperX1; |
1145 | taperX = 1.0f - taperX1; | 1162 | taperX = 1.0f - taperX1; |
1146 | 1163 | ||
1147 | taperY1 = _pbs.PathScaleY * 0.01f; | 1164 | taperY1 = BaseShape.PathScaleY * 0.01f; |
1148 | if (taperY1 > 1.0f) | 1165 | if (taperY1 > 1.0f) |
1149 | taperY1 = 2.0f - taperY1; | 1166 | taperY1 = 2.0f - taperY1; |
1150 | taperY = 1.0f - taperY1; | 1167 | taperY = 1.0f - taperY1; |
1151 | } | 1168 | } |
1152 | else | 1169 | else |
1153 | { | 1170 | { |
1154 | taperX = _pbs.PathTaperX * 0.01f; | 1171 | taperX = BaseShape.PathTaperX * 0.01f; |
1155 | if (taperX < 0.0f) | 1172 | if (taperX < 0.0f) |
1156 | taperX = -taperX; | 1173 | taperX = -taperX; |
1157 | taperX1 = 1.0f - taperX; | 1174 | taperX1 = 1.0f - taperX; |
1158 | 1175 | ||
1159 | taperY = _pbs.PathTaperY * 0.01f; | 1176 | taperY = BaseShape.PathTaperY * 0.01f; |
1160 | if (taperY < 0.0f) | 1177 | if (taperY < 0.0f) |
1161 | taperY = -taperY; | 1178 | taperY = -taperY; |
1162 | taperY1 = 1.0f - taperY; | 1179 | taperY1 = 1.0f - taperY; |
@@ -1166,13 +1183,13 @@ public sealed class BSPrim : BSPhysObject | |||
1166 | 1183 | ||
1167 | volume *= (taperX1 * taperY1 + 0.5f * (taperX1 * taperY + taperX * taperY1) + 0.3333333333f * taperX * taperY); | 1184 | volume *= (taperX1 * taperY1 + 0.5f * (taperX1 * taperY + taperX * taperY1) + 0.3333333333f * taperX * taperY); |
1168 | 1185 | ||
1169 | pathBegin = (float)_pbs.PathBegin * 2.0e-5f; | 1186 | pathBegin = (float)BaseShape.PathBegin * 2.0e-5f; |
1170 | pathEnd = 1.0f - (float)_pbs.PathEnd * 2.0e-5f; | 1187 | pathEnd = 1.0f - (float)BaseShape.PathEnd * 2.0e-5f; |
1171 | volume *= (pathEnd - pathBegin); | 1188 | volume *= (pathEnd - pathBegin); |
1172 | 1189 | ||
1173 | // this is crude aproximation | 1190 | // this is crude aproximation |
1174 | profileBegin = (float)_pbs.ProfileBegin * 2.0e-5f; | 1191 | profileBegin = (float)BaseShape.ProfileBegin * 2.0e-5f; |
1175 | profileEnd = 1.0f - (float)_pbs.ProfileEnd * 2.0e-5f; | 1192 | profileEnd = 1.0f - (float)BaseShape.ProfileEnd * 2.0e-5f; |
1176 | volume *= (profileEnd - profileBegin); | 1193 | volume *= (profileEnd - profileBegin); |
1177 | 1194 | ||
1178 | returnMass = _density * volume; | 1195 | returnMass = _density * volume; |
@@ -1207,7 +1224,8 @@ public sealed class BSPrim : BSPhysObject | |||
1207 | shape.Position = _position; | 1224 | shape.Position = _position; |
1208 | shape.Rotation = _orientation; | 1225 | shape.Rotation = _orientation; |
1209 | shape.Velocity = _velocity; | 1226 | shape.Velocity = _velocity; |
1210 | shape.Scale = _scale; | 1227 | shape.Size = _size; |
1228 | shape.Scale = Scale; | ||
1211 | shape.Mass = _isPhysical ? _mass : 0f; | 1229 | shape.Mass = _isPhysical ? _mass : 0f; |
1212 | shape.Buoyancy = _buoyancy; | 1230 | shape.Buoyancy = _buoyancy; |
1213 | shape.HullKey = 0; | 1231 | shape.HullKey = 0; |
@@ -1217,7 +1235,6 @@ public sealed class BSPrim : BSPhysObject | |||
1217 | shape.Collidable = (!IsPhantom) ? ShapeData.numericTrue : ShapeData.numericFalse; | 1235 | shape.Collidable = (!IsPhantom) ? ShapeData.numericTrue : ShapeData.numericFalse; |
1218 | shape.Static = _isPhysical ? ShapeData.numericFalse : ShapeData.numericTrue; | 1236 | shape.Static = _isPhysical ? ShapeData.numericFalse : ShapeData.numericTrue; |
1219 | shape.Solid = IsSolid ? ShapeData.numericFalse : ShapeData.numericTrue; | 1237 | shape.Solid = IsSolid ? ShapeData.numericFalse : ShapeData.numericTrue; |
1220 | shape.Size = _size; | ||
1221 | } | 1238 | } |
1222 | // Rebuild the geometry and object. | 1239 | // Rebuild the geometry and object. |
1223 | // This is called when the shape changes so we need to recreate the mesh/hull. | 1240 | // This is called when the shape changes so we need to recreate the mesh/hull. |
@@ -1234,7 +1251,7 @@ public sealed class BSPrim : BSPhysObject | |||
1234 | // Create the correct physical representation for this type of object. | 1251 | // Create the correct physical representation for this type of object. |
1235 | // Updates BSBody and BSShape with the new information. | 1252 | // Updates BSBody and BSShape with the new information. |
1236 | // Ignore 'forceRebuild'. This routine makes the right choices and changes of necessary. | 1253 | // Ignore 'forceRebuild'. This routine makes the right choices and changes of necessary. |
1237 | PhysicsScene.Shapes.GetBodyAndShape(false, PhysicsScene.World, this, shapeData, _pbs, | 1254 | PhysicsScene.Shapes.GetBodyAndShape(false, PhysicsScene.World, this, shapeData, BaseShape, |
1238 | null, delegate(BulletBody dBody) | 1255 | null, delegate(BulletBody dBody) |
1239 | { | 1256 | { |
1240 | // Called if the current prim body is about to be destroyed. | 1257 | // Called if the current prim body is about to be destroyed. |
@@ -1328,9 +1345,11 @@ public sealed class BSPrim : BSPhysObject | |||
1328 | _acceleration = entprop.Acceleration; | 1345 | _acceleration = entprop.Acceleration; |
1329 | _rotationalVelocity = entprop.RotationalVelocity; | 1346 | _rotationalVelocity = entprop.RotationalVelocity; |
1330 | 1347 | ||
1331 | PositionSanityCheck2(true); | 1348 | // remember the current and last set values |
1349 | LastEntityProperties = CurrentEntityProperties; | ||
1350 | CurrentEntityProperties = entprop; | ||
1332 | 1351 | ||
1333 | Linkset.UpdateProperties(this); | 1352 | PositionSanityCheck(true); |
1334 | 1353 | ||
1335 | DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", | 1354 | DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", |
1336 | LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity); | 1355 | LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity); |
@@ -1348,6 +1367,9 @@ public sealed class BSPrim : BSPhysObject | |||
1348 | entprop.Acceleration, entprop.RotationalVelocity); | 1367 | entprop.Acceleration, entprop.RotationalVelocity); |
1349 | } | 1368 | } |
1350 | */ | 1369 | */ |
1370 | // The linkset implimentation might want to know about this. | ||
1371 | |||
1372 | Linkset.UpdateProperties(this); | ||
1351 | } | 1373 | } |
1352 | } | 1374 | } |
1353 | } | 1375 | } |