Recover dynamic box shared-context ownership and kernel winding
This commit is contained in:
1 parent
346d350176
commit
135ff3642a
18 files changed
+640
-1
No files matched your search
@@ -0,0 +1,85 @@
|
||||
/* Full copied47A5E0 plus static dispatcher/kernel; synthetic actor/box transforms.
|
||||
Global context is seeded deliberately. No original entry point or real actors. */
|
||||
#include "collision_dispatch_probe.c"
|
||||
static unsigned char box_object[0x500],sphere_object[0x500];
|
||||
static uintptr_t box_table[0x440/4],sphere_table[0x440/4];
|
||||
static Vec box_root,low,high,sphere_root,sphere_previous;
|
||||
static float box_radius,sphere_radius;
|
||||
static int geometry,other_mode,inhibit,rotate_box,mutate;
|
||||
static unsigned dynamic_callbacks,static_callbacks,setters;
|
||||
static Vec kernel_arguments[12][4];static unsigned kernel_calls;static unsigned char kernel_prefix[5];
|
||||
static void hook_jump(void*destination,void*target){unsigned char*p=destination;*p=0xe9;int32_t d=(unsigned char*)target-p-5;memcpy(p+1,&d,4);}
|
||||
static unsigned capture_kernel(Vec a,Vec b,Vec c,Vec n,Vec previous,Vec*current,float radius,int edges){
|
||||
if(kernel_calls<12){kernel_arguments[kernel_calls][0]=a;kernel_arguments[kernel_calls][1]=b;kernel_arguments[kernel_calls][2]=c;kernel_arguments[kernel_calls][3]=n;}kernel_calls++;
|
||||
memcpy(AT(0x47bd80),kernel_prefix,5);
|
||||
unsigned result=((Kernel)AT(0x47bd80))(a,b,c,n,previous,current,radius,edges);
|
||||
hook_jump(AT(0x47bd80),capture_kernel);return result;
|
||||
}
|
||||
static float TC get_radius(void*self){return self==box_object?box_radius:sphere_radius;}
|
||||
static int TC get_geometry(void*self){(void)self;return geometry;}
|
||||
static int TC get_mode(void*self){(void)self;return other_mode;}
|
||||
static int TC get_inhibit(void*self){(void)self;return inhibit;}
|
||||
static Vec*TC get_root(void*self,Vec*out){*out=self==box_object?box_root:sphere_root;return out;}
|
||||
static Vec*TC get_previous(void*self,Vec*out){(void)self;*out=sphere_previous;return out;}
|
||||
static Vec*TC get_low(void*self,Vec*out){(void)self;*out=low;return out;}
|
||||
static Vec*TC get_high(void*self,Vec*out){(void)self;*out=high;return out;}
|
||||
static Vec*TC point(void*self,Vec*out,float x,float y,float z){
|
||||
(void)self;*out=rotate_box?(Vec){z+box_root.x,y+box_root.y,-x+box_root.z,1}:
|
||||
(Vec){x+box_root.x,y+box_root.y,z+box_root.z,1};return out;
|
||||
}
|
||||
static void TC set_root(void*self,Vec value){require(self==sphere_object,"root setter owner");sphere_root=value;setters++;}
|
||||
static void TC on_contact(void*self,Vec n,void*p){
|
||||
require(self==sphere_object,"contact owner");(void)n;
|
||||
if(p)static_callbacks++;else dynamic_callbacks++;
|
||||
if(mutate)sphere_root=(Vec){777,888,999,2};
|
||||
}
|
||||
static void reset(void){
|
||||
memset(box_object,0,sizeof(box_object));memset(sphere_object,0,sizeof(sphere_object));
|
||||
memset(box_table,0,sizeof(box_table));memset(sphere_table,0,sizeof(sphere_table));
|
||||
*(void**)box_object=box_table;*(void**)sphere_object=sphere_table;
|
||||
box_table[0x260/4]=sphere_table[0x260/4]=(uintptr_t)get_radius;
|
||||
box_table[0x310/4]=sphere_table[0x310/4]=(uintptr_t)get_root;
|
||||
box_table[0x2e4/4]=(uintptr_t)get_low;box_table[0x2dc/4]=(uintptr_t)get_high;
|
||||
box_table[0x384/4]=(uintptr_t)point;box_table[0x1e0/4]=(uintptr_t)get_inhibit;
|
||||
sphere_table[0x1d0/4]=(uintptr_t)get_geometry;sphere_table[0x178/4]=(uintptr_t)get_mode;
|
||||
sphere_table[0x2f8/4]=(uintptr_t)get_previous;sphere_table[0x314/4]=(uintptr_t)set_root;
|
||||
sphere_table[0x374/4]=sphere_table[0x370/4]=(uintptr_t)on_contact;
|
||||
box_root=(Vec){0,0,0,1};low=(Vec){-50,-50,-10,1};high=(Vec){50,50,10,1};
|
||||
sphere_previous=(Vec){0,0,50,1};sphere_root=(Vec){0,0,15,1};box_radius=40;sphere_radius=10;
|
||||
geometry=1;other_mode=inhibit=rotate_box=mutate=0;dynamic_callbacks=static_callbacks=setters=0;
|
||||
empty_grid();*(Vec*)(polygon[0]+8)=(Vec){0,0,1,0};
|
||||
*(void**)AT(0x695d4c)=polygon[0];*(float*)AT(0x695d5c)=77;*(float*)AT(0x5cfbe0)=88;
|
||||
*(Vec*)AT(0x5cfbe8)=(Vec){111,222,333,1};*(unsigned*)AT(0x695d74)=0;
|
||||
*(unsigned*)AT(0x695d70)=*(unsigned*)AT(0x695d78)=0;
|
||||
*(unsigned char*)AT(0x4f69e5)=1;*(unsigned char*)AT(0x695d46)=*(unsigned char*)AT(0x695d45)=0;
|
||||
}
|
||||
static void query(const char*name){
|
||||
int hit=((int(__cdecl*)(void*,void*))AT(0x47a5e0))(box_object,sphere_object)&255;
|
||||
Vec h=*(Vec*)AT(0x5cfbe8);
|
||||
printf("DYNAMIC {\"name\":\"%s\",\"contact\":%d,\"root\":[%.9g,%.9g,%.9g,%.9g],\"face\":%.9g,\"edge\":%.9g,\"hit\":[%.9g,%.9g,%.9g,%.9g],\"last\":%d,\"dynamicCallbacks\":%u,\"staticCallbacks\":%u,\"setters\":%u,\"passes\":%u,\"mode\":%u}\n",
|
||||
name,hit,sphere_root.x,sphere_root.y,sphere_root.z,sphere_root.w,*(float*)AT(0x695d5c),*(float*)AT(0x5cfbe0),h.x,h.y,h.z,h.w,
|
||||
*(void**)AT(0x695d4c)==polygon[0],dynamic_callbacks,static_callbacks,setters,*(unsigned*)AT(0x695d78),*(unsigned*)AT(0x695d74));
|
||||
}
|
||||
int main(void){
|
||||
setbuf(stdout,NULL);map_copy();
|
||||
memcpy(kernel_prefix,AT(0x47bd80),5);hook_jump(AT(0x47bd80),capture_kernel);
|
||||
reset();query("face_stale_polygon");
|
||||
reset();*(void**)AT(0x695d4c)=NULL;query("face_no_polygon");
|
||||
reset();inhibit=1;query("inhibited");
|
||||
reset();geometry=0;query("geometry_off");
|
||||
reset();sphere_root.z=200;query("broadphase_reject");
|
||||
reset();other_mode=2;query("other_box_overlap");
|
||||
reset();other_mode=2;sphere_root.z=51;query("other_box_reject");
|
||||
reset();sphere_previous.z=100;sphere_root.z=80;query("no_triangle_hit");
|
||||
reset();mutate=1;query("callback_root_overwritten");
|
||||
reset();mutate=inhibit=1;query("inhibited_callback_root_survives");
|
||||
reset();*(unsigned char*)AT(0x4f69e5)=0;query("static_geometry_off_stale_polygon");
|
||||
reset();sphere_object[0x42c]=1;query("forced_static_mode");
|
||||
reset();sphere_root=(Vec){0,45,15,1};sphere_previous=(Vec){0,45,50,1};query("near_top_edge");
|
||||
reset();box_root.x=100;sphere_root.x=sphere_previous.x=100;query("translated_box");
|
||||
reset();rotate_box=1;sphere_root=(Vec){15,0,0,1};sphere_previous=(Vec){50,0,0,1};query("rotated_box");
|
||||
reset();query("chain_first");sphere_previous=sphere_root;sphere_root.z=25;query("chain_away");
|
||||
printf("KERNEL_TRIANGLES [");
|
||||
for(unsigned i=0;i<12;i++){printf("%s[",i?",":"");for(unsigned j=0;j<4;j++){Vec v=kernel_arguments[i][j];printf("%s[%.9g,%.9g,%.9g,%.9g]",j?",":"",v.x,v.y,v.z,v.w);}printf("]");}puts("]");
|
||||
puts("DYNAMIC_CONTEXT_COMPLETE");return 0;
|
||||
}
|
||||
Reference in new issue
Block a user