MD3-based collision support via ZScript

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

MD3-based collision support via ZScript

Postby ZZYZX » Tue Jan 09, 2018 10:01 pm

Nash told me I should make a thread :roll:
Some time ago, in the beginning of ZScript, I said that once we get user-readable lumps I'm going to implement walkable models. Apparently, now's the time :D

Current link: http://www.mediafire.com/file/p99e18dtx ... lision.pk3

Video:

(the video is a bit old: it's not as buggy now)

As of now, as far as I know, it should not noclip or apply stupid velocity values, unless you try to walk between map geometry and a model (this is not implemented yet).

Things left to implement:
  • Walking between map model and non-model (essentially this algorithm: https://i.imgur.com/sJRrFgS.png)
  • Stepping up with MaxStepHeight
  • Optimization of lookup (AABB tree or just two-level 3D AABB structure, 64x64x64 boxes containing inner triangles) (using blockmap greatly reduced the list of triangles to check)
  • Moving along with actor attached to the model (i.e.: elevators, platforms..)
  • Optionally: NETMODEL lump to make sure all clients share the same version to avoid desyncs
  • ...maybe fix slopes? It still slides.

What it actually does: basically, it works on the velocity level, as any proper collision checking should.
Before every Tick(), it checks if actor's movement along it's velocity is going to hit a model, and if it does, it checks for all triangles that were intersected, finds the best triangle (the one that will lowest remaining intersections after inverted velocity is applied), and does this:
Code: Select allExpand view
            double diff = max(0, mostopposingnormal dot C3DCollision.NormalizeVector(parent.vel));
            double dst = max(0, FindBoxToPlaneDist(tp_c, tp_n, b_start, b_end));
            vector3 fac = mostopposingnormal * diff * parent.vel.Length() + mostopposingnormal * dst;
(which basically slides along triangle's plane, using 3 lines instead of 50 from Doom wall sliding code.)
Then if actor is blocked by anything below it, it will mark it as standing on another actor to fix up bobbing and stuff.

Once this is more complete, I'm also planning to make a compatible hitscan and A_Chase.
Then it will be possible to have some actor like StaticDecoration which will have model name and orientation as properties as opposed to having to specify it in the code.
Last edited by ZZYZX on Wed Jan 10, 2018 8:56 am, edited 1 time in total.
User avatar
ZZYZX
le chat du rabbin
 
Joined: 14 Oct 2012
Location: Ukraine

Re: MD3-based collision support via ZScript

Postby ramon.dexter » Wed Jan 10, 2018 2:03 am

Well...accroding to how it behaves...it should also work with voxels, Am I right?
User avatar
ramon.dexter
rudebwoy
 
Joined: 20 Oct 2015
Location: Kozolupy, Bohemia

Re: MD3-based collision support via ZScript

Postby Tormentor667 » Wed Jan 10, 2018 2:11 am

Definitely interesting but how is the Performance if you are using a lot of models?
User avatar
Tormentor667
needs more detail
 
Joined: 16 Jul 2003
Location: Germany

Re: MD3-based collision support via ZScript

Postby ZZYZX » Wed Jan 10, 2018 3:09 am

Currently it's not very good even while spamming plasma over a bridge, hence optimization listed in unimplemented.
Regarding voxels: no it won't support voxels. Voxels require completely different handling.
User avatar
ZZYZX
le chat du rabbin
 
Joined: 14 Oct 2012
Location: Ukraine

Re: MD3-based collision support via ZScript

Postby ramon.dexter » Wed Jan 10, 2018 7:39 am

ZZYZX: Wait, why? I understand that voxels are converted do models on runtime. So this wont work with voxels like voxel, but it should work with modelized voxel...
User avatar
ramon.dexter
rudebwoy
 
Joined: 20 Oct 2015
Location: Kozolupy, Bohemia

Re: MD3-based collision support via ZScript

Postby ZZYZX » Wed Jan 10, 2018 7:52 am

Important correction: voxels are converted to models at runtime by GZDoom (and I have my own loading code) and even then it creates a model with thousands of triangles which is not really suitable for collision.
Voxel collision should be implemented completely separately as AABB or sphere-based, since we know that voxel dots are, well, dots, instead of doing an overkill and using an arbitrary shape collision algorithm to work with them.

Unrelated update: I just put a blockmap in it (list of triangles for every ~64x64x64 block, but max blocks per model is 8x8x8 to reduce count of objects that float in the memory).
It seems to have made it run way faster, especially with large actor counts.
User avatar
ZZYZX
le chat du rabbin
 
Joined: 14 Oct 2012
Location: Ukraine

Re: MD3-based collision support via ZScript

Postby Nash » Wed Jan 10, 2018 10:45 am

Just tested the blockmap version, firing plasmas into the bridge doesn't cause slowdowns anymore.

However I found another case for MASSIVE slowdown: go to the center bridge, crouch a little so that you can pass through the opening of the tunnel, then stand up while you're still at the edge of the tunnel (your body half under the tunnel and the other half outside of the tunnel)...
User avatar
Nash
Nash Muhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia

Re: MD3-based collision support via ZScript

Postby ZZYZX » Wed Jan 10, 2018 10:59 am

I have this fixed locally. Uploaded it.
User avatar
ZZYZX
le chat du rabbin
 
Joined: 14 Oct 2012
Location: Ukraine

Re: MD3-based collision support via ZScript

Postby ZippeyKeys12 » Thu Jan 11, 2018 6:37 pm

I just messed around with this and it is amazing. I don't understand how you did this in ZScript despite this being no'd in feature requests for being a pain to implement in the GZDoom source.

Also what does:
ZZYZX wrote:Walking between map model and non-model (essentially this algorithm: https://i.imgur.com/sJRrFgS.png)
mean?
You're amazing :wub: keeps doing what you're doing :D
ZippeyKeys12
 
Joined: 15 Jun 2016

Re: MD3-based collision support via ZScript

Postby ZZYZX » Fri Jan 12, 2018 2:45 pm

Means if currently you try to walk between two surfaces with acute angle between them, you will be bumped away in the best case, and stuck between triangles in the worst case.
User avatar
ZZYZX
le chat du rabbin
 
Joined: 14 Oct 2012
Location: Ukraine

Re: MD3-based collision support via ZScript

Postby ZippeyKeys12 » Fri Jan 12, 2018 11:12 pm

Oh. That's seems bad, but I'm sure you'll figure it out :D
ZippeyKeys12
 
Joined: 15 Jun 2016


Return to Scripting

Who is online

Users browsing this forum: ramon.dexter and 2 guests