Jump to content


Photo

Gmode Physics V0.50b - Gm 6/7/8 Support


  • Please log in to reply
80 replies to this topic

#1 Keth

Keth

    GMC Member

  • New Member
  • 164 posts

Posted 03 September 2008 - 06:19 PM

Posted Image
GMODE is 2D physics library based on ODE (Open Dynamic Engine) physics.

Follow progress on Twitter here.

UPCOMING FEATURES IN GMODE V2.0!
Contact me (MSN/PM) if you would like to test the alpha before v2.0 gets released as beta.
  • [DONE] Whole code will be rewritten (C++ this time) and physics will be based on newest ODE svn version
  • Proper documentation of all functions
  • [DONE] Cleaner, easier to use code
  • [DONE] All ODE functions are compiled inside GMODE.dll. This means ODE.dll will no longer be used separately.
  • [DONE] All memory leaks are fixed (not a single leak of a byte with 3000 bodies and constant flow of them)
  • [DONE] Huge speed improvements (around 410% faster comparing the older version of GMODE)
  • Collision layers between bodies
  • [DONE] Realistic fluids simulation example (see videoes below for an example)
  • [DONE] Stiffness and repulsion of each particle body (with the right settings, you can re-create particle movement such as water, sand, mochi, tensile, smoke, fire, air, etc)
    Example: http://www.youtube.c...h?v=BIjSvkT8nKk
    Stress Test: http://www.youtube.c...h?v=yoV9N8Yw3pI (the performance will still keep improving)
  • [DONE] 100% Stability guaranteed as long as large forces/frictions aren't applied
  • [PROGRESS] Multi-threading is the thing I am focusing on mostly (has been over 2 weeks) and it seems to be going well (significant speed
    improvements)
  • Wiggling particles (just to add some realism - e.g. for sparks)
  • Dynamic convex/concave shapes - will be implemented in late testing
  • Blob bodies, destructible bodies and meltable bodies - those are pretty much future plans and considering the performance none of those are going to be a problem
  • Bugs? Suggestions?
  • Breakable joints?
NEW! Features v0.50b:
  • Support for Gamemaker 7 and 8 (GM6 version will no longer be updated - you can use old one though)
  • Cleaner function names (few got renamed)
  • New arguments for physx_start and physx_body_update
Features v0.30:
  • Trimesh avaible (static only)
  • New examples (motor and playground)
  • Lots of new functions (damping, max rotation, pausing physics, fixed step etc)
  • New line shape which can be used as terrain aswell
  • Minor optimizations
Features v0.26:
  • New functions
  • Up to 50% faster (only while having more than 100 bodies)
  • Joints added (fixed, hinge and slider)
Features v0.2 Beta:
  • Realistic rigid-bodies
  • Really simple to use
  • Find out exact collision points
  • Disable or enable collision between given bodies
  • and more...

Keep in mind this is just a beta. I did not focus on the features but stability and speed.
Upcoming versions will include lots of speed improvements.

Please report all the bugs and post suggestions for next release!

Screenshots:
Posted Image

Posted Image

Links:

For Gamemaker 7.0+ (GEX):
Posted Image
Link dead? http://www.mediafire.com/?immqymnz24e

For any other language e.g. C++ (DLL only):
Click here to download!

Old version of GMODE v0.30 for Gamemaker 6.0 (DLL):
Posted Image

Edited by Keth, 11 July 2010 - 03:37 PM.

  • 0

#2 posva

posva

    GMC Member

  • New Member
  • 610 posts
  • Version:GM8

Posted 03 September 2008 - 06:50 PM

if it don't work with GM 7 i can't try it :lol:
  • 0

#3 Keth

Keth

    GMC Member

  • New Member
  • 164 posts

Posted 03 September 2008 - 07:05 PM

if it don't work with GM 7 i can't try it :lol:


The EXE file attached inside the archive will work.
You just won't be able to compile gm6 file.
  • 0

#4 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 03 September 2008 - 08:35 PM

Wow, I've heard people say that GM can't handle 100 physical objects and maintain FPS. You had more. Great work.

I really think it can use a fix for GM7 but it's fine for me.

Edited by GMREC1111, 03 September 2008 - 08:36 PM.

  • 0

#5 Keth

Keth

    GMC Member

  • New Member
  • 164 posts

Posted 03 September 2008 - 09:27 PM

Wow, I've heard people say that GM can't handle 100 physical objects and maintain FPS. You had more. Great work.

I really think it can use a fix for GM7 but it's fine for me.


Thanks for the support!
GM7 is supported now.

Edited by Keth, 01 May 2010 - 09:43 PM.

  • 0

#6 Newly Discovered

Newly Discovered

    Harmonious Genius

  • GMC Member
  • 2475 posts
  • Version:GM8

Posted 03 September 2008 - 09:32 PM

neat, but you have a long way to go if you're attempting a full engine. two shapes that roll around isn't going to cut it.
good luck.
  • 0

poof_sig.png


#7 Keth

Keth

    GMC Member

  • New Member
  • 164 posts

Posted 03 September 2008 - 11:13 PM

I have tried to optimize the physics using packed data (1 call per step for all bodies) but parsing the long string containing x,y,rotation for 100 bodies is a lot slower.
The Gamemaker isn't that fast in long string handling.

I guess this is the fastest way possible to do physics in Gamemaker.
The only things left now are features I will work as soon as I will find some free time.

Edit: I managed to optimize it 50% faster in 0.26 version.
See physx_body_update script for details.

Edited by Keth, 06 September 2008 - 09:23 AM.

  • 0

#8 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 17098 posts
  • Version:GM:Studio

Posted 03 September 2008 - 11:59 PM

I have tried to optimize the physics using packed data (1 call per step for all bodies) but parsing the long string containing x,y,rotation for 100 bodies is a lot slower.
The Gamemaker isn't that fast in long string handling.

I guess this is the fastest way possible to do physics in Gamemaker.
The only things left now are features I will work as soon as I will find some free time.



Refer to the bullet dll thread for tips on how to bypass GM's API speed issues.


I get an Unexpected Error. Under GM7 and Vista.
  • 0

#9 Keth

Keth

    GMC Member

  • New Member
  • 164 posts

Posted 04 September 2008 - 01:16 AM

I have tried to optimize the physics using packed data (1 call per step for all bodies) but parsing the long string containing x,y,rotation for 100 bodies is a lot slower.
The Gamemaker isn't that fast in long string handling.

I guess this is the fastest way possible to do physics in Gamemaker.
The only things left now are features I will work as soon as I will find some free time.



Refer to the bullet dll thread for tips on how to bypass GM's API speed issues.

Thanks about the speed issue information. I think this might be faster way.

I get an Unexpected Error. Under GM7 and Vista.

GM7 supported now.

Edited by Keth, 01 May 2010 - 09:44 PM.

  • 0

#10 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 04 September 2008 - 10:22 AM

I see you've come to a good start, it's nice and simple. Just needs more predefined shapes and custom defining of shapes.
  • 0

#11 OpticalLiam

OpticalLiam

    GMC Member

  • New Member
  • 782 posts

Posted 04 September 2008 - 01:45 PM

Very nice work, I managed to get around 450 circles before it started to dip below 100FPS. Now you need to add support for rigid bodies of any shape.
  • 0

#12 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 04 September 2008 - 07:35 PM

Can you also fix the counter, it doesn't reset. Use instance_count(object) to get it or reset each time you hit R.
  • 0

#13 fire_soul453

fire_soul453

    aarons video games

  • GMC Member
  • 542 posts

Posted 05 September 2008 - 01:59 AM

Pretty cool. Might be useful once you update it more. Keep working on it.
  • 0
Game maker Top sites
I'm sick of paypal. From now on I'm not buying indie games unless I can use something else...

#14 ShaX

ShaX

    GMC Member

  • New Member
  • 246 posts

Posted 05 September 2008 - 04:15 AM

Ah, excellent! I am a very big fan of the ODE engine and use it almost exclusively in my developments. Steffen Itterheim has ported almost the entire ODE library to Game Maker back in 2004, and that's what I've been using since, but there are many flaws and/or errors with his dll and, well, he really doesn't come around here any more. So I look forward to your implementation and will be checking up for future updates frequently. Best of luck!
  • 0

#15 Paper Carnival

Paper Carnival

    GMC Member

  • New Member
  • 12 posts

Posted 05 September 2008 - 08:59 AM

This is amazing. Great job! I'll want to use it for my game, so I'm anxiously waiting for GM7 compatibility.

Edit: Can we apply a force to a specific object, or create explosion effects, etc? Or is that a feature to be implemented later?

Also, if possible, I'd suggest more options on how to dynamically affect the ODE "world" through Game Maker (eg set the x, y and rotation of a material).

Edited by Paper Carnival, 05 September 2008 - 09:10 AM.

  • 0

#16 them4n!ac

them4n!ac

    GMC Member

  • New Member
  • 1170 posts

Posted 05 September 2008 - 09:34 AM

please fix the memory leaks! ;)
Posted Image

EDIT:
and why there's PhysX?
that's a copyrighted trademark, you can't use it like this ^_^

Edited by them4n!ac, 05 September 2008 - 09:35 AM.

  • 0
what do you xpect to see here? another signature?
Cloud texture generator / renderer

#17 Keth

Keth

    GMC Member

  • New Member
  • 164 posts

Posted 05 September 2008 - 01:46 PM

please fix the memory leaks! ;)
<image>

EDIT:
and why there's PhysX?
that's a copyrighted trademark, you can't use it like this ^_^


Damn, I totally forgot about checking memory leaks.
Thanks for information!

About PhysX, On the beggining I've been doing AGEIA PhysX with those functions but then I changed to ODE because doing 2D in PhysX was a lot harder.
Now there is a lot of changing but I'm sure that AGEIA doesn't mind :D

Edit:
There is no memory leak. My memory usage for rigid_bodies.exe is static after creating 200 bodies (15,536 and doesn't change for 5 minutes).
Have you been adding new bodies while the graph was going up?

Edited by Keth, 05 September 2008 - 01:52 PM.

  • 0

#18 them4n!ac

them4n!ac

    GMC Member

  • New Member
  • 1170 posts

Posted 05 September 2008 - 03:22 PM

Delete the bodies, and you'll see the leak. ;)
Memory allocation doesn't make the leak if that memory is freed after usage. ^_^

Edited by them4n!ac, 05 September 2008 - 03:22 PM.

  • 0
what do you xpect to see here? another signature?
Cloud texture generator / renderer

#19 Keth

Keth

    GMC Member

  • New Member
  • 164 posts

Posted 05 September 2008 - 03:25 PM

Delete the bodies, and you'll see the leak. ;)
Memory allocation doesn't make the leak if that memory is freed after usage. ^_^


Oh, thanks for information.
Will be fixed in next release.
  • 0

#20 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 06 September 2008 - 02:50 AM

Hmm, do you know if ODE has deactivating objects? As in, if it doesn't move for a while, it is cut out of the loop to not waste speed?
  • 0

#21 Keth

Keth

    GMC Member

  • New Member
  • 164 posts

Posted 06 September 2008 - 06:24 AM

Hmm, do you know if ODE has deactivating objects? As in, if it doesn't move for a while, it is cut out of the loop to not waste speed?


Yeap, it does and I will add this feature soon.
Edit: Added as a global for all bodies for now. I will be adding in future for given bodies aswell.

Edited by Keth, 06 September 2008 - 09:20 AM.

  • 0

#22 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 06 September 2008 - 01:47 PM

Ok, that should manage speed problems for now...
  • 0

#23 Keth

Keth

    GMC Member

  • New Member
  • 164 posts

Posted 07 September 2008 - 11:57 PM

Okay guys, I have almost managed to create a trimesh shape.
It's really hard doing it in 2D because the shape is done in 3D.
The worst part (understanding the mesh data) is behind me.
  • 0

#24 Paper Carnival

Paper Carnival

    GMC Member

  • New Member
  • 12 posts

Posted 08 September 2008 - 11:02 AM

Nice!

I noticed a bug. When I manage to immobilize the rope, it stays fixated to its current position, even when I apply a force to it with the left and right key. Removing the bodies won't make the rope move, unless I hit it with something.

Also, a similar thing happens when I add bodies between the parts of the rope. The rope is immobilized when hanging mid-air, like this:
Posted Image

The only way to move it again is to hit it with another body.

I suppose you made the rope deactivate at certain cases to save CPU power and it doesn't become activated again when it should...

I don't suppose you figured out a fix for GM 7 yet?
  • 0

#25 Keth

Keth

    GMC Member

  • New Member
  • 164 posts

Posted 08 September 2008 - 02:01 PM

Nice!

I noticed a bug. When I manage to immobilize the rope, it stays fixated to its current position, even when I apply a force to it with the left and right key. Removing the bodies won't make the rope move, unless I hit it with something.

Also, a similar thing happens when I add bodies between the parts of the rope. The rope is immobilized when hanging mid-air, like this:
<image>

The only way to move it again is to hit it with another body.

I suppose you made the rope deactivate at certain cases to save CPU power and it doesn't become activated again when it should...


All the objects are disabled if they aren't moving. It's possible to set the minimum force to disable the body.
physx_world_set_linear_autodisable(0.02); // minimum velocity
physx_world_set_angular_autodisable(0.02); // minimum torque

---

I don't suppose you figured out a fix for GM 7 yet?

Edit: It is supported now.

Edited by Keth, 01 May 2010 - 09:47 PM.

  • 0

#26 Keth

Keth

    GMC Member

  • New Member
  • 164 posts

Posted 11 September 2008 - 11:14 AM

I just realized in half-way that ODE doesn't even support dynamic trimesh.

Trimesh (dynamic trimesh and trimesh-trimesh collisions are still incomplete)


So for now, I did static trimesh working.

Edited by Keth, 01 May 2010 - 09:49 PM.

  • 0

#27 them4n!ac

them4n!ac

    GMC Member

  • New Member
  • 1170 posts

Posted 20 September 2008 - 04:48 PM

then I don't understand you..
why you should try to make an unfinished and buggy 3d physics engine working like a 2d one?
in my opinion, that's a waste of processor time..
  • 0
what do you xpect to see here? another signature?
Cloud texture generator / renderer

#28 Keth

Keth

    GMC Member

  • New Member
  • 164 posts

Posted 20 September 2008 - 10:43 PM

then I don't understand you..
why you should try to make an unfinished and buggy 3d physics engine working like a 2d one?
in my opinion, that's a waste of processor time..


First of all, as I said in first post it's still beta and I will be working on it so I have no idea why are you repeating it's not finished.
Secondly, you have no idea how hard it is to find really easy 2D physics DLL. Not all the games got 3D physics but 2D as well.
Thirdly, you should see games using ODE physics: http://ode.org/users.html. ODE is not that bad as you think.

The only difference between calculating 3D physics and 2D physics is additional tangent calculation which makes 3D physics a bit slower.
However, tangent is basically not used for bodies attached to plane joint.
So the physics I made has nothing to do with 3D.

btw, GMPhysics 2D is waste of time as well, isn't it? AGEIA PhysX is 3d.

p.s. New version with new examples within few minutes.

Edited by Keth, 01 May 2010 - 09:50 PM.

  • 0

#29 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 17098 posts
  • Version:GM:Studio

Posted 21 September 2008 - 07:55 AM

then I don't understand you..
why you should try to make an unfinished and buggy 3d physics engine working like a 2d one?
in my opinion, that's a waste of processor time..


First of all, as I said in first post it's still beta and I will be working on it so I have no idea why are you repeating it's not finished.
Secondly, you have no idea how hard it is to find really easy 2D physics DLL. Not all the games got 3D physics but 2D aswell.
Thirdly, you should see games using ODE physics: http://ode.org/users.html. ODE is not that bad.

btw, GMPhysics is waste of time aswell, isn't it? AGEIA PhysX is 3d aswell.

p.s. New version with new examples within few minutes.


Hehehe. Actually, you can lock the z axis and make them work in 2d (like gmphysics must do). Same with gmbullet.
  • 0

#30 Keth

Keth

    GMC Member

  • New Member
  • 164 posts

Posted 21 September 2008 - 10:20 AM

then I don't understand you..
why you should try to make an unfinished and buggy 3d physics engine working like a 2d one?
in my opinion, that's a waste of processor time..


First of all, as I said in first post it's still beta and I will be working on it so I have no idea why are you repeating it's not finished.
Secondly, you have no idea how hard it is to find really easy 2D physics DLL. Not all the games got 3D physics but 2D aswell.
Thirdly, you should see games using ODE physics: http://ode.org/users.html. ODE is not that bad.

btw, GMPhysics is waste of time aswell, isn't it? AGEIA PhysX is 3d aswell.

p.s. New version with new examples within few minutes.


Hehehe. Actually, you can lock the z axis and make them work in 2d (like gmphysics must do). Same with gmbullet.


And same with GMODE, am I wrong?
I use plane 2d joint made espescially for 2D games (it locks to Z axis) so there is no difference between GMODE, GMBullet & GMPhysics.

p.s. New update available to download (see first post).

Edited by Keth, 21 September 2008 - 10:30 AM.

  • 0

#31 them4n!ac

them4n!ac

    GMC Member

  • New Member
  • 1170 posts

Posted 21 September 2008 - 02:49 PM

yes, GMPhysics is the same waste of time.
It isn't hard to find a great 2d physics engine, like Box2D

ODE isn't bad, it's just not for 3d, and not finished.

The only difference between calculating 3D physics and 2D physics is additional tangent calculation which makes 3D physics a bit slower.

Oh no..
3d physics use another collision detection, moves everything in 3 dimensions.
but I don't know what tangent calculation are you talking about..
I remember tangent velocity from collision handling which is projection of the velocity vector on an edge(2d)/plane(3d) of the other body, but that is used in 2d physics simulations too.

Edited by them4n!ac, 21 September 2008 - 02:50 PM.

  • 0
what do you xpect to see here? another signature?
Cloud texture generator / renderer

#32 Keth

Keth

    GMC Member

  • New Member
  • 164 posts

Posted 21 September 2008 - 06:01 PM

yes, GMPhysics is the same waste of time.

In my opinion GMPhysics isn't waste of time because there are lot of games using it right now on GMC.


It isn't hard to find a great 2d physics engine, like Box2D

You have no idea about physics engines. If you are going to do Box2D in Gamemaker then good luck!
Gamemaker doesn't support SDK libraries (Box2D is SDK).
Try looking for DLL physics engines which is the only way to use in Gamemaker.


ODE isn't bad, it's just not for 3d, and not finished.

The only difference between calculating 3D physics and 2D physics is additional tangent calculation which makes 3D physics a bit slower.

Oh no..
3d physics use another collision detection, moves everything in 3 dimensions.
but I don't know what tangent calculation are you talking about..

Collision detections are based on the same calculations for 2D and 3D and as I said, the only different is additional calculation for Z axis using tangent expression.
To calculate the velocity from collision handling in X axis you use sinus. Y axis you calculate cosinus. These two calculations are used in 2D physics for calculating collision.
However, in 3D physics tangent is for Z axis.

I remember tangent velocity from collision handling which is projection of the velocity vector on an edge(2d)/plane(3d) of the other body, but that is used in 2d physics simulations too.

Tangent is ONLY used for 3D projection and 3D physics. If your game has 2D physics and 2D projection then tangent is not used.

p.s. tangent calculation is 3 times slower than sinus calculation because tangent calls sinus 3 times. It depends on optimizations of physics.
tan(x) = sin(x)/cos(x)

I have no idea how to make this more clear to understand. :blink:

Edited by Keth, 21 September 2008 - 06:21 PM.

  • 0

#33 them4n!ac

them4n!ac

    GMC Member

  • New Member
  • 1170 posts

Posted 23 September 2008 - 07:47 PM

You look too inexperienced to make a physics dll.

In my opinion GMPhysics isn't waste of time because there are lot of games using it right now on GMC.

And it still can be faster. And that's the worst.


You have no idea about physics engines. If you are going to do Box2D in Gamemaker then good luck!

Oh no, I do have. And a lot. I've made a particle simulation with continuous collision detection so the particles never ever run behind walls with any speed.
As soon as Tutorial subforum will be opened, I'll put my ball physics example with sprite collisions using bounce function but controlling the power of friction and restitution.
But you have no idea about generic programming techniques, so you don't know how to make a Box2D DLL

Gamemaker doesn't support SDK libraries (Box2D is SDK).

SDK is Software Development Kit, not a library or something like that.
Try understanding the problem before saying "no".

Try looking for DLL physics engines which is the only way to use in Gamemaker.

[joke]Oh yeah, 2 dlls, that will be much(!!) faster!![/joke]

Collision detections are based on the same calculations for 2D and 3D and as I said, the only different is additional calculation for Z axis using tangent expression.
To calculate the velocity from collision handling in X axis you use sinus. Y axis you calculate cosinus. These two calculations are used in 2D physics for calculating collision.
However, in 3D physics tangent is for Z axis.

Do you have any idea what is sine, cosine or tangent?
http://en.wikipedia....metric_function
learn before talk such things. :D

Tangent is ONLY used for 3D projection and 3D physics. If your game has 2D physics and 2D projection then tangent is not used.

the same...
are you actually thinking what you're saying?
can you prove your words?

p.s. tangent calculation is 3 times slower than sinus calculation because tangent calls sinus 3 times. It depends on optimizations of physics.

tan(x) = sin(x)/cos(x)

why do you think that could ever happen?
tangent doesnt "call sinus" ever.

I have no idea how to make this more clear to understand. :mellow:

can't... understand.. :D

Edited by them4n!ac, 23 September 2008 - 07:48 PM.

  • 0
what do you xpect to see here? another signature?
Cloud texture generator / renderer

#34 Keth

Keth

    GMC Member

  • New Member
  • 164 posts

Posted 23 September 2008 - 10:24 PM

tan(x) = sin(x)/cos(x)

why do you think that could ever happen?
tangent doesnt "call sinus" ever.

You sure about that?
Open the link you have said: http://en.wikipedia....metric_function
and scroll down and you will see this:
Posted Image
as I said
tan(x) = sin(x)/cos(x)
Proof:
val = random(pi)-random(pi); // any number between -3.14 and 3.14 (and not only)
calc1 = tan(val);
calc2 = sin(val)/cos(val);
// calc1 = calc2
show_message(string(calc1) + ' = ' + string(calc2)); // print out
Result 0.71 = 0.71
GM6 Example: Download proof.gm6

---


You have no idea about physics engines. If you are going to do Box2D in Gamemaker then good luck!

Oh no, I do have. And a lot. I've made a particle simulation with continuous collision detection so the particles never ever run behind walls with any speed.

Oh noes! You made particles :mellow:.
I didn't asked what you did and I have no idea why are you saying this.
You haven't explained how you would implement Box2D into Gamemaker because that was my question.

---


Gamemaker doesn't support SDK libraries (Box2D is SDK).

SDK is Software Development Kit, not a library or something like that.
Try understanding the problem before saying "no".

I didn't asked what SDK is. I said that SDK is not supported by Gamemaker and you said it is. Could you explain a bit more how you would use that?
Also, SDK Library means that SDK is used as a library imported into application using collection of subroutines.
http://www.google.co...p;q=SDK Library

---


Collision detections are based on the same calculations for 2D and 3D and as I said, the only different is additional calculation for Z axis using tangent expression.
To calculate the velocity from collision handling in X axis you use sinus. Y axis you calculate cosinus. These two calculations are used in 2D physics for calculating collision.
However, in 3D physics tangent is for Z axis.

Do you have any idea what is sine, cosine or tangent?
http://en.wikipedia....metric_function
learn before talk such things. :D

Could you be nice and explain me what I have said wrong? In my opinion I do know what I am saying and you haven't explained me why I am wrong.

---


Tangent is ONLY used for 3D projection and 3D physics. If your game has 2D physics and 2D projection then tangent is not used.

are you actually thinking what you're saying?
can you prove your words?

Yes, I do know what I am saying and if you wan't a proof then your intelligence should prove it not me.

Edited by Keth, 23 September 2008 - 10:37 PM.

  • 0

#35 them4n!ac

them4n!ac

    GMC Member

  • New Member
  • 1170 posts

Posted 24 September 2008 - 02:36 PM

You sure about that?
Open the link you have said: http://en.wikipedia....metric_function
and scroll down and you will see this:
Posted Image
as I said

tan(x) = sin(x)/cos(x)
Proof:
val = random(pi)-random(pi); // any number between -3.14 and 3.14 (and not only)
calc1 = tan(val);
calc2 = sin(val)/cos(val);
// calc1 = calc2
show_message(string(calc1) + ' = ' + string(calc2)); // print out
Result 0.71 = 0.71
GM6 Example: Download proof.gm6

Yes.
The results are equal but computer's processor has a different function for each math function and one is never using another.

Oh noes! You made particles :mellow:.
I didn't asked what you did and I have no idea why are you saying this.
You haven't explained how you would implement Box2D into Gamemaker because that was my question.

I would make a dll which uses it. And that's it. There's no magic.
Learn programming in C++ good, and you'll know how to do it.


Gamemaker doesn't support SDK libraries (Box2D is SDK).

- Yeah, Box2D is SDK, not a library, and not SDK Library.

Also, SDK Library means that SDK is used as a library imported into application using collection of subroutines.

Where did you find that?
http://en.wikipedia....rch/SDK_Library
not there for sure. there are 2 types of libraries which are used by executables - statically (.lib(MSVC compiler)/.a(MinGW compiler)) and dynamically linked libraries (.DLL in windows)
both are used the same way.


Could you be nice and explain me what I have said wrong? In my opinion I do know what I am saying and you haven't explained me why I am wrong.

Well, it's not my job really.. but I can try.
I'll download ODE source.
searching for "tan"
found 1 .cpp file collision_trimesh_distance.cpp
everywhere I found "tan", it was in the word "Distance" either in the name of a function or in a description of the function.
Here's your proof.
You give me your proof or I'll know that your words are nothing, just words without any knowledge about it.
  • 0
what do you xpect to see here? another signature?
Cloud texture generator / renderer

#36 Keth

Keth

    GMC Member

  • New Member
  • 164 posts

Posted 24 September 2008 - 05:24 PM

You sure about that?
Open the link you have said: http://en.wikipedia....metric_function
and scroll down and you will see this:
Posted Image
as I said

tan(x) = sin(x)/cos(x)
Proof:
val = random(pi)-random(pi); // any number between -3.14 and 3.14 (and not only)
calc1 = tan(val);
calc2 = sin(val)/cos(val);
// calc1 = calc2
show_message(string(calc1) + ' = ' + string(calc2)); // print out
Result 0.71 = 0.71
GM6 Example: Download proof.gm6

Yes.
The results are equal but computer's processor has a different function for each math function and one is never using another.

Well, it might be as you said but it doesn't change the fact that the calculation CAN be optimized and the calculation is wrong at all.

---


Oh noes! You made particles :D.
I didn't asked what you did and I have no idea why are you saying this.
You haven't explained how you would implement Box2D into Gamemaker because that was my question.

I would make a dll which uses it. And that's it. There's no magic.
Learn programming in C++ good, and you'll know how to do it.

That changes the fact. You said "Box2D in Gamemaker" not "Box2D in Gamemaker via DLL".
Doesn't matter anyway :mellow: I do get your point now.
However, thanks for explaining.

---


Gamemaker doesn't support SDK libraries (Box2D is SDK).

- Yeah, Box2D is SDK, not a library, and not SDK Library.

Also, SDK Library means that SDK is used as a library imported into application using collection of subroutines.

Where did you find that?
http://en.wikipedia....rch/SDK_Library
not there for sure. there are 2 types of libraries which are used by executables - statically (.lib(MSVC compiler)/.a(MinGW compiler)) and dynamically linked libraries (.DLL in windows)
both are used the same way.

In Borland Delphi when you load SDK it says "Load Library".
Maybe this made you to misunderstood me.
Still, I have no idea who is right.

---


Could you be nice and explain me what I have said wrong? In my opinion I do know what I am saying and you haven't explained me why I am wrong.

Well, it's not my job really.. but I can try.
I'll download ODE source.
searching for "tan"
found 1 .cpp file collision_trimesh_distance.cpp
everywhere I found "tan", it was in the word "Distance" either in the name of a function or in a description of the function.
Here's your proof.
You give me your proof or I'll know that your words are nothing, just words without any knowledge about it.

You forgot about searching for ArcTan function which is used to calculate Z rotation axis.
Search for ATan (plane2d.cpp, collision_util.h and not only) :D
  • 0

#37 them4n!ac

them4n!ac

    GMC Member

  • New Member
  • 1170 posts

Posted 24 September 2008 - 05:40 PM

Well, it might be as you said but it doesn't change the fact that the calculation CAN be optimized and the calculation is wrong at all.

How? these trigonometric functions are at their maximum speed on every processor with the newest C runtime libraries.

That changes the fact. You said "Box2D in Gamemaker" not "Box2D in Gamemaker via DLL".

There's no another way :D
You're using ODE through your DLL, right?
But you could compile it into your DLL and you would get increase in speed too.

You forgot about searching for ArcTan function which is used to calculate Z rotation axis.
Search for ATan (plane2d.cpp, collision_util.h and not only) :mellow:

you were talking about "tan"
arctangent is "a different story".
the function is used to get direction as angle from a 2d vector
  • 0
what do you xpect to see here? another signature?
Cloud texture generator / renderer

#38 Keth

Keth

    GMC Member

  • New Member
  • 164 posts

Posted 24 September 2008 - 06:17 PM

Well, it might be as you said but it doesn't change the fact that the calculation CAN be optimized and the calculation is wrong at all.

How? these trigonometric functions are at their maximum speed on every processor with the newest C runtime libraries.

I mean optimization like calling sinus once and using it for tangent because this is what I meant from the beginning.
Example:
x = degtorad(45);
sx = sin(x);
sy = cos(x);
sz = sx/sy; // instead of tan
It speeds up around 25% instead of using tan.

---



That changes the fact. You said "Box2D in Gamemaker" not "Box2D in Gamemaker via DLL".

There's no another way :D
You're using ODE through your DLL, right?
But you could compile it into your DLL and you would get increase in speed too.

That would be against the ODE GPL I think.
Adding DLL into resources of application would result combining.

---


You forgot about searching for ArcTan function which is used to calculate Z rotation axis.
Search for ATan (plane2d.cpp, collision_util.h and not only) :mellow:

you were talking about "tan"
arctangent is "a different story".

Arctan is based on the same calculations as tan does - just backward.
tan(x) = y
arctan(y) = x
1,000,000 times calling arctan takes 2.2 seconds.
Exactly same for tan.

Edited by Keth, 24 September 2008 - 06:29 PM.

  • 0

#39 them4n!ac

them4n!ac

    GMC Member

  • New Member
  • 1170 posts

Posted 24 September 2008 - 07:35 PM

1. don't measure performance of basic math functions in GM
2. you can't add ODE to your dll, but you can do it with Box2D :)
3. I made a test in C++
tan is still faster than both sin and cos together
1000000 function calls
time there in seconds.
Posted Image
  • 0
what do you xpect to see here? another signature?
Cloud texture generator / renderer

#40 Keth

Keth

    GMC Member

  • New Member
  • 164 posts

Posted 24 September 2008 - 08:12 PM

1. don't measure performance of basic math functions in GM
2. you can't add ODE to your dll, but you can do it with Box2D :)
3. I made a test in C++
tan is still faster than both sin and cos together
1000000 function calls
time there in seconds.
<image cut>


1. It was a sketch code. I didn't tested it in GM just Delphi with micro time and 25% is average of 10 tests ran.
2. Well, I find ODE more precise than Box2D.
3. 0.038849 (sin float) + 0.038351 (cos float) = 0.0772
0.055449 (tan float)
so, 0.055449 / 0.0772 = 0.71825 = 28% faster.
Similar result I told in previous post. :)

Edited by Keth, 01 May 2010 - 09:58 PM.

  • 0

#41 them4n!ac

them4n!ac

    GMC Member

  • New Member
  • 1170 posts

Posted 25 September 2008 - 02:37 PM

3. 0.038849 (sin float) + 0.038351 (cos float) = 0.0772
0.055449 (tan float)
so, 0.055449 / 0.0772 = 0.71825 = 28% faster.
Similar result I told in previous post. :)


1. you forgot float division, that's a heavy cpu instruction too
2. GM uses doubles and converts them to floats for Direct3D, that is one of the reasons GM is slow.
3. you said:

It speeds up around 25% instead of using tan

quite different.
But at least you know how it is really, and that's good :)

btw, Box2D is easy to learn.
//somewhere
b2World* world;
//creation
world = new b2World( worldAABB, gravity, true );
//step
world.Step( timeDelta, iteration_count );

Edited by them4n!ac, 25 September 2008 - 02:37 PM.

  • 0
what do you xpect to see here? another signature?
Cloud texture generator / renderer

#42 Billyro

Billyro

    GMC Member

  • New Member
  • 57 posts

Posted 15 October 2008 - 06:54 AM

This is very good! :(
But I guess it would be very difficult to make a fighting game with this... :P
But fun to play with!

Edited by Billyro, 15 October 2008 - 06:54 AM.

  • 0

#43 GearGOD

GearGOD

    Deus Verus

  • GMC Member
  • 2153 posts

Posted 15 October 2008 - 07:47 AM

GM uses doubles and converts them to floats for Direct3D, that is one of the reasons GM is slow

No it isn't. The cast is negligible.
  • 0
Engineers are not programmers. Stop thinking that you can save a few bucks by writing code yourself instead of hiring a programmer. Your code sucks.

#44 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 16 October 2008 - 05:46 PM

To use a double as a float in Delphi, I think you just need to round it.

I agree that someone should make a Dox2D DLL but it would be extraordinarily hard, Box2D would need to be rewritten or coded so well that it would work.

Box2D uses OOP and is static, it may be impossible to just wrap the functions unless you add more. The types prevent a lot too, you'd need to use an array and return index numbers. It gets hard.

It's easier to use Allegro (Graphics) with Box2D in C++.
  • 0

#45 them4n!ac

them4n!ac

    GMC Member

  • New Member
  • 1170 posts

Posted 18 October 2008 - 10:57 AM

No it isn't. The cast is negligible.

oh, I said wrong. I just looked at the test results with my barely opened eyes.. :)
I looked at one book now and did some tests, that's right, they are very fast.

Edited by them4n!ac, 18 October 2008 - 11:01 AM.

  • 0
what do you xpect to see here? another signature?
Cloud texture generator / renderer

#46 coolsmile

coolsmile

    Programmer

  • New Member
  • 1346 posts

Posted 20 October 2008 - 10:05 PM

It just takes up a whole bunch of memory >_<
This is pretty interesting, I think it would be fun to create a dll from Box2D
  • 0

#47 them4n!ac

them4n!ac

    GMC Member

  • New Member
  • 1170 posts

Posted 24 October 2008 - 11:29 AM

Ok ok, but let's not spam the topic. If someone tries to make something with Box2D, he will make another topic.
  • 0
what do you xpect to see here? another signature?
Cloud texture generator / renderer

#48 heyufool1

heyufool1

    Fail

  • GMC Member
  • 1651 posts
  • Version:GM8

Posted 04 May 2009 - 12:42 AM

I realize that this is an old topic and i'm sorry for bringing it back, but i'm using this DLL right now, and sometimes doing the smallest change in code make the game come up with an error saying "unknown variable (global.)_002". I have the physx_start and everything but i don't know what's happening. Even when i change the code back to how it was i get the same error. Anyone know why? Thanks!

EDIT: I found out that even i declared global._002 in the create event of an object it still says that it's an unknown variable. So what could be causing this?
EDIT 2: I also just found that if i put the physx_start and the physx_world_set_gravity lines in the object that first causes the error it works. But i would still like to know why this is happening

Edited by heyufool1, 04 May 2009 - 02:25 AM.

  • 0
Posted ImagePosted Image

#49 fhd

fhd

    GMC Member

  • GMC Member
  • 175 posts
  • Version:GM:Studio

Posted 20 August 2009 - 01:47 PM

Is there any update for GM7 ?

Edited by fhd, 20 August 2009 - 01:48 PM.

  • 0

#50 posva

posva

    GMC Member

  • New Member
  • 610 posts
  • Version:GM8

Posted 01 October 2009 - 05:48 PM

i noticed that set_rotation make an unexpected error appear or an acces violation or freez game...
can you fix that?
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users