nicer floor explainer: terrain overview with grid and polygon numbers, zoom on both crate needles with the accepted slivers, side view
This commit is contained in:
1 parent
8baed2e87c
commit
74f8fec341
6 files changed
+203
-130
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import sys,struct,math; sys.path.insert(0,'/home/elias/projects/llamamod/tools'); import geomlib as G
|
||||
ch,wf,trak,mp=G.load_level(__import__('os').environ.get('WAD','/home/elias/.claude/jobs/90c6eed7/tmp/exitre/t1l4m002.wad'))
|
||||
_exe=open('/home/elias/projects/llamamod/re/groove.exe','rb').read()
|
||||
SIN=list(struct.unpack_from('<4096i',_exe,0x174318))
|
||||
def c8(b): return b-256 if b>127 else b
|
||||
def floor_test(px,py,pz,tx,ty,tz,rot,recs,dbg=False,probe_add=0x400):
|
||||
"""exact re-implementation of FUN_004036d0 floor branch (flags 0x200000 off). ints 20.12"""
|
||||
lx=px-tx; lz=pz-tz; ly=py-ty+probe_add
|
||||
u=(-rot)&0xffffffff
|
||||
if u:
|
||||
s=SIN[u&0xfff]; c=SIN[(u+0x400)&0xfff]
|
||||
lx,lz=(s*lz+c*lx)>>12,(c*lz-s*lx)>>12
|
||||
out=[]
|
||||
for i,r in enumerate(recs):
|
||||
if r[1]==0x11: continue
|
||||
ny=c8(r[3]); n14=ny*32
|
||||
if n14<=0: continue
|
||||
h=(((struct.unpack_from('<h',r,6)[0]*4096 - c8(r[4])*32*lz - c8(r[2])*32*lx) - n14*ly))
|
||||
q=abs(h)//abs(n14); i6= q if (h>=0)==(n14>=0) else -q # C truncating division
|
||||
i7=-i6
|
||||
Y=ly+i6
|
||||
tol=-0x40-((ny*-0x20+0x1000)>>6)
|
||||
ne=4 if r[0]&1 else 3
|
||||
vals=[]
|
||||
ok=True
|
||||
for k in range(ne):
|
||||
nx,nyy,nz,_,d=struct.unpack_from('<bbbBh',r,8+6*k)
|
||||
v=((nyy*32*Y+nz*32*lz+nx*32*lx)>>12)-d
|
||||
vals.append(v)
|
||||
if v<tol: ok=False
|
||||
out.append((i,i7,ok,vals,tol,ty+Y))
|
||||
return (lx,ly,lz),out
|
||||
if __name__=='__main__':
|
||||
t=443; x,y,z,rot,mi,_=mp['A'][t]
|
||||
recs=[r for g in trak[mi].coll for r in g]
|
||||
P=[float(a) for a in sys.argv[1:4]]
|
||||
loc,out=floor_test(*[int(round(v*4096)) for v in P],int(round(x*4096)),int(round(y*4096)),int(round(-z*4096)),rot,recs)
|
||||
print('local',[v/4096 for v in loc])
|
||||
for i,i7,ok,vals,tol,Y in out:
|
||||
if i7>=-0x80: print(f'poly {i:2d} dist {i7/4096:+.4f} planeY {Y/4096:.4f} pass={ok} edges {vals} tol {tol}')
|
||||
Reference in new issue
Block a user