22 [
Attribute(
"0",
UIWidgets.CheckBox,
"Whether the yaw axis may rotate freely (ignores limits)")]
31 bool m_PitchSetSpring;
32 [
Attribute(
"0",
UIWidgets.CheckBox,
"Whether the pitch axis may rotate freely (ignores limits)")]
42 [
Attribute(
"0",
UIWidgets.CheckBox,
"Whether the roll axis may rotate freely (ignores limits)")]
50 [
Attribute(
"0",
UIWidgets.CheckBox,
"Whether to set spring values along the right axis")]
51 bool m_RightSetSpring;
52 [
Attribute(
"0",
UIWidgets.CheckBox,
"Whether the right axis may move freely (ignores limits)")]
62 [
Attribute(
"0",
UIWidgets.CheckBox,
"Whether the up axis may move freely (ignores limits)")]
70 [
Attribute(
"0",
UIWidgets.CheckBox,
"Whether to set spring values along the forward axis" )]
71 bool m_ForwardSetSpring;
72 [
Attribute(
"0",
UIWidgets.CheckBox,
"Whether the forward axis may move freely (ignores limits)")]
74 [
Attribute(
"0",
UIWidgets.Slider,
"Minimum forward axis range in meters",
"-50 0 0.01")]
76 [
Attribute(
"0",
UIWidgets.Slider,
"Maximum forward axis range in meters",
"0 50 0.01")]
81 float m_SpringStiffness;
82 [
Attribute(
"0.5",
UIWidgets.Slider,
"Damping of the spring, lower values means more damping",
"0 1 0.001")]
83 float m_SpringDamping;
89 override void DebugDisplay()
99 bool noOffsets =
true;
100 if (m_YawIsFree || m_YawMax != 0 || m_YawMin != 0)
102 else if (m_PitchIsFree || m_PitchMax != 0 || m_PitchMin != 0)
104 else if (m_RollIsFree || m_RollMax != 0 || m_RollMin != 0)
106 else if (m_RightIsFree || m_RightMax != 0 || m_RightMin != 0)
108 else if (m_UpIsFree || m_UpMax != 0 || m_UpMin != 0)
110 else if (m_ForwardIsFree || m_ForwardMax != 0 || m_ForwardMin != 0)
123 CreateCircleSlice(pos, axisVec2, axisVec, 1, -1, 0.075,
ARGB(255, 0, 255, 255), 16,
ShapeFlags.ONCE|
ShapeFlags.NOZBUFFER);
126 if (m_YawMin != 0 || m_YawMax != 0)
127 CreateCircleSlice(pos, axisVec2, axisVec, m_YawMin, m_YawMax, 0.075,
ARGB(255, 0, 255, 255),
Math.Ceil(
Math.AbsFloat(m_YawMax - m_YawMin) / 360 * 16),
ShapeFlags.ONCE|
ShapeFlags.NOZBUFFER);
130 CreateCircleSlice(pos, -axisVec, axisVec2, 1, -1, 0.075,
ARGB(255, 0, 255, 255), 16,
ShapeFlags.ONCE|
ShapeFlags.NOZBUFFER);
133 if (m_PitchMin != 0 || m_PitchMax != 0)
134 CreateCircleSlice(pos, -axisVec, axisVec2, m_PitchMin, m_PitchMax, 0.075,
ARGB(255, 0, 255, 255),
Math.Ceil(
Math.AbsFloat(m_PitchMax - m_PitchMin) / 360 * 16),
ShapeFlags.ONCE|
ShapeFlags.NOZBUFFER);
137 CreateCircleSlice(pos, -axisVec3, axisVec, 1, -1, 0.075,
ARGB(255, 0, 255, 255), 16,
ShapeFlags.ONCE|
ShapeFlags.NOZBUFFER);
140 if (m_RollMin != 0 || m_RollMax != 0)
141 CreateCircleSlice(pos, -axisVec3, axisVec, m_RollMin, m_RollMax, 0.075,
ARGB(255, 0, 255, 255),
Math.Ceil(
Math.AbsFloat(m_RollMax - m_RollMin) / 360 * 16),
ShapeFlags.ONCE|
ShapeFlags.NOZBUFFER);
159 float GetSpringScale()
161 float result = (
SCR_Global.g_fPhysicsHz - 60) / 60;
162 result =
Math.Clamp(result, 0, 1);
163 result = 1 - result + 1;
165 result *= m_SpringStiffness * m_SpringStiffness;
171 float GetSpringLinDampScale()
173 return 0.001 * m_SpringDamping;
177 float GetSpringAngDampScale()
179 return 0.001 * m_SpringDamping;
185 bool isSpring =
false;
186 if (m_YawSetSpring || m_PitchSetSpring || m_RollSetSpring || m_RightSetSpring || m_UpSetSpring || m_ForwardSetSpring)
192 m_Joint =
PhysicsJoint.Create6DOFSpring(parent, child, jointMat1, jointMat2, m_CollisionBlocker, -1);
196 if (m_PitchSetSpring)
200 if (m_RightSetSpring)
204 if (m_ForwardSetSpring)
208 m_Joint =
PhysicsJoint.Create6DOF(parent, child, jointMat1, jointMat2, m_CollisionBlocker, -1);