Intended semantics of CollidesWith
by Scott Goodwin · in Torque X 2D · 06/15/2009 (10:41 pm) · 2 replies
What is the intended semantics of CollidesWith (AND or OR)? Example: CollidesWith red+ball. Some object red+tank. Collide with red OR ball. or collide with red AND ball.
In TX2, SceneContainer._FindBin has test: if ((ourType & typebits) == 0) whereas in TX3, this is replaced with if (((ourType & typebits) != typebits) && ((ourType & typebits) != ourType)).
In porting the PlatformerKit to TX3, I noticed the TX3 test messes with pepper pickups. Not sure yet if the test is wrong or if some further mods to the PlatformerKit are needed.
In TX2, SceneContainer._FindBin has test: if ((ourType & typebits) == 0) whereas in TX3, this is replaced with if (((ourType & typebits) != typebits) && ((ourType & typebits) != ourType)).
In porting the PlatformerKit to TX3, I noticed the TX3 test messes with pepper pickups. Not sure yet if the test is wrong or if some further mods to the PlatformerKit are needed.
About the author
#2
I even had a reference to the link you gave. But forgot all about it in TX3. I also hadn't seen your follow-up. I'll try it. Again, thanks.
06/16/2009 (11:24 pm)
Excellent! Thanks for the link. I had actually included Segers solution in my customized version of TX2.#region BUG(SDG)
// See http://www.garagegames.com/mg/forums/result.thread.php?qt=71678
#if !SDG_APPLY_BUGFIXES
if ((ourType & typebits) == 0)
{
// Move to next bin reference.
bin = bin._nextBinReference;
continue;
}
#endif
#endregion
#region BUGFIX(SDG)
#if SDG_APPLY_BUGFIXES
if (((ourType & typebits) != typebits) && ((ourType & typebits) != ourType))
{
// Move to next bin reference.
bin = bin._nextBinReference;
continue;
}
#endif
#endregionI even had a reference to the link you gave. But forgot all about it in TX3. I also hadn't seen your follow-up. I'll try it. Again, thanks.
Torque Owner Scott Zarnke
if (!obj.TestObjectType(_collidesWith)) continue;and according to the comments before the definition of TestObjectType:so it appears to be a logical OR combination for the types, i.e. if CollidesWith is set to Red and Ball, it will collide with anything that has type Red, Ball, or both (provided, of course that other object has a collision component itself. That's necessary because otherwise it would have no collision polygon and would be skipped in collision tests).
As far as the differences in _FindInBin(), the latter part looks similar to an attempt at a solution posted by Martijn Segers regarding the non-functioning noRenderMask, but applies to collisions as well, since they all use the _FindInBin method. I replied with an alternative solution that works better for use with collisions because of the way they use _FindInBin.
You can find that thread here. Maybe that might clear things up about how type filtering works. If you have access to the source code, you can try looking through yourself; it's fairly well commented.