[Added] ThruBits

Moderator: GZDoom Developers

ThruBits

Postby Major Cooke » Tue Oct 13, 2020 1:15 pm

Pull Request

By using bytes (1 << [0, 31]), allows actors to pass through others within the same 'byte'. An example is in the PR.

Spoiler: "Old Post"
Last edited by Major Cooke on Wed Oct 14, 2020 4:26 pm, edited 1 time in total.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: ThruActorLevel<Min/Max>

Postby Rachael » Tue Oct 13, 2020 5:16 pm

I think I would prefer to see this as a bitfield mask instead of as "levels", i.e. if (actor1->thrubits & actor2->thrubits) { noCollision = true; }
User avatar
Rachael
Webmaster
 
Joined: 13 Jan 2004
Location: This post
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: ThruActorLevel<Min/Max>

Postby Major Cooke » Tue Oct 13, 2020 5:35 pm

Oh? Can you expand more on that idea's explanation? I'm intrigued but I don't think I see the full picture.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: ThruActorLevel<Min/Max>

Postby Rachael » Tue Oct 13, 2020 6:23 pm

x->thrubits = 1
y->thrubits = 2
(x & y) == 0, so they collide

x->thrubits = 1
y->thrubits = 3
(x & y) == 1, so they do not collide.
User avatar
Rachael
Webmaster
 
Joined: 13 Jan 2004
Location: This post
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: ThruActorLevel<Min/Max>

Postby Graf Zahl » Tue Oct 13, 2020 11:32 pm

That definitely makes a lot more sense than what's there currently. Then the entire check can be condensed to a single '&' check of these two flag words. Since both would be 0 by default, no special flag and no helper functions would be needed.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ThruActorLevel<Min/Max>

Postby Major Cooke » Wed Oct 14, 2020 1:48 pm

While this solves my most immediate problem of ensuring blocks are always blocking, I need help testing some more advanced cases. Is it possible to create 'groups' in a way, and how would that be done? I get that 0 means its always blocking, but if I'm going to be using this, it'll help greatly to know how to handle this.

I'll create a PR in the mean time.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: ThruActorLevel<Min/Max>

Postby Major Cooke » Wed Oct 14, 2020 2:03 pm

User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: ThruActorLevel<Min/Max>

Postby Rachael » Wed Oct 14, 2020 2:31 pm

Major Cooke wrote: Is it possible to create 'groups' in a way, and how would that be done?

That's what the bitfield is for. Except - you as the modder get to assign the groups. i.e. bit 1 is one group, bit 2 is another, etc.

The basic idea is - you're never going to need 4 billion levels of ThruActor. However, if you instead use 32 different levels that can be switched on and off inside various actor definitions - it creates a system that is much more flexible and much less need of overrides in the future. It allows a granularity that simple numbers cannot define, and does it in a way that is a simple test for the CPU rather than a complex machination of if's and if else's that would inevitably be built upon in the future.

There are times when it is appropriate to design a mechanic from the top down instead of the bottom up, and I feel this is one of those instances.

Basically, I'm trying to avoid a repeat of God/God2/Buddha/Buddha2/NODAMAGE/NOPAIN/FOILINVUL/FORCEPAIN/etc with the clipping code.
User avatar
Rachael
Webmaster
 
Joined: 13 Jan 2004
Location: This post
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: ThruActorLevel<Min/Max>

Postby Major Cooke » Wed Oct 14, 2020 2:59 pm

So if I have actor X with (byte4|byte5), it can pass through anyone else with either of those two groups. Alright, that works for me.

Should anyone else need more, well... I guess we can cross that line when we get there.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: ThruBits

Postby Major Cooke » Wed Oct 14, 2020 4:27 pm

I've tested everything and the PR is already merged into QZDoom. Works like a charm.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: ThruBits

Postby Apeirogon » Fri Oct 16, 2020 12:14 pm

Maybe its better to implement it in other direction? Instead of "actors with same bits can pass through each other, collide otherwise" do it like "actors with same bits can collide with each other, pass through otherwise".

Also "thrubits" is not too good name for such thing, "Bits? What bits? Woob Woob Woooob???".
ThruGroup, PassLayer, IgnoreGroup or CollisionGroup maybe?
User avatar
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: ThruBits

Postby Major Cooke » Fri Oct 16, 2020 2:03 pm

I already asked Graf if I could do ThruGroup, but he said no. :P

You do have a good point about inverting though. It could be done with an added actor boolean if no one opposes it. But I'll wait for Rachael/Graf to speak on that matter first.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: ThruBits

Postby Rachael » Fri Oct 16, 2020 3:55 pm

Either works for me. As I've said before - the thing that I want to avoid is an override of an override of an override of an override ... especially when it comes to the collision code.

Stuffing up the collision code with a complex if-else tree can have a massively negative impact on performance.
User avatar
Rachael
Webmaster
 
Joined: 13 Jan 2004
Location: This post
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: ThruBits

Postby Graf Zahl » Sat Oct 17, 2020 1:56 am

Major Cooke wrote:I already asked Graf if I could do ThruGroup, but he said no. :P


And it remains 'no'. This is time critical code - adding a single bit masking check is no big deal, but doing anything more complex there will affect everything that does not need the feature.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ThruBits

Postby Major Cooke » Sat Oct 17, 2020 9:56 am

To clarify I meant rename it to ThruGroup, nothing more. But yeah. It makes more sense as ThruBits now that I think about it because of what can go into it.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007


Return to Closed Feature Suggestions

Who is online

Users browsing this forum: No registered users and 2 guests