Slick Forums

Discuss the Slick 2D Library
It is currently Thu Aug 16, 2018 4:43 am

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Thu Sep 04, 2008 10:48 pm 
Offline

Joined: Thu May 10, 2007 1:36 am
Posts: 4
In the latest version of phys2d, the collision mask changed from "things that do collide with each other" to "things that don't collide with each other". I had been using the "things that do collide with each other" model to make it so that tanks collide with each other and bushes, and helicopters collide with each other, but not tanks or bushes. I would like some advice on a new way to do this. Perhaps there is something that I am missing.

As I see it, I have the following options:
1. Use an old version of the library, or modify the library and maintain a modified version of the library
2. go through and add for each body that doesn't collide with another, add it to the exceptions list (I expect that this would slow the game down).

Any thoughts or advice on how to proceed would be appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 05, 2008 12:37 am 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
I hadn't realised:

a) It had changed
b) Anyone was using the masking functionality.

Using the exceptions list would be very slow as you pointed out. I'd suggest we change it so the masking can work either way and there's a flag on the world to control it?

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 05, 2008 12:57 am 
Offline

Joined: Thu May 10, 2007 1:36 am
Posts: 4
That would be awesome. Should make everyone happy. From what I can tell, this is the diff of the affected code.

Quote:
Modified /trunk/phys2d/src/net/phys2d/raw/Body.java diff
...
113 113 private boolean gravity = true;
114 114
115 115 /** The collision group bitmask */
116 - private long bitmask = 0xFFFFFFFFFFFFFFFFL;
116 + private long bitmask = 0; //0xFFFFFFFFFFFFFFFFL;
117 117 /** A hook for the library's user's data */
118 118 private Object userData = null;
119 119 /** The old position */
...


Modified /trunk/phys2d/src/net/phys2d/raw/CollisionSpace.java diff
...
149 149 if (bj.disabled()) {
150 150 continue;
151 151 }
152 - if ((bitmask & bi.getBitmask() & bj.getBitmask()) == 0) {
152 + if ((bi.getBitmask() & bj.getBitmask()) != 0) {
153 153 continue;
154 154 }
155 155 if (bi.getExcludedList().contains(bj)) {


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 05, 2008 11:18 am 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
In SVN:

Code:
   /**
    * Set whether the bitmask provided on the bodies is used to exclude collision
    * between bodies or include bodies in collision.
    *
    * @param bitmaskExcludes True if the bitmask is used to exclude one body from
    * another
    */
   public void setBitmaskExclusion(boolean bitmaskExcludes) {
      this.bitmaskExcludes = bitmaskExcludes;
   }


On collision space, hence World.

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 05, 2008 12:48 pm 
Offline

Joined: Thu May 10, 2007 1:36 am
Posts: 4
That was fast, thanks.

By the way, Slick and Phys2d are both awesome libraries. Easy and fun to use.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 05, 2008 10:44 pm 
Offline

Joined: Thu May 10, 2007 1:36 am
Posts: 4
I fired it up and everything worked great. Thanks for the lightning fast response on that.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 05, 2008 11:10 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Thanks for testing. I'll get the build up asap.

Ke


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group