Floor object on iPhone game

Post Reply
Zambiorix
Posts: 8
Joined: Sun Nov 09, 2008 11:09 pm
Location: Belgium

Floor object on iPhone game

Post by Zambiorix »

Hello all

I managed to get bullet work in my iPhone game.

Basically, I have a table (static object) with several balls rolling on top of it.
(a bit like a pool table)
Now I need to make holes in the table (not on the sides, just IN the table), so that if any one ball rolls over a hole, it drops in it. What direction do I need to go to accomplish that?

I have been tinkering height maps but I can't seem to get them working. The vehicle demo crashes on my iMac, so I can see it working from the demo neither, not sure why (2.72).

Actually, my iphone game runs with the height map collision object (it runs VERY slow) but the balls don't drop in the holes.

Can I solve my problem without using height maps?
Are there any algorithms out there that can deliver mesh data for my specific problem?

thank you for your help

regards

Zambi
hearsedriver
Posts: 10
Joined: Thu Nov 06, 2008 8:19 pm

Re: Floor object on iPhone game

Post by hearsedriver »

Why not create the holes directly in your table floor mesh?

hd
Zambiorix
Posts: 8
Joined: Sun Nov 09, 2008 11:09 pm
Location: Belgium

Re: Floor object on iPhone game

Post by Zambiorix »

I'm sorry, my floor object at the moment is just a box. I'm all new to this and trying to figure out how to build a "terrain", even if it is just a table with holes in it :o)

Not sure, how and where to start

Zambi
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Floor object on iPhone game

Post by Erwin Coumans »

Using btBvhTriangleMeshShape would be a good starting point for a static concave mesh.

Check out Bullet/Demos/ConcaveDemo for an example.
Zambiorix
Posts: 8
Joined: Sun Nov 09, 2008 11:09 pm
Location: Belgium

Re: Floor object on iPhone game

Post by Zambiorix »

Thank you

I managed to get it working with btBvhTriangleMeshShape. It was fairly simple after all :)

What i have now is a table with 5 holes in it, 176 vertices and 300 triangles. Together with 1 ball (sphere collision shape)

I must say that the performance on iPhone is not fluent. Not exactly slow, but you can see the iPhone is hard at work. Is this the kind of performance I can expect? Or should iPhone be able to handle more objects?

Before this, my table was just a box collision shape, and together with 4 balls, animation was fluent. When putting more than 16 balls in my world, animation started to degrade.

I'm just curious if this is what I can expect. Are there specific optimizations I could do to have better performance?
(I reduced the the memory usage as suggested in other threads)

Thanks
Zambi
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Floor object on iPhone game

Post by Erwin Coumans »

So the total number of triangles in the btBvhTriangleMeshShape is just 300?

Did you test performance in release/optimized mode or debug? We will likely improve iPhone performance, as part of the Oolong Engine iPhone integration.

Can you help profiling this setup, to see which part takes most time?
Thanks,
Erwin
Zambiorix
Posts: 8
Joined: Sun Nov 09, 2008 11:09 pm
Location: Belgium

Re: Floor object on iPhone game

Post by Zambiorix »

That is correct, just 300 triangles.

In the mean time, I wrote a routine to create a table mesh with random amount of holes that reduces the triangle count as much as possible. I was able to reduce it to about 90 triangles for seven holes (previously 342), with the same mesh quality.

Performance is ok (running at 57 FPS, with 5 balls). Occasionally i get hiccups (where animation gets interrupted for a fraction of a second). Don't know where that comes from.

Animation is definitely faster in release/optimized mode, and there is a performance increase when the the iPhone is not connected to my iMac. (i guess some background communication is taking place)

Don't have experience with profiling yet, I guess, it's measuring the executing costs of function calls .. etc? Have to look into that for sure.

I'm writing my own game engine. Are the specific iPhone optimizations for Bullet going to be available outside the Oolong project?

Hey, Erwin, I noticed that you are in California and your name definitely sounds Dutch or Belgian. I'm Belgian, by the way.

Thank you for your help so far

Gerd
Zambiorix
Posts: 8
Joined: Sun Nov 09, 2008 11:09 pm
Location: Belgium

Re: Floor object on iPhone game

Post by Zambiorix »

Managed to get some timing

Step = time to preform a StepSimulation (sec)
Update = specific for my game engine (sec)
Render = pure rendering (sec)

------------------------------------------------------------------------------------

table mesh = 84 triangles; 5 object (box collision) for table boundaries; 32 balls (sphere collision)

Step = 0.028947 : Update = 0.000451 : Render = 0.005536 : Total = 0.034964 = FPS = 28.601
Step = 0.029774 : Update = 0.000452 : Render = 0.005668 : Total = 0.035923 = FPS = 27.837
Step = 0.031337 : Update = 0.000448 : Render = 0.005500 : Total = 0.037312 = FPS = 26.801
Step = 0.028289 : Update = 0.000451 : Render = 0.005690 : Total = 0.034459 = FPS = 29.020

------------------------------------------------------------------------------------

table mesh = 84 triangles; 5 object (box collision) for table boundaries; 16 balls (sphere collision)

Step = 0.015295 : Update = 0.000287 : Render = 0.006104 : Total = 0.021711 = FPS = 46.060
Step = 0.015734 : Update = 0.000288 : Render = 0.004086 : Total = 0.020132 = FPS = 49.672
Step = 0.015833 : Update = 0.000289 : Render = 0.004138 : Total = 0.020285 = FPS = 49.297
Step = 0.014951 : Update = 0.000283 : Render = 0.005733 : Total = 0.020996 = FPS = 47.628

------------------------------------------------------------------------------------

table mesh = 84 triangles; 5 object (box collision) for table boundaries; 8 balls (sphere collision)

Step = 0.008863 : Update = 0.000199 : Render = 0.003560 : Total = 0.012812 = FPS = 78.052
Step = 0.008572 : Update = 0.000198 : Render = 0.002970 : Total = 0.011763 = FPS = 85.012
Step = 0.009187 : Update = 0.000203 : Render = 0.002917 : Total = 0.012332 = FPS = 81.090
Step = 0.009511 : Update = 0.000213 : Render = 0.002944 : Total = 0.012694 = FPS = 78.777

------------------------------------------------------------------------------------

table mesh = 84 triangles; 5 object (box collision) for table boundaries; 1 ball (sphere collision)

Step = 0.001430 : Update = 0.000120 : Render = 0.002167 : Total = 0.003740 = FPS = 267.381
Step = 0.001661 : Update = 0.000146 : Render = 0.003188 : Total = 0.005307 = FPS = 188.430
Step = 0.001687 : Update = 0.000140 : Render = 0.002815 : Total = 0.004677 = FPS = 213.812
Step = 0.000107 : Update = 0.000126 : Render = 0.013618 : Total = 0.013890 = FPS = 71.994
Step = 0.002080 : Update = 0.000145 : Render = 0.002820 : Total = 0.005071 = FPS = 197.199
Step = 0.001389 : Update = 0.000120 : Render = 0.002163 : Total = 0.003694 = FPS = 270.709
Step = 0.001646 : Update = 0.000139 : Render = 0.002763 : Total = 0.004588 = FPS = 217.960

------------------------------------------------------------------------------------

I just noticed a serious drop in render times every 20 (or so) frames. Nothing special is going on, just the stepsimulation.

I also notice a linear decrease in step time when I double the amount of balls in my scene.

hope this helps a bit
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Floor object on iPhone game

Post by Erwin Coumans »

I need more precise timings. Please get the latest SVN trunk, or unzip the attached btQuickProf.zip (.h/cpp) into your Bullet/src/LinearMath folder.

Then, please add the following line directly after your stepSimulation call:

Code: Select all

CProfileManager::DumpAll();
Can you copy/paste the console output here?
Thanks,
Erwin
Attachments
btQuickprof.zip
(5.1 KiB) Downloaded 244 times
Zambiorix
Posts: 8
Joined: Sun Nov 09, 2008 11:09 pm
Location: Belgium

Re: Floor object on iPhone game

Post by Zambiorix »

Hello Erwin

I'm getting the following compile error when adding your code:

/Volumes/Documents/Projects/Library/GZELIBBullet/Bullet/src/btQuickprof/btQuickprof.cpp:284: error: no 'void CProfileManager::DumpRecursive(CProfileIterator*, int)' member function declared in class 'CProfileManager'

/Volumes/Documents/Projects/Library/GZELIBBullet/Bullet/src/btQuickprof/btQuickprof.cpp:331: error: no 'void CProfileManager::DumpAll()' member function declared in class 'CProfileManager'

Build failed (2 errors)

I'm working with version 2.72 (the latest for download)
Zambiorix
Posts: 8
Joined: Sun Nov 09, 2008 11:09 pm
Location: Belgium

Re: Floor object on iPhone game

Post by Zambiorix »

Ok

It worked, uploaded is a sample of timing on iPhone

32 spheres, 4 boundary boxes and a trimesh with about 80 triangles



Is the performance normal?
Attachments
iPhone_timing.zip
(14.96 KiB) Downloaded 250 times
Post Reply