Issue after svn update
-
- Posts: 81
- Joined: Fri Aug 27, 2010 1:00 am
- Contact:
Issue after svn update
Hi all
I'm having a problem with the update from the svn
I have an older version (I can't remember the number of the revision sorry) and did all my wrappers based on it
I recompiled all the source without any problems
but now the physics won't update!!!
I checked the functions that update and they are all called correctly but my objects aren't moving. the initial coordinate are correct but the call back for the rendering show that they don't move...
Any ideas what has changed recently in the code that could lead to this ?
I'm having a problem with the update from the svn
I have an older version (I can't remember the number of the revision sorry) and did all my wrappers based on it
I recompiled all the source without any problems
but now the physics won't update!!!
I checked the functions that update and they are all called correctly but my objects aren't moving. the initial coordinate are correct but the call back for the rendering show that they don't move...
Any ideas what has changed recently in the code that could lead to this ?
-
- Posts: 81
- Joined: Fri Aug 27, 2010 1:00 am
- Contact:
Re: Issue after svn update
Oki after a lot of fighting with the compiler and eclipse and the new space varaibles I figured out what was happening and now it works... nearly.
I get the object moving and colliding well but :
1) I got the impression that the newest version of chipmunk is slower... has anybody noticed that too ?
2) I get a crash when I remove objects. I read in the log that something was changed with removable of objects but I haven't had any chance to look seriously into it yet. Anybody knows what has changed?
Best regards
Jason
I get the object moving and colliding well but :
1) I got the impression that the newest version of chipmunk is slower... has anybody noticed that too ?
2) I get a crash when I remove objects. I read in the log that something was changed with removable of objects but I haven't had any chance to look seriously into it yet. Anybody knows what has changed?
Best regards
Jason
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Issue after svn update
You probably last used something prior to 5.3.0 when I added object sleeping. In general it should be a little faster, but some of the time trials were 1-2% slower. Low enough that it was probably just a measurement error.
There shouldn't be any really drastic changes or new bugs, but there have been a couple things that have come up with adding/removing objects due to the added complexity of waking objects when removing them. If you've found any bugs, I'll try to fix them ASAP.
There shouldn't be any really drastic changes or new bugs, but there have been a couple things that have come up with adding/removing objects due to the added complexity of waking objects when removing them. If you've found any bugs, I'll try to fix them ASAP.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 81
- Joined: Fri Aug 27, 2010 1:00 am
- Contact:
Re: Issue after svn update
well all I can say about the version is that I downloaded it from the google project page a bit less that 2 month ago.
I definitively saw the sleeping appear (that was my initial problem, did a small init mistake that caused the sleep to be infinite).
Yesterday I didn't have enough time to track where the crash was happening exactly but as you might remember I had to right special functions to delete objects to fit my port so I'll trace what function is causing the problem and get back to you with the best diagnostic (it might be something that I'm not deleting correctly anymore).
Best regards
Jason
I definitively saw the sleeping appear (that was my initial problem, did a small init mistake that caused the sleep to be infinite).
Yesterday I didn't have enough time to track where the crash was happening exactly but as you might remember I had to right special functions to delete objects to fit my port so I'll trace what function is causing the problem and get back to you with the best diagnostic (it might be something that I'm not deleting correctly anymore).
Best regards
Jason
-
- Posts: 81
- Joined: Fri Aug 27, 2010 1:00 am
- Contact:
Re: Issue after svn update
Hi
I found the error
In the previous version you didn't use the body when removing a shape (cpSpaceRemoveShape), but now you have to activate it.
Since I was first removing the body then removing the shape it caused it to crash
I had also to tweak a couple of other things but all in all now it seems to work fine
Then I also got crashes with composed shapes because of cpSpaceRemoveShape(cpSpace *space, cpShape *shape)
I Located the error in
I tried several changes but havn't found a simple solution
what happends is that I get stuck in an infinite loop here.
I have to delete all the shapes linked to the body
but when I want to delete it just get stuck in a infinite loop ...
to be clear here is a composed shape names with numbers:
composed shape
Body
Shape1
Shape2
simple form
Body
Shape
I init Body with Shape1
With this:
then add Shape2 to Body
with this
So now when I delete
if I delete a simple form
no problem
When I try deleting a composed shape
if I start by removing Shape2 then removing Shape1 I manage to remove Shape2 and get infinit loop in when removing Shape1
if I start by removing Shape1 then removing Shape2 then I get stuck directly in an infinit loop
I get the impression that Chipmunk has a problem in the shape list (but then its just a intuition)
Am I the only one having this or did I put my foot in a bug ?
Jason
I found the error
In the previous version you didn't use the body when removing a shape (cpSpaceRemoveShape), but now you have to activate it.
Since I was first removing the body then removing the shape it caused it to crash
I had also to tweak a couple of other things but all in all now it seems to work fine
Then I also got crashes with composed shapes because of cpSpaceRemoveShape(cpSpace *space, cpShape *shape)
I Located the error in
Code: Select all
static void
cpBodyRemoveShape(cpBody *body, cpShape *shape)
{
cpShape **prev_ptr = &body->shapesList;
cpShape *node = body->shapesList;
while(node && node != shape){
prev_ptr = &node->next;
node = node->next;
}
cpAssert(node, "Attempted to remove a shape from a body it was never attached to.");
(*prev_ptr) = node->next;
}
what happends is that I get stuck in an infinite loop here.
I have to delete all the shapes linked to the body
but when I want to delete it just get stuck in a infinite loop ...
to be clear here is a composed shape names with numbers:
composed shape
Body
Shape1
Shape2
simple form
Body
Shape
I init Body with Shape1
With this:
Code: Select all
shape = cpSpaceAddShape(space, cpPolyShapeNew(body, length, r, get_cpVect_by_JavaObj_field(env, jshape, "offset", "Lsskk/android/chipmunk/classes/cpVect;")));
cpSpaceAddShape(space, shape);
with this
Code: Select all
shape = cpSpaceAddShape(space, cpBoxShapeNew(body, scalex, scaley,get_cpVect_by_JavaObj_field(env, jshape, "offset", "Lsskk/android/chipmunk/classes/cpVect;")));
cpSpaceAddShape(space, shape);
if I delete a simple form
no problem
When I try deleting a composed shape
if I start by removing Shape2 then removing Shape1 I manage to remove Shape2 and get infinit loop in when removing Shape1
if I start by removing Shape1 then removing Shape2 then I get stuck directly in an infinit loop
I get the impression that Chipmunk has a problem in the shape list (but then its just a intuition)
Am I the only one having this or did I put my foot in a bug ?
Jason
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Issue after svn update
I know I tested this at one point, but maybe I introduced a new bug with it. I'm a bit pressed for time with some contract work at the moment. If you could make a simple replication program in C, that would be very helpful.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 81
- Joined: Fri Aug 27, 2010 1:00 am
- Contact:
Re: Issue after svn update
Hi
I never set up a work environment in C for chipmunk (I use the ndk compiler and use text editors for changing the code)so it might be difficult for me to write the right version in C
but here goes:
Sorry if thise doesn't work first time round
as you know my code is broken up to work from Java and I had to recompose everything
Jason
I never set up a work environment in C for chipmunk (I use the ndk compiler and use text editors for changing the code)so it might be difficult for me to write the right version in C
but here goes:
Code: Select all
//init
cpInitChipmunk();
cpResetShapeIdCounter();
space = cpSpaceNew();
space->iterations = 30;
space->gravity = cpv(0,-1000);
cpSpaceResizeStaticHash(space, 30.0, 1000);
cpSpaceResizeActiveHash(space 30.0, 1000);
body = cpBodyNew(INFINITY, INFINITY);
body->p = cpv(width/2, 0)
shape = cpSegmentShapeNew(body, cpv(-width/2,0), cpv(width/2,0), 10);
shape->e = .0;
shape->u = .8;
shape->collision_type(CollisionTypes.KILLER_WALL);
cpSpaceAddStaticShape(space, shape);
//composed object droping
double scalex = 150
double scaley = 20
body = cpBodyNew(m, cpMomentForBox(100, scalex, scaley));
cpSpaceAddBody(space, body);
shapeA = cpSpaceAddShape(space, cpBoxShapeNew(body, scalex, scaley,cpvzero));
cpSpaceAddShape(space, shape);
shapeA->e = 0.0;
shapeA->u = 1.0;
shapeA->collision_type(CollisionTypes.TARGET);
scalex = 20
scaley = 80
shapeB = cpSpaceAddShape(space, cpBoxShapeNew2(body, scalex, scaley,get_cpVect_by_JavaObj_field(env, jshape, "offset", "Lsskk/android/chipmunk/classes/cpVect;")));
cpSpaceAddShape(space, shape);
shapeB->e = 0.0;
shapeB->u = 1.0;
shapeB->collision_type(CollisionTypes.TARGET);
//collision handle
cpSpaceAddCollisionHandler(space, CollisionTypes.KILLER_WALL, CollisionTypes.TARGET, beginCollision, NULL, NULL, NULL, NULL);
static int
beginCollision(cpArbiter *arb, cpSpace *space, void *unused)
{
cpSpaceAddPostStepCallback(space, (cpPostStepFunc)postStepRemove, b, NULL);
}
void deleteBody(cpBody * body){
LOGE("deleteBody @");
if(body != NULL){
deleteConstraintsToABody(body);
cpSpaceRemoveBody(space, body);
cpBodyFree(body);
}else{
LOGE("body NULL");
}
LOGE("deleteBody OUT");
}
void deleteShape(cpShape * shape){
if(shape != NULL){
cpSpaceRemoveShape(space, shape);
cpShapeFree(shape);
}else{
LOGE("shape NULL");
}
}
void deleteShapeAndBody(cpShape *shape){
if(shape != NULL){
cpBody *body = shape->body;
deleteShape(shape);
deleteBody(body);
}else{
LOGE("shape NULL");
}
}
static void
postStepRemove(cpSpace *space, cpShape *shape, void *unused)
{
//this actually goes back to java but the result of the java is this
deleteShape(shapeB);
deleteShapeAndBody(shapeA);
}
as you know my code is broken up to work from Java and I had to recompose everything
Jason
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Issue after svn update
Chipmunk comes with project/build files for linux/OS X/MSVC/Cygwin etc. Do none of those work?
I had to modify what you posted quite a bit to get it to run, but came up with this:
Which outputs:
I had to modify what you posted quite a bit to get it to run, but came up with this:
Code: Select all
#include <stdio.h>
#include "chipmunk.h"
#define LOGE(mess) printf(mess "\n");
cpShape *shape, *shapeA, *shapeB;
cpSpace *space;
cpBody *body;
void deleteBody(cpBody * body){
LOGE("deleteBody @");
if(body != NULL){
// deleteConstraintsToABody(body);
cpSpaceRemoveBody(space, body);
cpBodyFree(body);
}else{
LOGE("body NULL");
}
LOGE("deleteBody OUT");
}
void deleteShape(cpShape * shape){
if(shape != NULL){
cpSpaceRemoveShape(space, shape);
cpShapeFree(shape);
}else{
LOGE("shape NULL");
}
}
void deleteShapeAndBody(cpShape *shape){
if(shape != NULL){
cpBody *body = shape->body;
deleteShape(shape);
deleteBody(body);
}else{
LOGE("shape NULL");
}
}
static void
postStepRemove(cpSpace *space, cpShape *shape, void *unused)
{
//this actually goes back to java but the result of the java is this
deleteShape(shapeB);
deleteShapeAndBody(shapeA);
}
static int
beginCollision(cpArbiter *arb, cpSpace *space, void *unused)
{
CP_ARBITER_GET_SHAPES(arb, a, b);
cpSpaceAddPostStepCallback(space, (cpPostStepFunc)postStepRemove, b->body, NULL);
return cpTrue;
}
int main(void){
//init
cpInitChipmunk();
cpResetShapeIdCounter();
space = cpSpaceNew();
space->iterations = 30;
space->gravity = cpv(0,-1000);
cpSpaceResizeStaticHash(space, 30.0, 1000);
cpSpaceResizeActiveHash(space, 30.0, 1000);
cpFloat width = 2.0;
body = cpBodyNew(INFINITY, INFINITY);
body->p = cpv(width/2, 0);
shape = cpSegmentShapeNew(body, cpv(-width/2,0), cpv(width/2,0), 10);
shape->e = .0;
shape->u = .8;
shape->collision_type = 1;
cpSpaceAddStaticShape(space, shape);
//composed object droping
double scalex = 150;
double scaley = 20;
cpFloat m = 100.0;
body = cpBodyNew(m, cpMomentForBox(100, scalex, scaley));
cpSpaceAddBody(space, body);
shapeA = cpSpaceAddShape(space, cpBoxShapeNew(body, scalex, scaley));
shapeA->e = 0.0;
shapeA->u = 1.0;
shapeA->collision_type = (2);
scalex = 20;
scaley = 80;
shapeB = cpSpaceAddShape(space, cpBoxShapeNew(body, scalex, scaley));
shapeB->e = 0.0;
shapeB->u = 1.0;
shapeB->collision_type = (2);
//collision handle
cpSpaceAddCollisionHandler(space, 1, 2, beginCollision, NULL, NULL, NULL, NULL);
for(int i=0; i<100; i++){
printf(".");
cpSpaceStep(space, 1.0/60.0);
}
printf("done\n");
return 1;
}
It was supposed to get stuck in an infinite loop on the second shape removal?.deleteBody @
deleteBody OUT
...................................................................................................done
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 81
- Joined: Fri Aug 27, 2010 1:00 am
- Contact:
Re: Issue after svn update
I don't have a problem with removing the body but only when I try and remove one of the shapes
I'm guessing that for some reason node->next becomes = node and it creates a infinit loop because it can't find shape but I can't figure out why ...
the problem occures for me in this loopif I start by removing Shape2 then removing Shape1 I manage to remove Shape2 and get infinit loop in when removing Shape1
if I start by removing Shape1 then removing Shape2 then I get stuck directly in an infinit loop
Code: Select all
static void
cpBodyRemoveShape(cpBody *body, cpShape *shape)
{
cpShape **prev_ptr = &body->shapesList;
cpShape *node = body->shapesList;
while(node && node != shape){
prev_ptr = &node->next;
node = node->next;
}
cpAssert(node, "Attempted to remove a shape from a body it was never attached to.");
(*prev_ptr) = node->next;
}
-
- Posts: 81
- Joined: Fri Aug 27, 2010 1:00 am
- Contact:
Re: Issue after svn update
oki found the bug
it was coming from my wrapper in between Java and C
Sorry for stressing you
thank you for trying it out, it confirmed the problem was on my side
it was coming from my wrapper in between Java and C
Sorry for stressing you
thank you for trying it out, it confirmed the problem was on my side
Who is online
Users browsing this forum: No registered users and 6 guests