-
Notifications
You must be signed in to change notification settings - Fork 36
box2d physics library #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
add ID values for GuiIconName to make it easy to embed icons id's in strings
changed loadDirectoryFiles to raylib 55 to follow new function signture and unloadDirectoryFiles missed the necessary argument
Box2D is a 2D Physics engine, see more on https://box2d.org/
Tried to follow c3 vendor guide lines "conform to C3 stdlib layout (tabs, Allman braces)" didn't do this first because was unaware of them, don't known if the tabs stuff is fully correct, thou I changed the leading ones to real tab, hope is enough.
This looks like this is also making changes to the raylib bindings? Also, it's 0.7.0 and 0.6.8, not 7.0.0 and 6.8.0 :D |
Oh sorry about that! I'm still a noob at this github technical stuff (yeh shows I'm not a professional programmer, i'm just a self taught one), if possible ignore the raygui and raylib stuff. |
Thou looking at the two raylib changes I did (I did them some time ago, so I forgot about it...) they do make sense, as those were wrong function definitions/bindings in the original, unless those functions were already corrected in the mean time, I recommend that you also merge my raylib changes. |
I've removed the 0.6.8 versions and I'm doing 0.7.0 now exclusively. Could you update the bindings and changes for it? |
Yes I can. :) |
Could you do these changes? |
I already did the updates to 0.7.0, if that is what you are asking? |
No, there are some new changes requested, see in the boxes above! |
Sorry for my ignorance but what boxes above? Can you point me to what you are talking about. Or can you write what you want me to change in a comment here? |
changed the code to follow more closely @lerno suggestions (still not tested at this point...)
now fully compiles
I'm sorry I haven't checked this yet. I'll try to have time soon. 🙏 |
} | ||
|
||
// Body id references a body instance. This should be treated as an opaque handle. | ||
struct B2BodyId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would make these implement comparisons using operator overloading with macro methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may have bitten more than I can chew...
ok... any examples I can look at, so I can see what you mean?
Btw If I didn't said this before, I will say it now, I never used box2d before this, I know almost nothing about it, I just heard Unity3D used it and thought a 2D physics engine, would be cool to use with C3 for simple 2D games, so probably for me to really optimize its library for C3, I would need to first learn well its ins and outs, but I will see what I can do.
//===================================================================================================== | ||
module vendor::box2d::b2::b2math; | ||
|
||
alias B2Vec2 = float[2]; // NOTE(HM) to support C3 vector math using (float[<2>]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can make B2Vec2 a typedef and then implement the different vector ops on it, but it's probably easier to leave it as is, since a float[2]
will implicitly convert to a float[<2>]
and vice versa. See if you want to use operator overloading on structs such as B2Rot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it can stay like that for now better, it can always be changed later by me or others... the reality, I don't have much time to dedicate to this now. Not if you don't want to wait one more month for this... :(
Don't know how many people are waiting for this bindings, but they are always free to comment here. (...and also help btw....)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this stay like this?
libraries/box2d.c3l/manifest.json
Outdated
"macos-x64" : { | ||
"link-args" : [], | ||
"dependencies" : [], | ||
"linked-libraries" : [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add "linked-libraries" to macos and windows too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is mostly done?
libraries/raygui.c3l/raygui.c3i
Outdated
ICON_254, | ||
ICON_255, | ||
// val is the ID number for the "#iconID#sometext" ability | ||
enum GuiIconName : int (int val) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is the same as the ordinal the int val
part can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have the impression we already discussed this? Even if is useless, I think those should stay?
Thou I will probably make them into a comment, or better, thinking about it, make them into a inline string, so you can use the enum member directly and just concatenate them into other strings?
like so:
enum GuiIconName : (inline String str)
{
CURSOR_HAND = "#19#",
}
if( rgui::button(rec, CURSOR_HAND.zstr_tcopy()) ) {
//
}
Anyway why I think they should stay, the main reason is, because it removes the need to count each enum by hand, to know its value visually.
Imagine you saw a online tutorial on box2d and it used "#128#" on it (many do use the id directly like that), looking at that first time, what icon is that id?
If those index numbers are not there, for you to immediately connect the dots, you will have to count each enum member to find who is the 128 one...
But like I said, probably making them into a simple // comment or inline string is enough... but I'm not sure, I may be forgetting something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did this modifications
edited the manifest file and provided a compiled box2d library for windows-x64 I use, but imo the best is for others to compile box2d themselves for their own CPU architecture... Unfortunately cannot provide macos and linux ones at this time. Changed the raygui icon enum to be a inline ZString so you can pass them directly to raygui functions as zero terminated strings for the "#id#" feature.
Hmm.. it has some conflicts now. |
Let's merge this and let improvements come later. |
Agree and thanks for the patience in dealing with a noob like me. And sorry for not doing more but other work got in the way. |
Box2D is a popular 2D Physics engine for 2d games, docs and more on https://box2d.org/