@@ -300,48 +300,224 @@ struct VoxelCacheStruct
300300 void * Buffer;
301301};
302302
303+ /*
304+ ----------------------------------------------------------------------------------------------------
305+ > Jul 13, 2025 - CrimRecya
306+ > How does WW generate a VoxelIndexKey:
307+ ----------------------------------------------------------------------------------------------------
308+
309+ ----------------------------------------------------------------------------------------------------
310+ > Unit:
311+ >
312+ > 0x73B59D : key = Game::bVPLRead - 1;
313+ > ···· ···· ···· ···· ···· ···· ···· ····
314+ >
315+ > 0x73B5CB : loco->Draw_Matrix(&mtx, &key);
316+ > Drive/Ship/Teleport/Hover(!Powered)/Jumpjet(!State)/Tunnel(!State) ···· ···· ···· ···· ···· ·rrr rrrb bbbb
317+ > Hover(Powered)/Jumpjet(State)/DropPod/Mech/Walk ···· ···· ···· ···· ···· ·000 000b bbbb
318+ > Tunnel(State) ···· ···· ···· ···· ···b bbbb 00dd dddd
319+ > Fly ···· ···· ···· ···· ···· ···· bbbb bplr
320+ > Rocket ···· ···· ···· ···· ···· ···· ·fib bbbb
321+ >
322+ > 0x73B607 : key = (((this->WalkedFramesSoFar % Type->MainVoxel.HVA->FrameCount) & 0x1F) | (key << 5));
323+ > Drive/Ship/Teleport/Hover(!Powered)/Jumpjet(!State)/Tunnel(!State) ···· ···· ···· ···· rrrr rrbb bbbf ffff
324+ > Hover(Powered)/Jumpjet(State)/DropPod/Mech/Walk ···· ···· ···· ···· 0000 00bb bbbf ffff
325+ > Tunnel(State) ···· ···· ···· ··bb bbb0 0ddd dddf ffff
326+ > Fly ···· ···· ···· ···· ···b bbbb plrf ffff
327+ > Rocket ···· ···· ···· ···· ···· fibb bbbf ffff
328+ >
329+ > 0x73B6AA : key = key | (1 << 16); (if (this->Type->NoSpawnAlt && !this->SpawnManager->CountDockedSpawns()))
330+ > Drive/Ship/Teleport/Hover(!Powered)/Jumpjet(!State)/Tunnel(!State) ···· ···· ···· ···a rrrr rrbb bbbf ffff
331+ > Hover(Powered)/Jumpjet(State)/DropPod/Mech/Walk ···· ···· ···· ···a 0000 00bb bbbf ffff
332+ > Tunnel(State) ···· ···· ···· ··b? bbb0 0ddd dddf ffff
333+ > Fly ···· ···· ···· ···a ···b bbbb plrf ffff
334+ > Rocket ···· ···· ···· ···a ···· fibb bbbf ffff
335+ >
336+ > Obtain main result
337+ >
338+ > Draw main
339+ >
340+ > 0x73B778 : key = (this->SecondaryFacing.Current().GetFacing<32>() | (key & ~0x1F));
341+ > Drive/Ship/Teleport/Hover(!Powered)/Jumpjet(!State)/Tunnel(!State) ···· ···· ···· ···· rrrr rrbb bbbt tttt
342+ > Hover(Powered)/Jumpjet(State)/DropPod/Mech/Walk ···· ···· ···· ···· 0000 00bb bbbt tttt
343+ > Tunnel(State) ···· ···· ···· ··bb bbb0 0ddd dddt tttt
344+ > Fly ···· ···· ···· ···· ···b bbbb plrt tttt
345+ > Rocket ···· ···· ···· ···· ···· fibb bbbt tttt
346+ >
347+ > 0x73B78A : key = key & ~0x3E0; (if (!this->Type->TurretOffset))
348+ > Drive/Ship/Teleport/Hover(!Powered)/Jumpjet(!State)/Tunnel(!State) ···· ···· ···· ···· rrrr rr00 000t tttt
349+ > Hover(Powered)/Jumpjet(State)/DropPod/Mech/Walk ···· ···· ···· ···· 0000 0000 000t tttt
350+ > Tunnel(State) ···· ···· ···· ··bb bbb0 0d?? ???t tttt
351+ > Fly ···· ···· ···· ···· ···b bb?? ???t tttt
352+ > Rocket ···· ···· ···· ···· ···· fi00 000t tttt
353+ >
354+ > 0x73B79F : key = key | ((this->TurretAnimFrame % Type->TurretVoxel.HVA->FrameCount) << 16);
355+ > Drive/Ship/Teleport/Hover(!Powered)/Jumpjet(!State)/Tunnel(!State) ···· ···· iiii iiii rrrr rrbb bbbt tttt
356+ > Hover(Powered)/Jumpjet(State)/DropPod/Mech/Walk ···· ···· iiii iiii 0000 00bb bbbt tttt
357+ > Tunnel(State) ···· ···· iiii ii?? bbb0 0ddd dddt tttt
358+ > Fly ···· ···· iiii iiii ···b bbbb plrt tttt
359+ > Rocket ···· ···· iiii iiii ···· fibb bbbt tttt
360+ >
361+ > Draw barrel if no turret
362+ >
363+ > 0x73B917 : key = key | (this->CurrentTurretNumber << 24);
364+ > Drive/Ship/Teleport/Hover(!Powered)/Jumpjet(!State)/Tunnel(!State) cccc cccc iiii iiii rrrr rrbb bbbt tttt
365+ > Hover(Powered)/Jumpjet(State)/DropPod/Mech/Walk cccc cccc iiii iiii 0000 00bb bbbt tttt
366+ > Tunnel(State) cccc cccc iiii ii?? bbb0 0ddd dddt tttt
367+ > Fly cccc cccc iiii iiii ···b bbbb plrt tttt
368+ > Rocket cccc cccc iiii iiii ···· fibb bbbt tttt
369+ >
370+ > Obtain minor result
371+ >
372+ > Draw minor
373+ >
374+ > ... Then shadow ...
375+ ----------------------------------------------------------------------------------------------------
376+
377+ ----------------------------------------------------------------------------------------------------
378+ > Aircraft:
379+ >
380+ > 0x41470F : key = 0;
381+ > ···· ···· ···· ···· ···· ···· ···· ····
382+ >
383+ > ... Draw Shadow ...
384+ >
385+ > 0x414943 : key = ((this->WalkedFramesSoFar % Type->MainVoxel.HVA->FrameCount) & 0x1F);
386+ > ···· ···· ···· ···· ···· ···· ···f ffff
387+ >
388+ > 0x414969 : loco->Draw_Matrix(&mtx, &key);
389+ > Drive/Ship/Teleport/Hover(!Powered)/Jumpjet(!State)/Tunnel(!State) ···· ···· ···· ···· ffff frrr rrrb bbbb
390+ > Hover(Powered)/Jumpjet(State)/DropPod/Mech/Walk ···· ···· ···· ···· ffff f000 000b bbbb
391+ > Tunnel(State) ···· ···· ···· ··ff fffb bbbb 00dd dddd
392+ > Fly ···· ···· ···· ···· ···· ···· bbb? ????
393+ > Rocket ···· ···· ···· ···· ···· ···· ·fi? ????
394+ >
395+ > Obtain main result
396+ >
397+ > Draw main
398+ ----------------------------------------------------------------------------------------------------
399+
400+ ----------------------------------------------------------------------------------------------------
401+ > Draw_Matrix:
402+ >
403+ > Drive/Ship/Teleport/Hover/Jumpjet/Tunnel(!State)/DropPod/Mech/Walk: <<= 6 , += , <<= 5 , |=
404+ >
405+ > Tunnel(State) <<= 5 , |= , <<= 8 , |=
406+ >
407+ > Fly/Rocket: |= , |= (No shift)
408+ >
409+ > Return
410+ ----------------------------------------------------------------------------------------------------
411+ */
412+
303413struct MainVoxelIndexKey
304414{
305- public:
415+ /*
416+ pUnit->WalkedFramesSoFar % pType->MainVoxel.HVA->FrameCount
417+ */
306418 unsigned FrameIndex : 5 ;
307- unsigned RampType : 5 ;
308- private:
309- unsigned bitfield_10 : 6 ;
310- public:
311- unsigned UseAuxVoxel : 1 ; // !(!pUnit->Type->NoSpawnAlt || pUnit->SpawnManager->Draw_State())
312- private:
313- unsigned bitfield_17 : 15 ;
419+
420+ /*
421+ pUnit->PrimaryFacing.Current().GetFacing<32>()
422+ */
423+ unsigned BodyFacing : 5 ;
424+
425+ /*
426+ Drive : Loco->Ramp
427+ Ship : Loco->Ramp
428+ Hover (!loco->Is_Powered()): pUnit->GetCell()->SlopeIndex
429+ Jumpjet (!loco->State): pUnit->GetCell()->SlopeIndex
430+ Tunnel (!loco->State): pUnit->GetCell()->SlopeIndex
431+ Teleport (Fixed) : pUnit->GetCell()->SlopeIndex
432+ DropPod / Mech / Walk : Not set
433+ */
434+ unsigned RampType : 6 ;
435+
436+ /*
437+ pUnit->Type->NoSpawnAlt && !pUnit->SpawnManager->CountDockedSpawns()
438+ */
439+ unsigned AuxVoxel : 1 ;
440+
441+ /*
442+ No use
443+ */
444+ unsigned Reserved : 15 ;
314445};
315446
316- struct TurretWeaponVoxelIndexKey
447+ struct MinorVoxelIndexKey
317448{
318- public:
319- unsigned Facing : 5 ;
320- unsigned HasTurretOffset : 5 ;
321- private:
322- unsigned bitfield_10 : 6 ;
323- public:
324- unsigned FrameIndex : 8 ;
449+ /*
450+ pUnit->SecondaryFacing.Current().GetFacing<32>()
451+ */
452+ unsigned TurretFacing : 5 ;
453+
454+ /*
455+ Inherit from MainVoxelIndexKey
456+
457+ Reset to 0 if TurretOffset=0
458+ */
459+ unsigned BodyFacing : 5 ;
460+
461+ /*
462+ Inherit from MainVoxelIndexKey
463+ */
464+ unsigned RampType : 6 ;
465+
466+ /*
467+ pUnit->TurretAnimFrame % pType->TurretVoxel.HVA->FrameCount
468+
469+ Not set if have MainVoxelIndexKey.FrameIndex
470+ */
471+ unsigned TurretFrameIndex : 8 ;
472+
473+ /*
474+ pUnit->CurrentTurretNumber
475+
476+ Not set if no turret but have barrel
477+ */
325478 unsigned TurretWeaponIndex : 8 ;
326479};
327480
328- struct ShadowVoxelIndexKey
481+ struct AircraftVoxelIndexKey
329482{
330- public:
331- unsigned Data : 32 ;
483+ unsigned BodyFacing : 5 ;
484+ unsigned RampType : 6 ;
485+ unsigned FrameIndex : 5 ;
486+ unsigned Reserved : 16 ;
332487};
333488
334- struct TurretBarrelVoxelIndexKey
489+ struct FlyVoxelIndexKey
490+ {
491+ unsigned FrameIndex : 5 ;
492+ unsigned RollRight : 1 ;
493+ unsigned RollLeft : 1 ;
494+ unsigned PitchState : 1 ;
495+ unsigned BodyFacing : 5 ;
496+ unsigned Reserved : 19 ;
497+ };
498+
499+ struct RocketVoxelIndexKey
500+ {
501+ unsigned FrameIndex : 5 ;
502+ unsigned BodyFacing : 5 ;
503+ unsigned InitialPitch : 1 ;
504+ unsigned FinalPitch : 1 ;
505+ unsigned Reserved : 20 ;
506+ };
507+
508+ struct TunnelVoxelIndexKey
509+ {
510+ unsigned FrameIndex : 5 ;
511+ unsigned DigState : 6 ;
512+ unsigned Empty : 2 ;
513+ unsigned BodyFacing : 5 ;
514+ unsigned Reserved : 14 ;
515+ };
516+
517+ struct ShadowVoxelIndexKey
335518{
336519public:
337- unsigned Facing : 5 ;
338- unsigned HasTurretOffset : 5 ;
339- private:
340- unsigned bitfield_10 : 6 ;
341- public:
342- unsigned FrameIndex : 8 ;
343- private:
344- unsigned bitfield_24 : 8 ;
520+ unsigned Data : 32 ;
345521};
346522
347523struct ReservedVoxelIndexKey
@@ -376,12 +552,14 @@ union VoxelIndexKey
376552 Value = -1 ;
377553 }
378554
379- MainVoxelIndexKey MainVoxel;
380- TurretWeaponVoxelIndexKey TurretWeapon;
555+ MainVoxelIndexKey MainVoxel; // (Unit) For body to use
556+ MinorVoxelIndexKey MinorVoxel; // (Unit) For turret/barrel to use
557+ AircraftVoxelIndexKey AircraftVoxel;
558+ FlyVoxelIndexKey FlyVoxel; // (Unit)
559+ RocketVoxelIndexKey RocketVoxel; // (Unit)
560+ TunnelVoxelIndexKey UndergroundVoxel; // (Unit) loco->State != 0
381561 ShadowVoxelIndexKey Shadow;
382- TurretBarrelVoxelIndexKey TurretBarrel;
383562 ReservedVoxelIndexKey Reserved;
384- private:
385563 int Value;
386564};
387565
0 commit comments