[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
Chipmunk Physics • View topic - Multigrab: how to "z-order" overlapping shapes

Multigrab: how to "z-order" overlapping shapes

Official forum for the .

Multigrab: how to "z-order" overlapping shapes

Postby SorenToft » Sun Feb 24, 2013 8:57 am

Hi

I am using multigrab (objective-c wrapper) to grap the the arm, leg and torso of a person. The person is displayed in profile, so the chipmunk shapes representing the arm and torso overlaps. When i touch the arm multigrab will (most of the time) grab the torso instead. What would be a good way to make sure, the arm always have priority over the torso when grabbing?

Right now my best bet is do some "pre-filtering" in the ccToucedMoved that will determine if the touch is within the arm, then set the MultiGrab grabFilter to filter out all shapes with a lower z sprite index. But I am hoping for a less messy solution.

Regards.
SorenToft
 
Posts: 3
Joined: Sat Feb 23, 2013 8:44 am

Re: Multigrab: how to "z-order" overlapping shapes

Postby slembcke » Tue Feb 26, 2013 12:44 pm

Sorry, trying to catch up on missed posts this morning.

Unfortunately there is not a way to z-order them without modifying the ChipmunkMultiGrab source itself. It's implemented to grab the closest non-filtered shape to the touch location. In the case where you touch a spot where two shapes are overlapping, it will grab the one that the touch is deepest into. I assume "displayed in profile" means from the side? In that case if the arm and torso are overlapping and the torso is thicker, then you are pretty likely to touch deeper into the torso than the arm.

The changes to ChipmunkMultiGrab would be relatively simple to make. In the "beginLocation:" method, when it compares the distance change it to fall back on your z-order if the distance is negative (meaning inside the touched shape).

An idea for the next version of ChipmunkMultiGrab would be to have a sorting callback. In the case of ties (multiple shapes under the touch location), it breaks them with the return value of the sorting callback. The default one could just return the touch depth to keep the current behavior. For z-ordered stuff you could override the callback to return the z-value. It might be a while before I get to this though. I'm already sort of backlogged right now. :-\
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Multigrab: how to "z-order" overlapping shapes

Postby SorenToft » Wed Feb 27, 2013 2:21 pm

Hi - thank you for your answer.

Yes, when I say in profile I mean "from the side". Writing displayed in profile is probably speaking Danglish (Danish-English). ;)

I did make a work-around. In my ccToucesBegan I look at the distance from the touch point to the arm, and if it is <= 0, I filter out the torso before calling [Multigrab beginLocation].

I may subclass Multigrab to make a more generic solution along the line you suggested.
SorenToft
 
Posts: 3
Joined: Sat Feb 23, 2013 8:44 am

Re: Multigrab: how to "z-order" overlapping shapes

Postby slembcke » Mon Mar 11, 2013 12:34 pm

Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Multigrab: how to "z-order" overlapping shapes

Postby SorenToft » Mon Mar 11, 2013 2:55 pm

Thank you - I will check it out and clean up my code :-)
SorenToft
 
Posts: 3
Joined: Sat Feb 23, 2013 8:44 am


Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 0 guests

cron