Pages: 1
  Print  
Author Topic: B2D physics question  (Read 2209 times)
Offline (Unknown gender) Darkstar2
Posted on: May 02, 2014, 06:15:54 PM
Member
Joined: Jan 2014
Posts: 1244

View Profile Email
I'm going to start learning and use B2D for my physics projects since the settings through the IDE (room setting and object setting) are not implemented.

I had a question regarding setting the points, I remember from GMS that there was a limit of 6 points.  On GMS you can set up physics fully through the IDE, so you could not go more than 6 points.   Was this a GMS set limit or is this a limit on the physics engine?

In ENIGMA do I still have the limitations ?

Thanks.
Logged
Offline (Male) Goombert
Reply #1 Posted on: May 02, 2014, 10:17:21 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
That was a GM: Studio limit Darkstar, you are free to add as many points to your shapes as you want when you use my function set. Just make sure the points are ordered clockwise and create a convex shape, Box2D does not support concave shapes.

http://enigma-dev.org/docs/Wiki/Box2D_Functions
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) Darkstar2
Reply #2 Posted on: May 02, 2014, 11:38:01 PM
Member
Joined: Jan 2014
Posts: 1244

View Profile Email
That was a GM: Studio limit Darkstar, you are free to add as many points to your shapes as you want when you use my function set. Just make sure the points are ordered clockwise and create a convex shape, Box2D does not support concave shapes.

http://enigma-dev.org/docs/Wiki/Box2D_Functions

Yes thanks Robert I am fully aware of the clockwise and convex restrictions.  In GMS IDE it would not let you do otherwise, this is one of the great things with doing things through an IDE at least for beginners :D

Curious to know why did GM Studio limit this to 6 points ? Why 6 and not 7 or 8 or 12 ? 
Logged
Offline (Male) Goombert
Reply #3 Posted on: May 03, 2014, 12:12:14 AM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
I have no idea, it should have never been limited.

Edit: I would test this, but I just updated to the new release and it appears the modify collision shape button has now broken.
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) Darkstar2
Reply #4 Posted on: May 03, 2014, 12:32:42 AM
Member
Joined: Jan 2014
Posts: 1244

View Profile Email
I have no idea, it should have never been limited.

Edit: I would test this, but I just updated to the new release and it appears the modify collision shape button has now broken.

Or maybe they just intend to remove it and ask people to figure the points on their own ! lol!
mind you that's how it is done now in LGM :P
« Last Edit: May 03, 2014, 12:37:15 AM by Darkstar2 » Logged
Offline (Male) Goombert
Reply #5 Posted on: May 03, 2014, 12:47:05 AM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
For a reason, because their whole system is designed horribly, mine has reusable shapes as well without duplicating RAM. Anyway, I can confirm this point limit exists, I wasn't actually adding a subimage to my sprite that's why the button wasn't working, because apparently the object needs to have a sprite for w/e dumbfuck reason.



This is why I think it would better to just make ENIGMA better and not even offer support for their physics but do everything our own way. It would probably be better to split the ENIGMA project in 2, we'd get much more done if we just did things our own way, because then we wouldn't have to worry about compatibility, and we could just do things the right way.
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) Darkstar2
Reply #6 Posted on: May 03, 2014, 01:01:23 AM
Member
Joined: Jan 2014
Posts: 1244

View Profile Email
For a reason, because their whole system is designed horribly, mine has reusable shapes as well without duplicating RAM. Anyway, I can confirm this point limit exists,

So who's going to volunteer in asking them why this limit of 6 and see what amazing reason they come up with ?

BTW I noticed you are using only the standard edition and not pro...shame on you, you are missing out on a lot!   ;D :P

Quote
This is why I think it would better to just make ENIGMA better and not even offer support for their physics but do everything our own way. It would probably be better to split the ENIGMA project in 2, we'd get much more done if we just did things our own way, because then we wouldn't have to worry about compatibility, and we could just do things the right way.

Agreed with this but properly documenting it as to help make the transition smoother. :)
Logged
Offline (Unknown gender) TheExDeus
Reply #7 Posted on: May 03, 2014, 07:04:54 AM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
Quote
So who's going to volunteer in asking them why this limit of 6 and see what amazing reason they come up with ?
If they check convexity when editing the shape then it's possible that they didn't bother to create an algorithm that could check it for more than 6 points. It's possible that they use some easier algorithm limited to that. Just my two cents, as checking convexity isn't that trivial and can be slow with many points.

Quote
For a reason, because their whole system is designed horribly, mine has reusable shapes as well without duplicating RAM.
I think their is reusable as well. It's one per sprite, so every instance using that sprite uses that shape. I don't think it's a bad design, as the whole point is making a collision shape for the sprite. I don't use GMS so I didn't know they added that. I think you should add something similar to LGM. You can add a separate resource if you want, but then compatibility will be harder (but should still be possible). As Darkstar and others have pointed out, one massive problem with ENIGMA (and still with GM) is that it's too "low level", as in, you have to do everything in code. I don't have any problems with that, but others want something like Unity, which has editor for everything. So adding collision shape editors among others would be a nice addition. It would probably take time though, so I don't know if you should try that now. GMS seems to reuse the path editor for that, so might be easier. It already has the possibility to add points, have an image in the background and other things that are useful.
Logged
Offline (Male) Goombert
Reply #8 Posted on: May 03, 2014, 01:22:27 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
Quote
If they check convexity when editing the shape then it's possible that they didn't bother to create an algorithm that could check it for more than 6 points. It's possible that they use some easier algorithm limited to that. Just my two cents, as checking convexity isn't that trivial and can be slow with many points.

That seems to me like the most arbitrary limitation one could possibly create, what is wrong with a "Check Convexity" button?

Quote
I think their is reusable as well. It's one per sprite, so every instance using that sprite uses that shape. I don't think it's a bad design, as the whole point is making a collision shape for the sprite.
It does not do that, I tested adding the same sprite to two objects, the points are stored per object in the GMX file as well.

Quote
GMS seems to reuse the path editor for that, so might be easier.
It does, but here is the thing. #1 Unity3d's editor doesn't come with that much built in, you usually have to download some 3rd party extensions before you get a very good tool. But anyway, their IDE supports JavaScript and C# extensions, which is what I wanted LGM to have using Java 8's Project Nashorn, which is a JavaScript engine.

Also, there is no real need to duplicate it, users could literally just create a path resource, and use the following script.
Code: (EDL) [Select]
fix = physics_fixture_create();
for (i = 0; i < path_get_number(shapepath); i++) {
  physics_fixture_add_point(fix, path_get_point_x(shapepath, i), path_get_point_y(shapepath, i);
}
physics_fixture_set_polygon_shape(fix);

I haven't tested that, but should be pretty close.
« Last Edit: May 03, 2014, 01:29:27 PM by Robert B Colton » Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) Darkstar2
Reply #9 Posted on: May 03, 2014, 02:02:16 PM
Member
Joined: Jan 2014
Posts: 1244

View Profile Email
If they check convexity when editing the shape then it's possible that they didn't bother to create an algorithm that could check it for more than 6 points.

That sounds logical, but I'm wondering if there could be another reason as well.  Perhaps they figured 6 was enough for starters and that if you needed more you could add them manually ???
I've never done physics through GML, so I would not know; do they support doing physics from GML ? Like adding the points yourself ?  I would think the limit of 6 points is an editor limit (the convexity is indeed checked realtime) and that you could in theory check for convexity yourself by sketching (in a 3rd party program) and manually adding the points.  Have not tried this.  Would be an interesting experiment.  This is the method currently done in LGM since there is no collision shape nor any physics in IDE, so it's entirely low-level for physics here.  Mind you writing an external script or GUI and converting it to code would not be hard and think I might be able to do that, but directly integrating to ENIGMA/LGM, not skilled enough to handle that for now :D

Quote
I think their is reusable as well. It's one per sprite, so every instance using that sprite uses that shape. I don't think it's a bad design, as the whole point is making a collision shape for the sprite.

When I was new to this I was very confused.  I thought that the physics engine handled everything, that you just plugged in physics attribute and the rest was handled by the engine, meaning that you did not have to set a collision shape and points, the the physics engine would consider the entire sprite shape and work the same way as precise collision works.

So defining points is mandatory ?  what about more complex shapes that have curves or weird shapes
that would be difficult or impossible to trace with points ?

Quote
I don't use GMS so I didn't know they added that. I think you should add something similar to LGM.

There was a big discussion on that, the feature is visible in LGM, but when you click on it nothing happens. He answered that the IDE has it just for editing purposes and that it was not implemented yet and that we have to all use B2D and do everything manually, which basically involve plugging all those values you enter in the IDE directly into their physics GML equivalents, or in ENIGMA's case it would be the B2D functions.

Quote
You can add a separate resource if you want, but then compatibility will be harder (but should still be possible). As Darkstar and others have pointed out, one massive problem with ENIGMA (and still with GM) is that it's too "low level", as in, you have to do everything in code.

That's how it was since the time of Mark Overmars.  It would have been tedious to convert every possible function into D&D objects, and they just wanted to keep the basics and commonly used features while allowing the more advanced users to access extra features through functions.  To my knowledge that's how most other programs work too.  The ones that allow everything done without single code are probably quite limited. 

Quote
I don't have any problems with that, but others want something like Unity, which has editor for everything. So adding collision shape editors among others would be a nice addition. It would probably take time though, so I don't know if you should try that now.

That suggestion was already made, but lack of time and other things to do first.  Also I don't think adding this to the IDE is the only thing, they would have to integrate the physics values from IDE so that it works.  Having code free physics in ENIGMA is more than just adding collision shape, and they have no time for that.  :P  So yeah there are things low level that people have to do themselves, but that is the case with GM, shaders being a good example.
That's why GM was designed to allow extension through libraries that people made !  Until code free physics is possible using LGM, one could create a library but problem is LIBs don't work here either. They show up, but have no effect.  So only alternative is writing an external editor that allows you to edit shape and points, enter physics values and have it spit out the set of codes to be used !  Much the same way the ParticleDesigner app worked for GM, which btw was entirely made using GM.

Quote
GMS seems to reuse the path editor for that, so might be easier. It already has the possibility to add points, have an image in the background and other things that are useful.

BTW you mentioned Unity has an editor for everything. I never used Unity before.  So what you are saying is that every aspect of game has an editor right ?  But it still requires coding to put all that together.  From what I heard it's a steeper learning curve.

With PROPER documentation and examples, and explaining step by step why things are done that way, people would eventually learn to do everything by code.  This is something GM lacked back in the days.  Docs have gotten better, but still far from perfect, which is why at that point you have to dig for those tutorials, some are crap some explain things very well.    GM started with ease of use in mind, but I think YYG is bringing GM in another direction, adding too many features at the low level, requiring advanced users, and I can see they are relying mostly on the community to do the educating than the developers themselves......so people have to wait until some contributors volunteer to make tutorials, etc, and they are not always correct or comprehensive.   
Logged
Offline (Unknown gender) TheExDeus
Reply #10 Posted on: May 03, 2014, 05:11:13 PM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
Quote
That seems to me like the most arbitrary limitation one could possibly create, what is wrong with a "Check Convexity" button?
Well they wanted it real-time, just like syntax checking. Because otherwise a user wouldn't check it and then post a topic on how physics are broke. So this automatic checking is probably a fool proof method. And I do like it actually. Like if there is a limitation, then don't even allow users to reach it. I think checking convexity up to a certain number of points would be possible in real-time as well, but that limit is probably in hundreds (or at least late tens) so shouldn't be a real "limit". As physics meshes are usually quite simple. That suggestion was just my idea on why they have that 6 point limit. Of course the reason could be anything. But I could imagine how a simpler algorithm could work with only 6 points. They maybe also wanted to limit users, so they wouldn't use unnecessary number of points. Like I can image someone using one point per pixel to make a "pixel perfect" collision, which probably would be unbelievably slow and useless. So in essence they made a "good practice" limit. But I can image cases were 6 can be too few.

Quote
It does not do that, I tested adding the same sprite to two objects, the points are stored per object in the GMX file as well.
Yeah, sorry, I didn't know how the whole thing worked. I just looked it up and it is actually per object, not per sprite. Which is not a bad thing either. In that case it also reuses the mesh anyway. So it's still not a bad design.

Quote
Also, there is no real need to duplicate it, users could literally just create a path resource, and use the following script.
Newbies sadly don't want to code. :(
Logged
Offline (Unknown gender) Darkstar2
Reply #11 Posted on: May 03, 2014, 07:16:10 PM
Member
Joined: Jan 2014
Posts: 1244

View Profile Email
That seems to me like the most arbitrary limitation one could possibly create, what is wrong with a "Check Convexity" button?

I honestly don't think that is in their priority of things to do anyway, especially if there exists an alternative method to plug in the points using code, their library maker and system actually works so it would be easy for one to make :D 

Quote
physics meshes are usually quite simple. That suggestion was just my idea on why they have that 6 point limit. Of course the reason could be anything.

Your suggestion sounds logical, I can't think of other possible reasons, maybe however, if the limit of 6 is not applicable to the GML counterpart, then this would prove your suggestion is correct and the only reason.

Quote
But I could imagine how a simpler algorithm could work with only 6 points. They maybe also wanted to limit users, so they wouldn't use unnecessary number of points. Like I can image someone using one point per pixel to make a "pixel perfect" collision,

Another very good point, but this can be prevented by mentioning it in their documentation along with images on how it works.  GMS has become far more advanced and has advanced functionality in code, so they shouldn't just assume every user is dumb enough to set a point on every edge pixel :P

Quote
which probably would be unbelievably slow and useless. So in essence they made a "good practice" limit. But I can image cases were 6 can be too few.

Yes I found that out when I made my physics example, the one I discussed about in my other physics topic.  A star shape, which if not mistaken requires 10 points.

Quote
Newbies sadly don't want to code. :(

Can you blame them ?  Not everyone who starts using comes from a solid programming background.  When I first used GM I was so happy because of the D&D thing, but then later gained a lot of interest in doing GML and now learning C++, I would now rarely if at all use D&D. 
When I joined GM however I was a newbie but had some programming background, sort of, as I did BASIC, ASM, etc. so I knew the logic of programming ,just had to learn GML functions :D SO it makes it all the much easier.

But otherwise pure newbies, nope, I can understand why they would not want to code.

Here is another thing with GM, apparently there is one guy who does ALL his games with D&D, he's very skilled and very good and he did some stuff unimaginable.  He was even talked about by YYG devs themselves during a presentation, don't know if it was Mike Daily, Russel, but it was mentioned.  He releases his stuff too. 

It's funny now but I found once I got into GML I can't really go back to D&D, it confuses me and so tedious.   BUt I have a long long way to go with GML I am still not up to par with the experts far from it.
Logged
Pages: 1
  Print