No(Block/Clip)Mask

Moderator: GZDoom Developers

Post Reply
User avatar
Major Cooke
Posts: 8209
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

No(Block/Clip)Mask

Post by Major Cooke »

I've begun working on NoBlockMask and NoClipMask. I changed it from BlockMask/ClipMask to "No" version because otherwise users would have to keep track of which flags they would need to follow through with, and in relation to THRU flags, it's the same as having the No affixed to it.

Graf/Randi: I've got the property made now, and a function to control it.

Still a WIP, but I wanted to check: I should replace the flag checks where appropriate, and have A_ChangeFlag simply add/subtract the flag from their masks, right? Somewhat like I did here:

Code: Select all

//==========================================================================
//
//==========================================================================
DEFINE_PROPERTY(NoClipMask, O, Actor) //O has been set up to parse mask flags
{
	// What doesn't the actor block?
	PROP_INT_PARM(val, 0);

	// [MC] Handle actor flags here.
	// MASK_ALl doesn't combine all of them, because this could break things like bullet 
	// puffs with species. Instead, it'll just take priority like the THRUACTORS flag does.

	if ((defaults->flags2 & MF2_THRUACTORS) && !(val & MASK_All))
		val += MASK_All; 
	if ((defaults->flags2 & MF2_THRUGHOST) && !(val & MASK_Ghost))
		val += MASK_Ghost;
	if ((defaults->flags2 & MF6_THRUSPECIES) && !(val & MASK_Species))
		val += MASK_Species;
	if ((defaults->flags2 & MF6_MTHRUSPECIES) && !(val & MASK_MSpecies))
		val += MASK_MSpecies;

	if (val)
		defaults->NoClipMask = val;
	else
		defaults->NoClipMask = MASK_Default;
}

//==========================================================================
//
//==========================================================================
DEFINE_PROPERTY(NoBlockMask, O, Actor)
{
	// What isn't the actor blocked by?
	PROP_INT_PARM(val, 0);

	if ((defaults->flags2 & MF2_THRUACTORS) && !(val & MASK_All))
		val += MASK_All;
	if ((defaults->flags2 & MF2_THRUGHOST) && !(val & MASK_Ghost))
		val += MASK_Ghost;
	if ((defaults->flags2 & MF6_THRUSPECIES) && !(val & MASK_Species))
		val += MASK_Species;
	if ((defaults->flags2 & MF6_MTHRUSPECIES) && !(val & MASK_MSpecies))
		val += MASK_MSpecies;

	if (val)
		defaults->NoBlockMask = val;
	else
		defaults->NoBlockMask = MASK_Default;
}
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49226
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: No(Block/Clip)Mask

Post by Graf Zahl »

You cannot check for flags in the property parser. They need to be handled as deprecated flags. And you need to OR the flags, not add them.
You also shouldn't implement something too complex. Deprecated flags are not supposed to be used in conjunction with the feature that replaces them.

Be careful, this has a high potential of going wrong as it possibly needs to shuffle around more than a few things.
User avatar
Major Cooke
Posts: 8209
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: No(Block/Clip)Mask

Post by Major Cooke »

Yea, I'm a little nervous about doing this myself, but randi said this is how he wanted it... I think...
randi wrote:I would much rather see two new flags fields: clipmask and blockmask. Clipmask controls what an object is blocked by, and blockmask controls what an object blocks. Some existing flags could be moved into these, and some could be implied by existing flags.

The point is that the blocking check becomes a single bitwise and of the two fields without dozens of lines of nearly identical duplicated code. It also offers more flexibility.

Yes, it will require some more setup code for compatibility, but I think it's worth it
Unless I misinterpreted what he said about "flags fields"?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49226
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: No(Block/Clip)Mask

Post by Graf Zahl »

Flag fields would be two actor properties.
But to map the old flags to those new properties you have to use the deprecated flags mechanism, you can't do the reassignments inside the property parser functions themselves.

Another issue is flags that also have another meaning, like 'Ghost'. Some investigation is needed to handle these properly with the new mask fields.
User avatar
Major Cooke
Posts: 8209
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: No(Block/Clip)Mask

Post by Major Cooke »

Yeah. I've got two flag fields, NoBlockMask and NoClipMask. I've figured out the deprecated flag handler, so I believe that should be good. In fact, I'll upload progress as soon as I reach a good stopping point for others to inspect.

About those flags with ghost, I figured making a function to handle things like that would help. Like:

Code: Select all

// Check if the mask is in noclip of one actor and noblock of the other. Inverse will
	// change clip to block checking on the caller, and vice versa on the other. Can check for
	// the flag as well if noflag is left to false, but just note missile checking won't work
	// properly without it (since it's a non-monster, it'll make it return true).
	inline bool crossCheckMask(AActor *other, int mask, bool noflag = false)
	{
		if (other)
		{
			if (mask == MASK_Ghost && !(noflag))
				return (((flags3 & MF3_GHOST) || (NoClipMask & mask)) && (other->NoBlockMask & mask));

			else if (mask == MASK_Monsters && !(noflag))
				return (((flags3 & MF3_ISMONSTER) || (NoClipMask & mask)) && (other->NoBlockMask & mask));

			else if (mask == MASK_Missiles && !(noflag))
				return (((flags & MF_MISSILE) || (NoClipMask & mask)) && (other->NoBlockMask & mask));

			else if (mask == MASK_Objects && !(noflag)) //Special case: Ensure neither actor is a missile.
				return ((!(flags3 & MF3_ISMONSTER) || (NoClipMask & mask)) && (other->NoBlockMask & mask) && !(flags | other->flags & MF_MISSILE));
			else
			{
				if (mask == MASK_Species && (GetSpecies() != other->GetSpecies()))
					return false; //Only the same species can pass through one another.
				return ((NoClipMask & other->NoBlockMask) & mask);
			}
		}
		return false;
	}
Last edited by Major Cooke on Tue Mar 03, 2015 4:44 pm, edited 2 times in total.
User avatar
Major Cooke
Posts: 8209
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: No(Block/Clip)Mask

Post by Major Cooke »

Okay, curious. THRUSPECIES and MTHRUSPECIES behaved similarly to what masks are going to do, right?

Code: Select all

	case DEPF_THRUSPECIES:	
	case DEPF_MTHRUSPECIES: //It basically did it just like masks.
		defaults->NoBlockMask |= MASK_Species;
		defaults->NoClipMask |= MASK_Species;
		break;
Is that okay?
User avatar
randi
Site Admin
Posts: 7749
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Re: No(Block/Clip)Mask

Post by randi »

No offence, but I think I'd rather do it myself.
User avatar
Major Cooke
Posts: 8209
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: No(Block/Clip)Mask

Post by Major Cooke »

None taken. This was proving to be a bit of a mouthful anyway. I have one request though, something to change the masks with a DECORATE function, please.

Do you want what I already have?
User avatar
Xtyfe
Posts: 1490
Joined: Fri Dec 14, 2007 6:29 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support

Re: No(Block/Clip)Mask

Post by Xtyfe »

I understand this will change how these functions work internally, but I'm not sure I understand the end result. How will it be different?
User avatar
Major Cooke
Posts: 8209
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: No(Block/Clip)Mask

Post by Major Cooke »

Means in short when Randi does this, my previous submission for MTHRUSPECIES flags will be made useless. Except as a reminder that maybe species should be respected on bfg sprays and rail attacks.
User avatar
Major Cooke
Posts: 8209
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: No(Block/Clip)Mask

Post by Major Cooke »

My obsessive compulsiveness took over and made me finish it. And I was bored. Still doing some more thorough testing but so far, everything seems to be running alright.

I don't care if you do use it, randi. I know you said you'll probably do it yourself. I'm just bringing it up because I was bored, and this felt like a nasty itch that could only be cured by just doing it anyway. Even if it winds up a waste of time, I still learned quite a bit from it. :geek:

There's no pull request yet because I'm still fine-testing as much as I can.
User avatar
randi
Site Admin
Posts: 7749
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Re: No(Block/Clip)Mask

Post by randi »

Yeah... That's not at all what I had in mind.
User avatar
Major Cooke
Posts: 8209
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: No(Block/Clip)Mask

Post by Major Cooke »

That's fine. Just thought, if anything, well, at least it works. I've done a couple more bug fixes which I've yet to upload but if you don't want this, no biggie.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”