BASIC

Author Topic: Box2d - 2D physics  (Read 63502 times)

Offline matchy

  • Prof. Inline
  • *****
  • Posts: 1540
    • View Profile
Re: Box2d - 2D physics
« Reply #75 on: 2010-Aug-21 »
The issue could be not GLB related regarding box-to and poly-to collison and I tried setting the those flags in Xcode/Other C Flag and GLB CMP but no difference on compile.
 :(

Adding this to the Box2D.h enabled WinCE compile. It's slow but a quick test it works. Thanks KH.  :booze:
Code: GLBasic [Select]
        inline float cosf(float c){return cos(c);}
        inline float sinf(float c){return sin(c);}
        inline float sqrtf(float c){return sqrt(c);}
        inline float atan2f(float c){return atan2(c,c);}
 


In the meantime I made this cool 3D pool demo (WIP maybe)!  :P :-[ :good:
http://www.youtube.com/watch?v=8vn9uDq0AI8

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10697
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Box2d - 2D physics
« Reply #76 on: 2010-Aug-26 »
Didn't you solve the box-box collision bug by making boxes from poly-objects?

Offline blackway

  • Mr. Polyvector
  • ***
  • Posts: 186
    • View Profile
Re: Box2d - 2D physics
« Reply #77 on: 2010-Aug-26 »
Hello Gernot!
The bug is box to box, box to poly,  poly to poly,
The only thing that works is circle to everything else  including circle to circle.

Did you read the post in the box2d forum??
That guy had exactly the same problem, under windows run ok but have that bug on the iphone...

Finally he found the problem and solution:

"The ClipVertex objects were not created properly in the engine because of a small change I made. Peculiar how it worked on Visual Studio though. I guess some difference in the compilers..."

I don't understand nothing about ClipVertex objects  and how GLbasic is handling =D  but I guess that there is the problem, maybe you need to change something ...

Gernot, we believe in you!  :good:
Bye!






Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10697
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Box2d - 2D physics
« Reply #78 on: 2010-Aug-26 »
his option was to put the "--no-idunnowhat" flag in the CMP box for the iPhone platform in project options.

Offline blackway

  • Mr. Polyvector
  • ***
  • Posts: 186
    • View Profile
Re: Box2d - 2D physics
« Reply #79 on: 2010-Aug-26 »
Are you talking about this???:

"gcc 4.0 has some bugs with agressive optimization, I suggest you to add the -fno-regmove instruction in OTHER_CFLAGS to avoid weird behavior. gcc 4.2 fix the problem."

That's another guy telling that is a good practice to compile with that flags, but he found the solution before that and the solution was on Clipvertex Object's side.

Matchy tried setting those flags in Xcode/Other C Flag and GLB CMP but no difference on compile.

Bye!

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10697
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Box2d - 2D physics
« Reply #80 on: 2010-Aug-27 »
Did he fix box2d and submit the code?

Offline blackway

  • Mr. Polyvector
  • ***
  • Posts: 186
    • View Profile
Re: Box2d - 2D physics
« Reply #81 on: 2010-Aug-30 »
Umm I think that he fix his engine if I don´t understood wrong  :blink:

Offline matchy

  • Prof. Inline
  • *****
  • Posts: 1540
    • View Profile
Re: Box2d - 2D physics
« Reply #82 on: 2010-Sep-06 »
The issue with non circle body collision (circle to box/poly is okay) when compiling for iPhone is lurking a dark cloud and needs to be resolved soon.
I tried the "-fno-regmove" flag in both GLB project options; CMP and, as suggested, in OTHER_CFLAG in XCode but neither made any changes.

I afraid to think about Kitty Hello's suggestion was to import the box2d framework into xcode. :(



Offline blackway

  • Mr. Polyvector
  • ***
  • Posts: 186
    • View Profile
Re: Box2d - 2D physics
« Reply #83 on: 2010-Sep-06 »
Matchy I agree with you, It's needs to be resolved soon !!
Maybe Kitty can contact Erin Catto to ask about this issue  ;)

Offline monono

  • Mr. Polyvector
  • ***
  • Posts: 213
    • View Profile
    • Sockel Lernmedien
Re: Box2d - 2D physics
« Reply #84 on: 2010-Sep-06 »
Is there any way to delete a box after creating it? As far as I know there is no function for that in the Box2d.gbas. I tried to do it myself, but how do I include "void b2World::DestroyBody(b2Body* body)"? I have no clue of C++.

Offline backslider

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 892
    • View Profile
Re: Box2d - 2D physics
« Reply #85 on: 2010-Sep-07 »
try this (copy this function into the box2d.gbas):

Code: GLBasic [Select]
FUNCTION b_destroyBody: body%
INLINE
 bWorld->DestroyBody(bBody(body));
ENDINLINE
ENDFUNCTION
 

Hope it works =)
« Last Edit: 2010-Sep-07 by backslider »

Offline monono

  • Mr. Polyvector
  • ***
  • Posts: 213
    • View Profile
    • Sockel Lernmedien
Re: Box2d - 2D physics
« Reply #86 on: 2010-Sep-07 »
Nice 1 backslider! It works.

I have the urgend feeling that the port is nearly complete if everybody would insert the parts on their harddrives.

To all the heavy-users:
The ordinary GLB user can´t make any games with this. Until now there wasn´t even a way to delete objects. So please start a community edition where you add your parts. :nw:

Offline backslider

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 892
    • View Profile
Re: Box2d - 2D physics
« Reply #87 on: 2010-Sep-08 »
I will search all box2d functions in the forum, add it to the .gbas of this thread and then I will add it here as "userfriendly" box2d-lib :P

If it´s OK for you :D
I need the lib, too.

cheers

Edit: Now I added all functions from this thread.

edited functions:
 - b_CreateCircle (extended parameters)
 - b_CreateBox    (extended parameters)
 - b_CreatePoly   (extended parameters)

new functions:
 - b_DestroyJoint% (function has now code to destroy joints)
 - b_destroyBody    (delete bodys that you don´t need)

That´s all I can find, but should be enough for GLBasic!?! =)

[attachment deleted by admin]
« Last Edit: 2010-Sep-08 by backslider »

Offline blackway

  • Mr. Polyvector
  • ***
  • Posts: 186
    • View Profile
Re: Box2d - 2D physics
« Reply #88 on: 2010-Sep-09 »
Hello to all....
I was searching and searching :)  and I found this:

http://www.box2d.org/forum/viewtopic.php?f=3&t=2688

Matchy, what do you think?
I can't test nothing because I'm at work, If you finally find the solution please share !!!   =D

Offline matchy

  • Prof. Inline
  • *****
  • Posts: 1540
    • View Profile
Re: Box2d - 2D physics
« Reply #89 on: 2010-Sep-19 »
blackway, you thread find has lead me to the solution to iPhone box to box collision!!!  :enc:  :whistle: Simply add -O2 to the cmp. ;)   :good:

I'm thirsty.  :coke: :coke: :coke: