PhysLite Issues

Started by Hardcoal, January 25, 2021, 20:49:57

Previous topic - Next topic

Hardcoal

Im learning this PhysLite 2D engine now.
and something really strange which I cant understand..

when I run my simulation of lets say a bridge of attached masses.. they suddenly stop being simulated..
as if they went into sleep mode..

when i produce another bridge.. it works.. without entering sleep mode.. and than again another one does enter sleep mode..

anyone one has any Idea?

Ive already compared it to many code examples.. and I cant figure it out..
so weird..

anyway ive attached what I did..
Press mouse to produce a new bridge..

Method CreateBridge:Tmass[] (X:Float = 10, Y:Float = 10, Size:Float = 300, Sections = 5)
Local BridgePart:TMass[], bridge:TBody, TempM:TMass, I, Radius:Float, XC:Float, Friction:Float = 1
Local Mass:Float = 10

If Sections < 3 Then Return
If Sections > 100 Then Return

Radius = size / (Sections * 2)

bridge = New TBody

BridgePart = BridgePart +[MassCreate(X, Y, Mass, Radius, Friction, 99)]
TempM = BridgePart[0]

Local c:TConstraint
For I = 1 To Sections
BridgePart = BridgePart +[MassCreate(X + XC, Y, Mass, Radius, Friction, 99)]
c = ConCreate(TempM, BridgePart[I])
c.Assign (bridge)
TempM = BridgePart[I]
XC = XC + Radius * 2
Next

BridgePart = BridgePart +[MassCreate(X + Size, Y, Mass, Radius, Friction, 99)]
c = ConCreate(BridgePart[I - 1], BridgePart[I])
c.Assign (bridge)

BridgePart[0].Freeze()
BridgePart[I].Freeze()

ListAddLast(PhyObjList, BridgePart)

Return BridgePart
End Method


Code

blinkok

This happens with all physics systems based on box2D. You need to turn off the objects ability to sleep

Hardcoal

#2
How? what is the command for this?
And how come it doest happen on the demos Ive checked..


ive found a command called TBody.SetAutoSleep(False)

but it wont let it work.. its unrecognized for some reason..
Code

blinkok

I am not familiar with this physics system. Your issue seemed strikingly similar to the Box2D one i described


Hardcoal

#4
Im fed up with this stupid  error.. I cant understand this..
So I guess ill give up on this too..

Ive never seen such an annoying error. cant figure it after many experiments..

Ill move on
Code

Hardcoal

Ok. I realized what was my silly Issue/Error..
Sorry PhysLite..

I used Local TBody, Instead of Global..
Hurray.. I can continue now..


Code

_PJ_

Quote from: Hardcoal on January 27, 2021, 19:39:01
Ok. I realized what was my silly Issue/Error..
Sorry PhysLite..

I used Local TBody, Instead of Global..
Hurray.. I can continue now..

I think all the most challenging issues follow this same pattern!!!

1) Code the next feature
2) Identify some bugs
3) Scour code and maybe add in some feedback / breakpoints to isolate bugs
4) Bash head against desk repeatedly as no clues appear other than "it's just not working"
5) Suddenly notice it was a silly mistake

Psychologically, I believe this is very common due to the fact that we expect that the problem is with the logic and commands we have been adding.
Typically, Local / Global scope definition would be a very trivial thing, so we gloss over checking that as it would not be expected to have been such a mistake. Instead we focus on minutae of functional and computational aspects and get ever more puzzled since they are of course, perfectly correct!

So glad to hear you solved it.

Hardcoal

In this case. it was more of general lack of understanding how the garbage collector works..
so what happened is that the garbage collector collected my TBODY while it was running..
hence the sudden physical simulation stop.
once i realized it.. i took the TBODY out of the  Function.

I simply didnt realize.. something that works can be suddenly collected..
Code

Hardcoal

after spending like a week with physlite.. I realized there is no way to make collisions with say. Rect to Rect..
it all works on mases..

can anyone really tell me which 2d engine is best to invest in?
I Dont feel like wasting so much time for than realizing such a basic thing does not exist in a 2D physics  engine..

It seems like Box2D is the best around.. but there is also this Chipmunk Engine..

why do people recommand on Physlite when it seems like box2d gives much more..
If Im wrong. please correct me, so I can concentrate on the right Engine and develop my own commands.



Code

Hardcoal

#9
Ive never seen a more annoying and unclear inconvenient to understand 2D physics Framework or any other frameworks that Ive tried, than Box2D,
Yet, ill keep trying to learn/understand it. since it seems worthy the effort.

How can a 2D physics engine be more complex than Strings theory.

Code

GW

I investigated Physlite when I made MazeEscape http://www.kerneltrick.com/?p=36 .  I ended up writing my own physics instead. Do you need a full physics engine?
If you just just need basic collision detection and response, It might be easier to code it up yourself.  Both chipmunk and box2d are dead for BMax I think. There are a few physics engines that were written in pure Monkey long ago, you could try porting one of those over.

Hardcoal

why do you say box2d is dead? :) its working..
Its just made horribly complicated. and im trying to simplify it.. to the point its usable by mortals..

Thanks for your offer GW . well i need more than just collision detection.. but ill download what you did and test it as well.

physlite is a walk in the part compared to box2d!

Im gonna make box2d great again I promise :)

well hopefully at least,

than ill post my code here..

i also tried newton physics which is a 3D physics. but i didnt manage to make it work.
i tried to use hitoro mod.. under blizmax 1.50

what i do is I take an engine and make my own library to simply things..
and thats what im gonna do with box2d



Code

Hardcoal

Im proud to say that I cracked the complexity of the Box2D and Im simplifying it to a point that it will be ultra easy to use.

theres nothing in box2d that was made simple..
Even the Y position coords of objects goes Up like in a 3D environment, instead of down as a normal 2D environment usually use.

I simplified it to a

Create2DWorld()
CreateBox()

and so on..

lets hope it will be worth the effort
Code

Hardcoal

#13
hi, If anyone have some box2d code examples besides the basic ones.. ill be happy to see it here..
there is the collision issue which i still dont understand

collision detection and many more..

cheers


Thanks PJ
Code