Match original collision rounding through populated dynamic reclip
This commit is contained in:
1 parent
135ff3642a
commit
bf876e9c3c
22 files changed
+701
-14
No files matched your search
@@ -0,0 +1,83 @@
|
||||
/* Complete original dynamic box + populated static grid; bounded actor fixtures.
|
||||
* Included source is generated without its standalone main. Originals untouched. */
|
||||
#include "dynamic_context_probe.c"
|
||||
static unsigned char stale_polygon[0x30];
|
||||
static char events[4096];
|
||||
static unsigned event_length,kernel_zero,kernel_lower;
|
||||
static int tracing;
|
||||
static unsigned trace_steps;
|
||||
static void vector_json(Vec p){printf("[%.9g,%.9g,%.9g,%.9g]",p.x,p.y,p.z,p.w);}
|
||||
|
||||
static int polygon_id(void *p) {
|
||||
if(!p)return -1;
|
||||
if(p==stale_polygon)return 99;
|
||||
if(p==polygon[0])return 0;
|
||||
if(p==polygon[1])return 1;
|
||||
require(0,"unknown fixture polygon");return -2;
|
||||
}
|
||||
static void event(unsigned slot,void*p) {
|
||||
int count=snprintf(events+event_length,sizeof(events)-event_length,
|
||||
"%s%x:%d:%u",event_length?",":"",slot,polygon_id(p),*(unsigned*)AT(0x695d74));
|
||||
require(count>0&&event_length+(unsigned)count<sizeof(events),"event bound");
|
||||
event_length+=(unsigned)count;
|
||||
}
|
||||
static void TC response370(void*self,Vec n,void*p){event(0x370,p);on_contact(self,n,p);}
|
||||
static void TC response374(void*self,Vec n,void*p){event(0x374,p);on_contact(self,n,p);}
|
||||
static void TC publish(void*self,Vec p){event(0x314,NULL);set_root(self,p);}
|
||||
static unsigned observe_kernel(Vec a,Vec b,Vec c,Vec n,Vec previous,Vec*current,float radius,int edges) {
|
||||
Vec input=*current;
|
||||
if(*(unsigned*)AT(0x695d74))kernel_lower++;else kernel_zero++;
|
||||
memcpy(AT(0x47bd80),kernel_prefix,5);
|
||||
unsigned result=((Kernel)AT(0x47bd80))(a,b,c,n,previous,current,radius,edges);
|
||||
if(tracing&&trace_steps<12){
|
||||
printf("KERNEL_STEP {\"index\":%u,\"input\":",trace_steps++);vector_json(input);
|
||||
printf(",\"output\":");vector_json(*current);
|
||||
printf(",\"contact\":%u,\"face\":%.9g,\"edge\":%.9g,\"hit\":",result&255,
|
||||
*(float*)AT(0x695d5c),*(float*)AT(0x5cfbe0));vector_json(*(Vec*)AT(0x5cfbe8));puts("}");
|
||||
}
|
||||
hook_jump(AT(0x47bd80),observe_kernel);return result;
|
||||
}
|
||||
static void setup(void) {
|
||||
reset();event_length=kernel_zero=kernel_lower=trace_steps=0;events[0]=0;tracing=0;
|
||||
memset(stale_polygon,0,sizeof(stale_polygon));
|
||||
*(Vec*)(stale_polygon+8)=(Vec){0,0,1,0};*(void**)AT(0x695d4c)=stale_polygon;
|
||||
sphere_table[0x370/4]=(uintptr_t)response370;sphere_table[0x374/4]=(uintptr_t)response374;
|
||||
sphere_table[0x314/4]=(uintptr_t)publish;
|
||||
}
|
||||
static void z_wall(unsigned id,float z) {
|
||||
add_triangle(id,(Vec){-100,-100,z,1},(Vec){-100,100,z,1},
|
||||
(Vec){100,100,z,1},(Vec){0,0,1,0});
|
||||
}
|
||||
static void result(const char*name) {
|
||||
int hit=((int(__cdecl*)(void*,void*))AT(0x47a5e0))(box_object,sphere_object)&255;
|
||||
Vec h=*(Vec*)AT(0x5cfbe8);
|
||||
printf("RECLIP {\"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,\"visits\":%u,\"mode\":%u,\"kernelZero\":%u,\"kernelLower\":%u,\"events\":\"%s\"}\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,
|
||||
polygon_id(*(void**)AT(0x695d4c)),dynamic_callbacks,static_callbacks,setters,
|
||||
*(unsigned*)AT(0x695d78),*(unsigned*)AT(0x695d70),*(unsigned*)AT(0x695d74),
|
||||
kernel_zero,kernel_lower,events);
|
||||
}
|
||||
int main(void) {
|
||||
setbuf(stdout,NULL);map_copy();
|
||||
memcpy(kernel_prefix,AT(0x47bd80),5);hook_jump(AT(0x47bd80),observe_kernel);
|
||||
setup();z_wall(0,35);result("nearer_wall");
|
||||
setup();z_wall(0,10);result("equal_dynamic_face");
|
||||
setup();z_wall(0,0);result("far_wall");
|
||||
setup();z_wall(0,35);z_wall(1,30);result("two_near_first");
|
||||
setup();z_wall(0,30);z_wall(1,35);result("two_far_first");
|
||||
setup();z_wall(0,35);mutate=1;result("nearer_callback_root");
|
||||
setup();z_wall(0,35);inhibit=1;result("inhibit_static_visit");
|
||||
setup();z_wall(0,35);*(unsigned char*)AT(0x4f69e5)=0;result("geometry_off_visits");
|
||||
setup();z_wall(0,35);sphere_object[0x42c]=1;result("forced_primitive_mode");
|
||||
setup();z_wall(0,0);*(Vec*)(stale_polygon+8)=(Vec){0,-1,0,0};result("stale_ceiling_callback");
|
||||
setup();z_wall(0,0);sphere_root.y=30;
|
||||
add_triangle(1,(Vec){-100,35,-100,1},(Vec){-100,35,100,1},(Vec){100,35,100,1},(Vec){0,-1,0,0});
|
||||
result("ceiling_response");
|
||||
setup();z_wall(0,35);sphere_previous.y=-30;
|
||||
add_triangle(1,(Vec){-100,5,-100,1},(Vec){100,5,100,1},(Vec){100,5,-100,1},(Vec){0,-1,0,0});
|
||||
tracing=1;result("wall_and_ceiling");
|
||||
setup();z_wall(0,35);result("retained_first");
|
||||
sphere_previous=(Vec){0,0,50,1};sphere_root=(Vec){0,0,15,1};result("retained_second");
|
||||
puts("DYNAMIC_RECLIP_COMPLETE");return 0;
|
||||
}
|
||||
Reference in new issue
Block a user