All I did was verify that the function gets called twice with the proper parameter setup. What you do inside the function is not limited in anyway. Look out for the correct parameter signature, though, it's "override bool CanCollideWith(Actor other, bool passive)".Major Cooke wrote:...Okay, better question. Graf, how did you test this to ensure the multi-actor thing works?
[ZScript] Actor Collision Exclusion
Moderator: GZDoom Developers
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49229
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: [ZScript] Actor Collision Exclusion
- 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: [ZScript] Actor Collision Exclusion
...Oooooh, wait a second! The actor parameter is automatically filled in if the passive boolean is set, to the actor its checking?Graf Zahl wrote:I wouldn't use CheckClass.
Either use 'GetClass() ==' if you want to check a single class or 'mobj is "classname"' if you want to check for a group of actors, you can of course also do 'GetSpecies() == 'speciesname', or check friendliness or check if one actor has a specific damage type or whatever else you like to have tested. Calling the super method is not needed, AActor' just returns true and does nothing.
If that's the case, NOW it all makes sense.
I wonder though, could something to toggle off obvious collision exclusions be included? For the power user.Graf Zahl wrote:I added the virtual call at a place where the obvious non-collisions had already been processed and only do it for cases that might result in an actual collision, it will not get called if something intersects with a non-solid object that has no special properties.
The point is simply to allow the scripted functions to be more complex, the more often it gets called the more constrained you are.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49229
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: [ZScript] Actor Collision Exclusion
'self' is the checking actor, and 'other' the one it collides with. The function gets called twice in the process, from both actors taking part in the collision. First with the one whose move is being checked as 'self' and 'passive set to false, then again with the actor it collided with as 'self' and 'passive' set to true, so that both get a chance at deciding if the collision is supposed to happen.
- 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: [ZScript] Actor Collision Exclusion
Aaah, this makes it all clear now. Thanks!
However, I still think this could include two power options, one to not abort whenever one of them returns false and one to allow manual detection of everything like corpses. It may not make much sense, yet if I could wip up a recording of it to showcase some interesting things, I'd do it in a heartbeat.
Otherwise I have to make corpses spawn a blocking actor which allows passing through of everything else BUT that one actor (faking non-solid). And that's just more processing power being sapped.
Trust me when I say this, people WILL wind up using this kind of hacky stuff to achieve those things.
However, I still think this could include two power options, one to not abort whenever one of them returns false and one to allow manual detection of everything like corpses. It may not make much sense, yet if I could wip up a recording of it to showcase some interesting things, I'd do it in a heartbeat.
Otherwise I have to make corpses spawn a blocking actor which allows passing through of everything else BUT that one actor (faking non-solid). And that's just more processing power being sapped.
Trust me when I say this, people WILL wind up using this kind of hacky stuff to achieve those things.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49229
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: [ZScript] Actor Collision Exclusion
The main problem here is performance. That stuff you suppose is really costly here. Imagine an actor with a relatively complex collision exclusion logic wading through a field of corpses. That can easily end up in hundreds of script calls if all corpses need to be checked. I tried to keep this simple: The purpose of this is merely to query if a collision or interaction should be allowed, because that's straightforward and quick to check. This is absolutely not the place to toy around with power options that require more complex checks because they always need to be done, even if none of the actors really needs them.
Re: [ZScript] Actor Collision Exclusion
I suppose a better way would be to mark a certain kind of actors as excluded from this kind of processing with a flag similar to +NOINTERACTION, maybe even reuse the existing THRUACTORS for this since it makes no sense to have with flag applied and custom actor collision logic at the same time. If it is set, the game will always treat them as non-solid for other actors, w/o this mechanism being applied; this has lots of benefits and marginally is the same like the current way, so no much extra work is needed.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49229
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: [ZScript] Actor Collision Exclusion
The logic already excludes everything that can be trivially classified as a non-collision. It only calls these functions to check if a registered collision is supposed to happen, but never to check if a non-collision should be ignored.
If you do not want these checks, do not override the virtual function, the default is a quick jump to an empty function that does almost nothing. This doesn't cost any significant performance compared to the rest of the function. But if only one actor overrides it, the checks need to be done to ensure proper behavior.
If you do not want these checks, do not override the virtual function, the default is a quick jump to an empty function that does almost nothing. This doesn't cost any significant performance compared to the rest of the function. But if only one actor overrides it, the checks need to be done to ensure proper behavior.
Re: [ZScript] Actor Collision Exclusion
But the point was to enable modders to optionally override this, so they could in fact, enable corpses and whatnot also call back this function.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49229
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: [ZScript] Actor Collision Exclusion
In this case I have to weigh between performance and flexibility, and here performance wins - every call that can be avoided is a plus. This is not a place where you can play loose with features. Like I said, PIT_CheckThing is one of the most performance critical and most called functions in the entire game, slowing this one down for some minor convenience will have widespread impact.
- 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: [ZScript] Actor Collision Exclusion
We'll just have to use work-arounds in this case. If we want blocking corpses, we simply will have to spawn an actor in the exact same location as the corpses which block this particular actor from being able to go around them. It'll remain unsolid to everything else using this feature.
Thankfully it's not difficult to make.
Thankfully it's not difficult to make.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49229
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: [ZScript] Actor Collision Exclusion
The thing is, the feature is not designed to make something non-solid blocking. It's designed to avoid a collision that's about to happen. The other way around is, as I said, far too costly.
Re: [ZScript] Actor Collision Exclusion
Maybe I am missing something here, but can't you simply set +SOLID on your corpses if you want them executing your block function?
I found this handy little line in p_interaction.cpp in AActor::Die (line 637):
Anything in the Death state is obviously after said function - so - ...?
I found this handy little line in p_interaction.cpp in AActor::Die (line 637):
Code: Select all
flags &= ~MF_SOLID;
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49229
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: [ZScript] Actor Collision Exclusion
Absolutely. Die doesn't even clear the flag. Normally A_NoBlocking does that so skipping that call would keep the corpse solid - and allow overriding its CanCollideWith function to do what is desired.