Shaun, thanks for checking it out.  Yah, I agree that the real
complexity of a physics engine comes from joints and contact
constraints.  The constraints in my demo are simple minimum distance
constraints.  I have a 2D rigid body physics engine that I'm thinking
more and more about porting over to Android as well.  This demo was
more of a calibration for myself to see how much computation I can do,
and what optimizations lead to the largest improvements.  I'll
probably turn it into a fun toy for the Market and then look into
rewriting my rigid body engine for Android.

    Reading through Simpull I noticed that you allocate a new Vector3f
in your Verlet update routine.  I think that will be a killer on the
Android platform because of it's rudimentary garbage collector and
limited RAM.  My solution was to allocate an array of fixed point
numbers, four per ball.  Effectively a vector pool that didn't require
any management because the number of balls never changed.

On Apr 2, 6:31 am, shaun <[email protected]> wrote:
> I took a look at Anton's demo on a G1 device, and I was glad to see
> the integration of accelerometer as it really added value.  I assume
> the calculations for collision detection and response are fairly
> basic, which allows for that performance.
>
> Simpull will also provide good performance for a scene of that nature
> (all verlet, no joints).  At least I believe it will.  The point where
> simpull becomes slow is when a more complex scene is in play with 10s
> of objects with many joints connecting some of them.  Since the engine
> is all verlet and no rigid body dynamics, joints are one way to
> acheive a similar result, but with a very bad performance hit due to
> all the new temporary objects and new calculations.
>
> I would be super impressed to see a demo like Anton's with rigid body
> dynamics involved with at least some rectangles, if not other polygons
> and perhaps a joint or two.  That is where the performance degrades
> quickly in my experience.
>
> On Apr 1, 2:45 pm, mscwd01 <[email protected]> wrote:
>
> > Thanks Lajos for pointing APE out, I hadn't heard of it until now.
>
> > Unfortunately your link to your Android port is broken, can you mend
> > it as I dont fancy spending another hour porting another library to
> > Android :D
>
> > Thanks
>
> > On Mar 31, 9:50 pm, lkelemen <[email protected]> wrote:
>
> > > Hello everyone,
>
> > > I was also disappointed with jbox2d's performance so I checked APE
> > > (Actionscript Physics Engine) fromhttp://www.cove.org/ape/.
> > > It was converted to java (http://www.cove.org/ape/java_ape.zip) so I
> > > started to convert the java version to Android.
>
> > > The performance is quite OK for 10-20 objects at the first start of
> > > the app but if you exit with the back key and restart it form the
> > > installed copy
> > > (either in the emulator or on the dev phone) then it gets slower and
> > > slower with each start. If you restart it from the emulator (by
> > > reinstalling it) then it is faster again.
> > > Neither the pressed keys are not working (probably it is because of my
> > > poor Android programming knowledge).
>
> > > Here is a zipped Android project of it. Please experiment with it and
> > > send results to here i.e. is it slow for you also after re-re-re-..
> > > staring?www.kotiposti.net/lkelemen/android/testape2d.zip
>
> > > thanks
> > > Lajos Kelemen
>
> > > On Mar 31, 9:26 pm, shaun <[email protected]> wrote:
>
> > > > I started going down the path of Object pooling.  It seemed the only
> > > > solution when taking an existing engine and making work on a resource
> > > > constrained system like Android on a phone.  Determining the strategy
> > > > for returning objects to the pool proved quite tough for me.  I have
> > > > no doubt there are some experts on embedded systems programming with
> > > > tons of experience with object pooling.  We just would be too lucky if
> > > > that person(s) was also experienced with Java, physics engines and had
> > > > a passion for open source and games!  Is that too much to ask?  LOL!!
>
> > > > On Mar 31, 12:17 pm, mscwd01 <[email protected]> wrote:
>
> > > > > Thanks for your feedback Shaun, I too unfortunately think a bespoke
> > > > > engine will need to be written for Android, which is a real pity as
> > > > > the iPhone has several physics engines which can easily handle
> > > > > hundreds of objects.
>
> > > > > Having said that Anton (2nd reply) has said he has an engine running,
> > > > > it would be nice to see a demo of this if that'd be possible?
>
> > > > > Clark, i'd definately host any .apk's on my own site, I wouldn't put
> > > > > it on the marketplace if it wasn't a "finished" app - do people
> > > > > actually do that?!
>
> > > > > I think i'll stay away from developing games with physics for the time
> > > > > being and concentrate on something else, I cant see it being feasible
> > > > > to include it any time soon which is a real pity.
>
> > > > > On Mar 31, 3:28 pm, shaun <[email protected]> wrote:
>
> > > > > > I am the author ofsimpull.
>
> > > > > > Sorry guys for the demo being out of whack forSimpullto the Core.
> > > > > > The version of PulpCore that I integratedsimpullwith did not support
> > > > > > Chrome, but you should be able to see it in IE, FF Safari.  It is 
> > > > > > nice
> > > > > > to take a look at that demo to get a feel for what the engine is
> > > > > > capable of, but the performance does not translate over to the fixed
> > > > > > point branch/version ofsimpullwhen running on Android.
>
> > > > > > I ran tests on both the emulator and the actual device and there 
> > > > > > was a
> > > > > > significant increase in performance because of the fixed point
> > > > > > implementation, but I got very frustrated that it still did not
> > > > > > support the amount of objects in a scene that I considered good for 
> > > > > > a
> > > > > > physics-based game.  It seemed to handle ~10 objects moving and
> > > > > > colliding OK.  It has been a while since I was playing with it, so I
> > > > > > do not really remember the exact number of objects or the frame 
> > > > > > rate.
> > > > > > I mostly remember being upset with it.
>
> > > > > > I am leaving the physics ideas for games out of the picture when
> > > > > > thinking Android for now.  Someone would have to write a ground up
> > > > > > engine with all the performance and memory concerns of Android in
> > > > > > mind, which was not the case withSimpull.....I created it for
> > > > > > applets, then thought to port over to fixed-point for Android.  It
> > > > > > works well with small scenes, but certainly not the staple engine to
> > > > > > use in my opinion.
>
> > > > > > Also, Phys2D will not run worth a damn on Android.  I tried it and I
> > > > > > even went through some heavy performance tuning.  Garbage collection
> > > > > > is the major issue even after all I did.  I seriously doubt JBox2D
> > > > > > will run well either.  I'll stick to what I said earlier, a 
> > > > > > ground-up
> > > > > > solution by someone smarter than me is probably required.
>
> > > > > > On Mar 31, 9:49 am, "[email protected]"
>
> > > > > > <[email protected]> wrote:
> > > > > > > Not tried but if you can provide us with some example source code 
> > > > > > > or
> > > > > > > put something on the market, I'm sure we could take a look.
>
> > > > > > > G1 performance is significantly faster than emulator, but there 
> > > > > > > are
> > > > > > > limitations.
>
> > > > > > > Particularly with garbage collection and memory allocation on code
> > > > > > > that gets run continuously in loops, so I don't know how optimised
> > > > > > > these physics engines are for this purpose.
>
> > > > > > > Would be interesting to find out though.
>
> > > > > > > On Mar 31, 12:52 pm, mscwd01 <[email protected]> wrote:
>
> > > > > > > > Oh I forgot to re-ask...
>
> > > > > > > > "Has anyone tested Phys2D or JBox2D on an actual device to see 
> > > > > > > > if they
> > > > > > > > run better than on the emulator?
>
> > > > > > > > I have a feeling the performance will better on a G1 than the 
> > > > > > > > emulator
> > > > > > > > for some reason!
>
> > > > > > > > On Mar 31, 12:51 pm, mscwd01 <[email protected]> wrote:
>
> > > > > > > > > I did take a look atSimpull, however the demo application 
> > > > > > > > > failed to
> > > > > > > > > run as it relied on some library which wasn't supplied or 
> > > > > > > > > referenced
> > > > > > > > > to - I just got annoyed after spending two days failing to 
> > > > > > > > > get Phys2D
> > > > > > > > > and JBox2D to work in Android and didn't bother trying to 
> > > > > > > > > work out the
> > > > > > > > > problems!
>
> > > > > > > > > I might give it another look though...
>
> > > > > > > > > On Mar 30, 10:41 pm, Streets Of Boston 
> > > > > > > > > <[email protected]>
> > > > > > > > > wrote:
>
> > > > > > > > > > I wonder how well this one works on Android:
>
> > > > > > > > > >  http://code.google.com/p/simpull/
>
> > > > > > > > > > -- Anton Spaans
>
> > > > > > > > > > On Mar 30, 4:58 pm, Anton <[email protected]> wrote:
>
> > > > > > > > > > >     I have a simple 2D physics engine written and 
> > > > > > > > > > > running.  It uses
> > > > > > > > > > > the now famous Jacobson physics tricks (Verlet 
> > > > > > > > > > > integration and hard
> > > > > > > > > > > constraints).  I can manage 40 balls on the screen, with 
> > > > > > > > > > > fill n^2
> > > > > > > > > > > interaction between balls.  I am working on spatial data 
> > > > > > > > > > > structure
> > > > > > > > > > > optimizations now to improve the computational complexity 
> > > > > > > > > > > of the
> > > > > > > > > > > collision detection code.  I run the constraint update 
> > > > > > > > > > > loop five times
> > > > > > > > > > > per frame and get 30 frames per second.  Once the engine 
> > > > > > > > > > > is up and
> > > > > > > > > > > running there are no memory allocations done in my 
> > > > > > > > > > > program.  And once
> > > > > > > > > > > the system settles down from the app launch there are 
> > > > > > > > > > > very few GC
> > > > > > > > > > > events from other programs.  Though they do still happen. 
> > > > > > > > > > >  Viewing
> > > > > > > > > > > LogCat I see a GC every 10 or 20 seconds because of some 
> > > > > > > > > > > background
> > > > > > > > > > > application.  But between those events I get a consistent 
> > > > > > > > > > > frame rate.
> > > > > > > > > > > I am using OpenGL for my rendering.
>
> > > > > > > > > > >     -Anton
>
> > > > > > > > > > > On Mar 30, 1:14 pm, mscwd01 <[email protected]> wrote:
>
> > > > > > > > > > > > Does anyone know of, or have implemented, a physics 
> > > > > > > > > > > > engine which runs
> > > > > > > > > > > > smoothly in Android?
>
> > > > > > > > > > > > I have spent the last couple of days trying Phys2D and 
> > > > > > > > > > > > JBox2D, however
> > > > > > > > > > > > both perform very poorly - I am struggling to get even 
> > > > > > > > > > > > a few objects
> > > > > > > > > > > > to simulate smoothly as frequent garbage collection 
> > > > > > > > > > > > spoils it.
>
> > > > > > > > > > > > One question I do have is will these run smoother on an 
> > > > > > > > > > > > actual G1
> > > > > > > > > > > > device or is the performance of the emulator accurate?
>
> > > > > > > > > > > > Thanks- Hide quoted text -
>
> > > > > > > > > > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to