8
8
// Jumpjets stuck at FireError::FACING because Jumpjet has its own facing just for JumpjetTurnRate
9
9
// We should not touch the linked unit's PrimaryFacing when it's moving and just let the loco sync this shit in 54D692
10
10
// The body facing never actually turns, it just syncs
11
+ // Whatever, now let's totally forget PrimaryFacing and only use that loco facing
11
12
DEFINE_HOOK (0x736F78 , UnitClass_UpdateFiring_FireErrorIsFACING, 0x6 )
12
13
{
13
14
GET (UnitClass* const , pThis, ESI);
@@ -176,7 +177,7 @@ DEFINE_HOOK(0x70B649, TechnoClass_RigidBodyDynamics_NoTiltCrashBlyat, 0x6)
176
177
}
177
178
178
179
// Just rewrite this completely to avoid headache
179
- Matrix3D* __stdcall JumpjetLocomotionClass_Draw_Matrix (ILocomotion* iloco, Matrix3D* ret, VoxelIndexKey * pIndex)
180
+ Matrix3D* __stdcall JumpjetLocomotionClass_Draw_Matrix (ILocomotion* iloco, Matrix3D* ret, int * pIndex)
180
181
{
181
182
__assume (iloco != nullptr );
182
183
auto const pThis = static_cast <JumpjetLocomotionClass*>(iloco);
@@ -185,19 +186,15 @@ Matrix3D* __stdcall JumpjetLocomotionClass_Draw_Matrix(ILocomotion* iloco, Matri
185
186
bool const onGround = pThis->State == JumpjetLocomotionClass::State::Grounded;
186
187
// Man, what can I say, you don't want to stick your rotor into the ground
187
188
auto slope_idx = MapClass::Instance->GetCellAt (linked->Location )->SlopeIndex ;
188
-
189
- if (onGround && pIndex && pIndex->Is_Valid_Key ())
190
- *(int *)(pIndex) = slope_idx + (*(int *)(pIndex) << 6 );
191
-
192
- *ret = Matrix3D::VoxelRampMatrix[onGround ? slope_idx : 0 ] * pThis->LocomotionClass ::Draw_Matrix (pIndex);
193
-
189
+ *ret = Matrix3D::VoxelRampMatrix[onGround ? slope_idx : 0 ];
190
+ auto curf = pThis->LocomotionFacing .Current ();
191
+ ret->RotateZ ((float )curf.GetRadian <32 >());
194
192
float arf = linked->AngleRotatedForwards ;
195
193
float ars = linked->AngleRotatedSideways ;
196
194
197
195
if (std::abs (ars) >= 0.005 || std::abs (arf) >= 0.005 )
198
196
{
199
- if (pIndex)
200
- pIndex->Invalidate ();
197
+ if (pIndex) *pIndex = -1 ;
201
198
202
199
if (onGround)
203
200
{
@@ -218,6 +215,14 @@ Matrix3D* __stdcall JumpjetLocomotionClass_Draw_Matrix(ILocomotion* iloco, Matri
218
215
ret->RotateY (arf);
219
216
}
220
217
}
218
+
219
+ if (pIndex && *pIndex != -1 )
220
+ {
221
+ if (onGround) *pIndex = slope_idx + (*pIndex << 6 );
222
+ *pIndex *= 32 ;
223
+ *pIndex |= curf.GetFacing <32 >();
224
+ }
225
+
221
226
return ret;
222
227
}
223
228
0 commit comments