Repository navigation
Expand file tree
/
Copy pathHeadMeshPolicyProbe.cpp
More file actions
74 lines (74 loc) · 6.21 KB
/
Copy pathHeadMeshPolicyProbe.cpp
File metadata and controls
74 lines (74 loc) · 6.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "HeadMeshPolicy.h"
#include <cstdio>
#include <cstdlib>
#include <initializer_list>
using namespace HeadMeshPolicy;
void Check(bool value,const char* message){if(!value){std::fprintf(stderr,"FAIL: %s\n",message);std::exit(1);}}
int main(){
// Deliberately shuffled bone order: hand, eye, spine, head, pelvis, neck.
int parents[]{2,3,4,5,-1,2};unsigned char head[6]{},ancestors[6]{};
Check(Hierarchy(parents,6,3,head,ancestors),"valid non-parent-first hierarchy");
Check(head[1]&&head[3]&&!head[0]&&!head[5],"head and face only");
Check(ancestors[2]&&ancestors[4]&&ancestors[5]&&!ancestors[0]&&!ancestors[1],"ancestor weights");
unsigned face[]{0,100,10,200,0,30};
Check(HeadOnly(face,6,head,ancestors),"head/face plus neck weights");
unsigned body[]{40,0,200,0,100,20};
Check(!HeadOnly(body,6,head,ancestors),"body remains visible");
unsigned mixed[]{40,100,200,200,100,20};
Check(!HeadOnly(mixed,6,head,ancestors),"mixed head/body mesh remains visible");
unsigned empty[6]{};Check(!HeadOnly(empty,6,head,ancestors),"empty groups fail open");
int cycle[]{2,3,4,5,-1,3};Check(!Hierarchy(cycle,6,3,head,ancestors),"cyclic rig rejected");
int bad[]{2,3,4,5,-1,7};Check(!Hierarchy(bad,6,3,head,ancestors),"invalid parent rejected");
Selection selected{0x2000,{0x3000,0x4000},2};
Entry owner{0x1000,0x3002,0x2007,0x76543210};
Check(Matches(selected,owner),"retail tagged pointers decoded");
auto npc=owner;npc.node=0x5007;Check(!Matches(selected,npc),"shared NPC head is preserved");
auto torso=owner;torso.primitive=0x6002;Check(!Matches(selected,torso),"unselected player mesh preserved");
auto missing=selected;missing.node=0;Check(!Matches(missing,owner),"missing player fails open");
Check(MainView(0x9000,0x9000,true,false,15),"tracked first-person main view");
Check(!MainView(0x9000,0,true,false,15),"third-person/screen/menu disables filtering");
Check(!MainView(0x8000,0x9000,true,false,15),"other camera preserved");
Check(!MainView(0x9000,0x9000,false,false,15),"mono context preserved");
Check(!MainView(0x9000,0x9000,true,true,15),"mirror preserved");
for(unsigned layer=4;layer<=7;++layer)Check(!MainView(0x9000,0x9000,true,false,layer),"shadow layer preserved");
for(unsigned layer=24;layer<=27;++layer)Check(!MainView(0x9000,0x9000,true,false,layer),"reflective shadow layer preserved");
Check(!MainLayer(21)&&!MainLayer(28)&&!MainLayer(30),"non-view layers fail open");
Check(MainLayer(0)&&MainLayer(1)&&MainLayer(2)&&MainLayer(3)&&MainLayer(20)&&MainLayer(22)&&MainLayer(23)&&MainLayer(29),"main geometry layers");
Check(SkinArrayView(0x9000,0x9000,true,false,true,0x333794,true),"skin fade branch allowed");
Check(SkinArrayView(0x9000,0x9000,true,false,true,0x333846,false),"skin shared-buffer branch allowed");
Check(!SkinArrayView(0x9000,0x9000,true,false,true,0x333846,true),"wrong array overload fails open");
for(uintptr_t caller:{uintptr_t(0x308891),uintptr_t(0x32c76d),uintptr_t(0x3138f8)})
Check(!SkinArrayView(0x9000,0x9000,true,false,true,caller,true),"other array paths preserved");
Check(!SkinArrayView(0x8000,0x9000,true,false,true,0x333794,true),"other camera skin preserved");
Check(!SkinArrayView(0x9000,0,true,false,true,0x333794,true),"screen/third-person/menu skin preserved");
Check(!SkinArrayView(0x9000,0x9000,true,true,true,0x333794,true),"mirror skin preserved");
Check(!SkinArrayView(0x9000,0x9000,false,false,true,0x333794,true),"mono skin preserved");
Check(!SkinArrayView(0x9000,0x9000,true,false,false,0x333794,true),"non-main target preserved");
Check(!MainView(0,0x9000,true,false,15),"null context without owned traversal remains native");
Check(MainView(0,0x9000,true,false,15,true),"null camera accepted inside verified main traversal");
Check(!MainView(0x8000,0x9000,true,false,15,true),"explicit other camera cannot use traversal fallback");
Check(!MainView(0,0x9000,true,true,15,true)&&!MainView(0,0x9000,true,false,6,true),"scoped fallback preserves mirrors and shadows");
Check(SkinArrayView(0,0x9000,true,false,true,0x333794,true,true),"scoped null-camera skin fade branch");
Check(SkinArrayView(0,0x9000,true,false,true,0x333846,false,true),"scoped null-camera shared skin branch");
Check(!SkinArrayView(0,0x9000,true,false,true,0x333794,true),"null skin camera without scope remains native");
Check(!SkinArrayView(0,0x9000,true,false,false,0x333794,true,true),"non-main null camera remains native");
Check(!SkinArrayView(0,0x9000,true,false,true,0x3138f8,true,true),"scope never widens allowed array callers");
Entry entries[]{owner,npc,torso,owner},out[4]{};
uint32_t refs[]{0x1111,0x2222,0x3333,0x4444},outRefs[4]{};unsigned kept{};
Check(CopyArray(selected,entries,4,out,refs,outRefs,kept)&&kept==2,"only owned selected head entries removed");
Check(out[0].node==npc.node&&out[0].sort==npc.sort&&out[1].primitive==torso.primitive&&out[1].instance==torso.instance,"native draw order and instance/sort preserved");
Check(outRefs[0]==refs[1]&&outRefs[1]==refs[2],"per-entry constant buffers remain paired with meshes");
Check(entries[0].node==owner.node&&entries[3].primitive==owner.primitive&&refs[3]==0x4444,"native source arrays unchanged");
Check(CopyArray(selected,entries,4,out,nullptr,nullptr,kept)&&kept==2,"shared constant-buffer branch");
Check(!CopyArray(selected,entries,4,out,refs,nullptr,kept),"missing buffer output rejected");
Check(CopyArray(selected,&owner,1,out,refs,outRefs,kept)&&kept==0,"all-head batch compacts to zero draws");
// Full body selection still requires the player node. A held weapon has
// its own node even if it happens to share a primitive pointer.
Selection fullBody{0x2000,{0x3000,0x4000,0x6000},3};
auto weapon=torso;weapon.node=0x7002;
Entry bodyBatch[]{owner,torso,npc,weapon},bodyOut[4]{};
uint32_t bodyRefs[4]{};
Check(CopyArray(fullBody,bodyBatch,4,bodyOut,refs,bodyRefs,kept)&&kept==2,"full body option removes owned head and torso");
Check(bodyOut[0].node==npc.node&&bodyOut[1].node==weapon.node&&bodyRefs[0]==refs[2]&&bodyRefs[1]==refs[3],"NPC and held weapon retain order and constants");
std::puts("Head mesh hierarchy, tagged ownership and view/pass scope checks passed");
}