Chipmunk questions
Having a moment of inertia of zero is very bad, that might be part of your problem. Either make it be INFINITY if you don't want it to rotate at all, or use the cpMomentForCircle() function to help estimate the moment of inertia.
Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Thanks. Putting it to infinity solved the problem.
Why did you name the library Chipmunk? There is a hill outside of Stanford University's campus, which the university owns, that has a long walking route. There is a massive chipmunk density, and I saw one about every 10 meters along the road. I also saw two hawks, which are surely living the good life.
Why did you name the library Chipmunk? There is a hill outside of Stanford University's campus, which the university owns, that has a long walking route. There is a massive chipmunk density, and I saw one about every 10 meters along the road. I also saw two hawks, which are surely living the good life.
Because my previous (and not very good) physics library was named Squirrel Physics Kit. Chipmunk was the next logical step.
Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
The collisions work now, although they are completely inelastic. I added a static segment to the window's left edge. However, it is not rigid, so that the body sinks into it. What is the problem?
Code:
wall = cpSpaceAddBody(space, cpBodyNew(1, INFINITY));
wallShape = cpSpaceAddStaticShape(space, cpSegmentShapeNew(wall, cpv(0,0), cpv(0, size.height), 0));
Static shapes must be attached to infinite mass objects, otherwise the collisions will cause them to pick up velocity.
Read the section on static shapes in the docs: http://files.slembcke.net/chipmunk/relea...s/#cpSpace
Read the section on static shapes in the docs: http://files.slembcke.net/chipmunk/relea...s/#cpSpace
Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Thanks. However, is the default elasticity value 0? I can not find any method to change it.
cpShape.e is the elasticity value. It seems I never wrote getter/setter functions for those. You'd think I would have noticed that when rewriting the docs. Originally Chipmunk never even had getters or setters unless they were really needed for something. All the structs were really just full of public members.
Anyway, have you read the docs? http://files.slembcke.net/chipmunk/relea...test-Docs/
Anyway, have you read the docs? http://files.slembcke.net/chipmunk/relea...test-Docs/
Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
I have read most of the docs. Are you going to add elasticity getset methods next time that you update Chipmunk?
Is the reason that the collisions are completely inelastic that cpBodyResetForces is called every time before cpBodyApplyForce in my code? If I remove it, the bodies' acceleration is too large.
Is the reason that the collisions are completely inelastic that cpBodyResetForces is called every time before cpBodyApplyForce in my code? If I remove it, the bodies' acceleration is too large.
No it's inelastic because the default elasticity (and friction) is 0. I should probably add that to the docs. Most other defaults are doced. Chipmunk never changes the forces applied to a body unless you ask it to.
I'll put the setters on the list of things to do for the next version. In the mean time, it doesn't hurt anything to just set the struct fields directly. As was mentioned, the body accessors are new anyway. Using them is not required except for mass, moment and angle. None of the shape properties have required setters.
I'll put the setters on the list of things to do for the next version. In the mean time, it doesn't hurt anything to just set the struct fields directly. As was mentioned, the body accessors are new anyway. Using them is not required except for mass, moment and angle. None of the shape properties have required setters.
Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
When I add shape->e = 0.9 I get an Error Starting Executable sheet: "Unable to find Mach task port for process-id 504: (os/kern) failure (0x5)." What is the correct way to change the struct's variables?
allocate the pointer before you dereference it.
you know, C basics.
you know, C basics.
It is allocated, cpShape *shape. I did not just add shape->e = 0.9, I also use shape and it works, I just did not feel the need to write the allocation and use lines of code in my previous message, as the problem is not about them.
You post implies you added one line of code, which contains one pointer dereference, and your program stopped working. Therefore, in all likelihood, the pointer is invalid.
"cpShape *shape" does not allocate the shape.
In any case, if you actually meant that you did allocate the shape, and you know for sure the pointer is valid, you have all the usual memory corruption tools available to you to debug.
"cpShape *shape" does not allocate the shape.
In any case, if you actually meant that you did allocate the shape, and you know for sure the pointer is valid, you have all the usual memory corruption tools available to you to debug.
The problem has disappeared. Thanks for answering my Chipmunk questions.

