Extremephysics - 2d Physics Engine For Game Maker
#41
Posted 03 November 2009 - 09:04 PM
#42
Posted 08 November 2009 - 10:42 PM
Edited by theludicrous, 09 November 2009 - 01:22 AM.
#43
Posted 11 November 2009 - 12:31 PM
#44
Posted 13 November 2009 - 01:43 PM
#45
Posted 14 November 2009 - 04:39 PM
#46
Posted 14 November 2009 - 07:31 PM
in the future can you please make a stack of tutorials, complex ones and simple ones, i just found the one there now hard to understand, btw what let GmPhysics down was lack of documentation and explanation on lots of the functions.
Please don't let that happen to this, it seems to good!
#47
Posted 19 November 2009 - 02:37 PM
No, but you can create concave polygons by dividing them into multiple convex polygons. I could even try to make the engine do that automatically, but it's very hard to generate a good subdivision.Does it support concave polygons?

This is what I want to do, but I haven't found a good algorithm yet.
#49
Posted 21 November 2009 - 08:07 PM
The first example looks very good, I will add that in v2.1 if possible.
I've rewritten half of the code so far (100kb
#50
Posted 21 November 2009 - 09:48 PM
The first example looks very good, I will add that in v2.1 if possible.
I've rewritten half of the code so far (100kb). The other half should be easier because I don't have to change it completely.
The only thing is that people usually define vertices clockwise.... So be careful. I have no idea why the implementation is backwards (or maybe I am).
#51
Posted 22 November 2009 - 05:52 AM
#52
Posted 22 November 2009 - 08:55 PM
My implementation is clockwise. Or did you mean the implementation in the example? I'm not going to copy the code (I am not using any code I don't understandThe only thing is that people usually define vertices clockwise.... So be careful. I have no idea why the implementation is backwards (or maybe I am).
#53
Posted 23 November 2009 - 01:47 AM
My implementation is clockwise. Or did you mean the implementation in the example? I'm not going to copy the code (I am not using any code I don't understandThe only thing is that people usually define vertices clockwise.... So be careful. I have no idea why the implementation is backwards (or maybe I am).
), I will probably write my own code anyway.
Yeah, I meant all the examples listed there are backwards. Cool find though. hope it helped.
#54
Posted 25 November 2009 - 03:41 PM
- Avoid exceptions by checking for overflow manually. This is possible but not very convenient. I can only do this when casting doubles (from gm) to other types, but that's not really a problem as the actual code doesn't need casts. This won't stop overflow errors from being thrown during the simulation itself, but I think my code is overflow-safe.
- Disable exceptions when entering the function and enable them again when returning. This is also rather inconvenient, and it will decrease performance. If a game uses EP functions 100000 times per second (3333 times per frame, 30fps), which is reasonable, it will be spending 1-2% of its time enabling and disabling exceptions.
- Disable exceptions when the DLL is loaded. This is very simple, but not very safe. It would break GM code (and possibly code in other DLLs) that relies on exceptions. Moreover it won't work if GM enables the exceptions again (and I have no idea when this will happen).
I'm not sure about the best solution for this problem. What's your opinion?
Edited by Maarten Baert, 25 November 2009 - 03:51 PM.
#55
Posted 25 November 2009 - 11:03 PM
sin with 1.000000000001, the value is a floating point impresition which happens quite often
so you have to min(1,max(-1,value))
Some times, depending where you do a dll call with this problem you dont even get exeptions, you find your GM code, after calling a function is skipped... I even had one game going straight from the step even into the draw event of another object, skipping all objects step and end step...
Edited by icuurd12b42, 25 November 2009 - 11:04 PM.
#56
Posted 26 November 2009 - 08:27 PM
No it's notyeah, it's your sin/cos... whatever function that expects values from -1 to 1.
sin with 1.000000000001, the value is a floating point impresition which happens quite often
so you have to min(1,max(-1,value))
Some times, depending where you do a dll call with this problem you dont even get exeptions, you find your GM code, after calling a function is skipped... I even had one game going straight from the step even into the draw event of another object, skipping all objects step and end step...
Now i'm using this code:
// gm_cast - cast without throwing exceptions
template <typename A> A gm_cast(double);
template <> inline unsigned long gm_cast<unsigned long>(double d) {
if((double)((unsigned long)(0x00000000))<=d && d<=(double)((unsigned long)(ULONG_MAX))) return (unsigned long)(d);
else return 0;
}
template <> inline int gm_cast<int>(double d) {
if((double)((int)(INT_MIN))<=d && d<=(double)((int)(INT_MAX))) return (int)(d);
else return 0;
}
template <> inline bool gm_cast<bool>(double d) {
if(d>=0.5) return true;
else return false;
}
template <> inline float gm_cast<float>(double d) {
if((double)((float)(FLT_MIN))<=d && d<=(double)((float)(FLT_MAX))) return (float)(d);
else return (float)(0);
}This solves the problem when casting gm's doubles to other types, but it doesn't stop overflows in the simulation code. For example, I can't use this code without checking whether pos1-pos2>1e-100:double d; d = (pos1-best_len)/(pos1-pos2); d = ep_clamp(0,1,d); // macroIt's not a huge problem but it would be easier if I could just use 'normal' C++ code.
#57
Posted 27 November 2009 - 12:02 AM
bool t = (bool)(short)(DWORD) doublevalue;
from bool
return (double)(DWORD)(short) boolvalue;
but why are you using the troublesome unsigned longs? DWORD should do for IDs... IDs are int32 (int or DWORD), pretty sure about that from the way people reported the value wraping to negative.
I ALWAYS pass through DWORD. Refer to my dll tutorial...
but you will eventually find trouble with the sin cost, guaranteed.
#58
Posted 27 November 2009 - 12:47 AM
#59
Posted 27 November 2009 - 06:05 AM
double input; bool output=(input)?true:false; bool input; double output=input; // allowed hidden cast from low-bit size to high-bit size
Edited by PsichiX, 27 November 2009 - 06:56 AM.
#60
Posted 27 November 2009 - 08:45 AM
icuurd12b42: for cast double<->bool faster way:
double input; bool output=(input)?true:false; bool input; double output=input; // allowed hidden cast from low-bit size to high-bit size
really? casts are resolved at compile time (is this a cast?), where this is done at run time (is it?). so I do have my doupts, so please enlighten me.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users









