Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (429)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (468)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Mass bug  (Read 928 times)
0 Members and 1 Guest are viewing this topic.
Offline t_larkworthy

Senior Member


Medals: 1
Projects: 1


Google App Engine Rocks!


« Posted 2005-08-22 01:46:53 »

I have been having loads of difficulties getting my mass stuff to work. I had alot of non-deterministic crashes. The crashed are memory violations. I think I have traced the fault to how the mass is associated with a Body.
I found that if I kept a reference to the original dMass object, not just the pointer, everything seemed to work. So I am thinking that SWIG is deallocating the memory when Java garbage collects the dMass object (becuase after Body construction there are no longer any pointers to the object). I beleive there are settings in SWIG to stop that happening, but I think it is much easier just to keep the reference.

Runesketch: an Online CCG built on Google App Engine where players draw their cards and trade. Fight, draw or trade yourself to success.
Offline t_larkworthy

Senior Member


Medals: 1
Projects: 1


Google App Engine Rocks!


« Reply #1 - Posted 2005-08-22 02:13:08 »

Oh yeah. Further to that I found some strange things going on in the Body source. addGeom() calls setDefaultMass(), which may not be the behavior a user would expect. It basically means the last box or sphere that is added (NOT a transformed geometry) will erase all previous mass information and  be used to define the mass.

I have also found it helpful for me to expose the mass Cptr so that I can use the low level mass routines.


Runesketch: an Online CCG built on Google App Engine where players draw their cards and trade. Fight, draw or trade yourself to success.
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #2 - Posted 2005-08-22 15:47:41 »

OK, so what do you suggest then?

* I'm happy to expose the mass pointer as an "unsupported" function.  Do you mean the massId instance variable?  I notice there is already a getMass.
* where is the dereference/where should the reference be kept, I can't see it
* regarding setDefaultMass(), if we remove this, I guess people relying on this feature will need to change their code?  Will it cause problems if it isn't called?  If so, we could make it backward compatable, but it may get even more confusing.

Regards,

Will.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline t_larkworthy

Senior Member


Medals: 1
Projects: 1


Google App Engine Rocks!


« Reply #3 - Posted 2005-08-23 10:43:02 »

Yeah. I was thinking about backward compatability. Perhaps setDefaultMass should stay in addGeom. An overloaded version could be addGeom(..., boolean setMass);
But even so, this method would still be a bit crappy because it would ignore GeomTransforms and a more expected behavior from a users point of view would be that the mass should be altered and not set. The ideal logic would use the low level mass functions for creating a mass for the underlying geom, translating that mass, and then adding the mass to the current mass parameters. Its one of those things that is probably 4 lines of code but quite hard to tell if its actually working or not so maybe this issue should be ignored.

As for the dMass reference in the constructor I see:
1  
2  
3  
4  
public Body(String name, World world, PlaceableGeom geom) {
....
dMass mass = new dMass();
massId = mass.getCPtr();


I am saying the mass object should be declared not as a local variable but as a field of Body, to avoid garbage collection.


Runesketch: an Online CCG built on Google App Engine where players draw their cards and trade. Fight, draw or trade yourself to success.
Offline ewills

Junior Member




Java skeletal animation systems rock!


« Reply #4 - Posted 2005-08-25 18:36:40 »

Are you using the latest build from CVS?  I committed fixes for both of these issues a while ago...

http://192.18.37.44/forums/index.php?topic=7822.0
http://192.18.37.44/forums/index.php?topic=7094.0
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

theagentd (6 views)
2014-04-24 23:00:44

xsi3rr4x (83 views)
2014-04-15 18:08:23

BurntPizza (75 views)
2014-04-15 03:46:01

UprightPath (86 views)
2014-04-14 17:39:50

UprightPath (69 views)
2014-04-14 17:35:47

Porlus (86 views)
2014-04-14 15:48:38

tom_mai78101 (109 views)
2014-04-10 04:04:31

BurntPizza (169 views)
2014-04-08 23:06:04

tom_mai78101 (265 views)
2014-04-05 13:34:39

trollwarrior1 (216 views)
2014-04-04 12:06:45
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!