Non-Square / Rotated collision
Moderator: GZDoom Developers
Re: Non-Square / Rotated collision
Chris brings up a very good point, and I am starting to think that the only real change I should make to it at all is adding an optional map-wide cylindrical support, if anything at all.
I think for lines, a way that I might be able to do this is to get a colliding line's slope (rise/run), and simply invert the line's slope with relation to the target actor.
So the math would be something line: (this is all purely conceptual)
(vec2)relative = (vec2)vertex1 - (vec2)vertex2;
(float)distr = dist(vertex1, vertex2);
if (distr <=0) exit;
(float)xradius = actor.radius * abs(relative.y / distr);
(float)yradius = actor.radius * abs(relative.x / distr);
where xradius would be the actor's collision radius to the line on the X axis, and yradius would be the actor's collision radius on the Y axis.
This is mostly just notes for myself in case I get to it later - so that I don't forget how to do this. (It seems I come up with the best ideas when I am half asleep)
As for dealing with slopes - I am not even going to bother. The actors will all remain square for that.
At any rate, this option will have to be set per-map. I will not bother with per-actor collision tests for this. Either all actors are circles, or all actors are squares.
I think for lines, a way that I might be able to do this is to get a colliding line's slope (rise/run), and simply invert the line's slope with relation to the target actor.
So the math would be something line: (this is all purely conceptual)
(vec2)relative = (vec2)vertex1 - (vec2)vertex2;
(float)distr = dist(vertex1, vertex2);
if (distr <=0) exit;
(float)xradius = actor.radius * abs(relative.y / distr);
(float)yradius = actor.radius * abs(relative.x / distr);
where xradius would be the actor's collision radius to the line on the X axis, and yradius would be the actor's collision radius on the Y axis.
This is mostly just notes for myself in case I get to it later - so that I don't forget how to do this. (It seems I come up with the best ideas when I am half asleep)
As for dealing with slopes - I am not even going to bother. The actors will all remain square for that.
At any rate, this option will have to be set per-map. I will not bother with per-actor collision tests for this. Either all actors are circles, or all actors are squares.
- Chris
- Posts: 2942
- Joined: Thu Jul 17, 2003 12:07 am
- Graphics Processor: ATI/AMD with Vulkan/Metal Support
Re: Non-Square / Rotated collision
I can't point out a specific example, but I'm pretty sure at least one map relies on this trick.RockstarRaccoon wrote:I've never heard this. Can you give an example?
Re: Non-Square / Rotated collision
My fear about this request, based on what I have heard various devs of various ports saying about the physics engine over the years, is that it amounts to "can we open a can of worms please".
I am very much not trying to take a jab at RockstarRaccoon and I really get where he is coming from but toying with something as fundamental as this with such a fragile physics engine seems to be asking for trouble.
Personally, I'd rather welcome a ground-up new physics engine to iron out all the little wrinkles in the Doom engine and to act as a new engine particularly suited to being a base for new games with Doom etc comparability being a lesser consideration. However, I suspect no one will have much appetite for such an endeavour and the likely audience would probably be small too. I.e. not worth it
I am very much not trying to take a jab at RockstarRaccoon and I really get where he is coming from but toying with something as fundamental as this with such a fragile physics engine seems to be asking for trouble.
Personally, I'd rather welcome a ground-up new physics engine to iron out all the little wrinkles in the Doom engine and to act as a new engine particularly suited to being a base for new games with Doom etc comparability being a lesser consideration. However, I suspect no one will have much appetite for such an endeavour and the likely audience would probably be small too. I.e. not worth it
Re: Non-Square / Rotated collision
I don't know where Graf went, but in the light of his absence over the past two days I am going to wait for him to weigh in on this.
When you said it like that with the can of worms thing - it's leading me to believe he will not be too fond of this request and may close it simply for that reason.
If not, I think I am pretty solid on how to make actors into cylinders. If he accepts that, I think that's as far as this suggestion will go - and then it's end of the line, at least for my coding for it. I don't want to muck up something that has such a huge potential to impact performance as well as introduce bugs to many well-established mapsets over the years.
Much as I hate copy-pasting code, I may also consider turning the collision functions in to function pointers and creating separate code paths for each collision type - to try and keep performance at a sane level for both modes.
When you said it like that with the can of worms thing - it's leading me to believe he will not be too fond of this request and may close it simply for that reason.
If not, I think I am pretty solid on how to make actors into cylinders. If he accepts that, I think that's as far as this suggestion will go - and then it's end of the line, at least for my coding for it. I don't want to muck up something that has such a huge potential to impact performance as well as introduce bugs to many well-established mapsets over the years.
Much as I hate copy-pasting code, I may also consider turning the collision functions in to function pointers and creating separate code paths for each collision type - to try and keep performance at a sane level for both modes.
- RockstarRaccoon
- Posts: 598
- Joined: Sun Jul 31, 2016 2:43 pm
Re: Non-Square / Rotated collision
I'm only asking for the ability, as someone making mods, to give new things cylindrical collision. I was hoping, as I said, for it to be a flag in DECORATE to choose collision on a Case by case basis. I don't see how that would break anyone else's maps if you can implement it without breaking existing functionality...
That said, if all you can give me is map-set cylinder support, I'll probably use it in everything from now on.
That said, if all you can give me is map-set cylinder support, I'll probably use it in everything from now on.
Re: Non-Square / Rotated collision
How would it work when a cylinder collides with a box? You use the cylindrical model or the box model? the way Doom works, it's pretty much an all-or-nothing affair.RockstarRaccoon wrote:I was hoping, as I said, for it to be a flag in DECORATE to choose collision on a Case by case basis.
Re: Non-Square / Rotated collision
It's easier to check the collision of two squares, or two circles, mathematically, than it is to check for the collision of a square and a circle together.RockstarRaccoon wrote:I was hoping, as I said, for it to be a flag in DECORATE to choose collision on a Case by case basis.
I am not even sure it's worth it to bog down the physics engine with conditional actor-to-actor checks to figure out which collision engine to use - of which there would be 3 if your idea were to go through - square-to-square, circle-to-circle, and circle-to-square. The first two are a lot simpler, the 3rd is doable but a bit more complicated.
And remember this: Imagine a map with 10,000 actors. Let's pretend they're all in one spot. That means each actor has to check against each other actor. That means, each individual actor iterates every single actor in the scene - a total of 100,000,000 checks. Add conditionals on top of that - and you will VERY quickly have no trouble understanding the performance difference between a pure square-to-square collision detection system and the more dynamic and complicated one that you propose. Trust me - with the way people abuse actor spawns as it is already now, it simply is not worth it to push those limits.
Contrary to what it may seem, I am not trying to be mean by imposing these limits. I'm trying to keep things sane. I do hope that you understand that, by now, having dealt with performance issues on other fronts already. As I said, physics checks are time-sensitive code, especially in maps with tons of actors - like the ones we routinely play with on a daily basis, especially ones in mods like Paranoid or Wolf:BOA.
- RockstarRaccoon
- Posts: 598
- Joined: Sun Jul 31, 2016 2:43 pm
Re: Non-Square / Rotated collision
Alright, I'll live with cylinders if you can give that to me. I'm aware of the limitations here, I just don't run into those sorts of performance issues in the stuff I make. I just thought this would be a good feature to eventually add...
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: Non-Square / Rotated collision
Needless to say, you're ultimately going to have to wait on Graf to come back. His word is law, here.
Re: Non-Square / Rotated collision
More like - GZDoom is his port, and if he doesn't want it he probably has a very good reason for not wanting it.Major Cooke wrote:His word is law, here.
- Kinsie
- Posts: 7399
- Joined: Fri Oct 22, 2004 9:22 am
- Graphics Processor: nVidia with Vulkan support
- Location: MAP33
- Contact:
Re: Non-Square / Rotated collision
Given how horrid Doom actor collision and physics apparently are under the hood, I wouldn't exactly hold my breath.
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: Non-Square / Rotated collision
I'm not holding my breath for it at all. I'm perfectly fine with squares right now anyway.
And yeah, for GZDoom I meant.
And yeah, for GZDoom I meant.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Non-Square / Rotated collision
Do I have to report when I go on vacation over an extended weekend?Rachael wrote:I don't know where Graf went, but in the light of his absence over the past two days I am going to wait for him to weigh in on this.
Regarding the issue, sorry. This is something I am not going to touch. It's simply not possible to do enhanced collision detection and still play Doom.
Re: Non-Square / Rotated collision
You do you. You don't have to report anything.Graf Zahl wrote:Do I have to report when I go on vacation over an extended weekend?
But you stirred up a bit of worry.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Non-Square / Rotated collision
For god's sake, I was gone for merely 3.5 days...