Collision detection with rotate/scale

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Collision detection with rotate/scale

Post by VilleK »

ZGE version 1.7.6 introduces a new collision style Rect2D_OBB for 2D collision detection with respect to rotation and scaling.

Attached is a small project demonstrating this new feature. Use keys Q,W,A,S and mouse to control.

Note: Currently if you are using Rect2D_OBB you need both models involved in a collision to use this style. So you cannot combine Rect2D_OBB and Rect2D for instance. This will be fixed in a later version.
Attachments
CollisionTests_OBB.zgeproj
Need ZGE 1.7.6 or later to run
(1.81 KiB) Downloaded 499 times
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hej Ville,

Works great! Hopefully we can see something similar appear for the Box3D and Sphere3D CollisionStyle's some time in the future 8)

Will the original Rect2D be phased out / dissipated in the future? I assume you primarily left it in to not break projects that use Rect2D while scaling / rotating their model and depending on the non-modified Collision Model ( will that person please come forward :roll: )?

Regards,
Kjell
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

Very cool, I will have to update and play with this! Is good news indeed,. thanks a bunch Ville ! could work nicely for may square sprite game eh,.

Kjell- here I is ! I am just working with what i find 'acceptable' for my little test games,. came too close, you died,. these are only fun games not millitary sims, refignment takes time,. . we will get there eventualy, or die trying!
iterationGAMES.com
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hej jph,

Haha :lol: Sorry about that. I did not realize that you make use of CollisionStyle: Rect2D when I wrote that, should have though :wink: The comment was merely intended to question why the new Rect2D_OBB hadn't replaced the old Rect2D, since I don't think that when you can choose between Rect2D and Rect2D_OBB, people will go with the first.

And I agree, the old style Rect2D did not have a adverse influence on CCUG at all. Besides, the one-hit-death mechanic makes me scared enough to try to stay away from enemies ( and the edge of the screen where enemies are spawned ) and their collisions best as I can anyway :P

Kind Regards,
Kjell
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

The reason for keeping the old style rect2d is that is felt more safe to add new code, rather that changing the old working code for rect2d. Also I would have to update all the demo-projects, so I also raise my hand as someone who have projects which depends on the existing collision system ;) . The final reason is that the new style is more cpu-depanding, so if you do not need rotate/scale aware testing then you don't have to "pay" in performance for it.
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hej Ville,

Hmm, would there be any demo projects that stop working / not work as they should when the Rect2D CollisionStyle would behave as the new Rect2D_OBB? But ok, I give in .. the argument that you can save some CPU time when Rect2D is enough ( non-animated obstacles ) is more then valid and indeed reason enough to keep it :wink:

*By the way, perhaps a Circle2D / Radius2D CollisionStyle ( the 2D variant of Sphere3D ) could be useful as well? Low priority though as you can use Sphere3D for now.

Kind Regards,
K
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

2d circle / radius

Post by jph_wacheski »

I have to agree that 2d circle / radius would be a great addition,. must be less cpu than 3Dsphear,. It will be even more great if it worked with the OBB rectange stuff,. although I am quite impressed with the obb so far as loads of objects don't seem to slow it., and it does look great to have it accurate with all the rotation angles of the objects,.
iterationGAMES.com
Post Reply