CP._cpBodyGetPos(_handle) return Vector2(NaN,NaN)
-
- Posts: 37
- Joined: Fri Aug 30, 2013 4:27 pm
- Contact:
CP._cpBodyGetPos(_handle) return Vector2(NaN,NaN)
During Fixed update, body get from space, and when try to access the position, get this error.
-
- Posts: 37
- Joined: Fri Aug 30, 2013 4:27 pm
- Contact:
Re: CP._cpBodyGetPos(_handle) return Vector2(NaN,NaN)
I can not fix this bug by myself. _cpBodyGetPos was encapsulated. There may be somewhere in the function created NaN or may be some other error. Need help on this as soon as possible. Thanks!
-
- Posts: 37
- Joined: Fri Aug 30, 2013 4:27 pm
- Contact:
Re: CP._cpBodyGetPos(_handle) return Vector2(NaN,NaN)
Just searched Github repository. So the function return NaN may because there is error during the function processing.
What members or attributes may cause error in this function?
I have check the handle, it is not null, and pointed to the object that I want, and the object it pointed not been released. But I will going to check if there are some member gone wrong in that object.
What members or attributes may cause error in this function?
I have check the handle, it is not null, and pointed to the object that I want, and the object it pointed not been released. But I will going to check if there are some member gone wrong in that object.
-
- Posts: 37
- Joined: Fri Aug 30, 2013 4:27 pm
- Contact:
Re: CP._cpBodyGetPos(_handle) return Vector2(NaN,NaN)
So currently, what I did is to avoid the situation cause this bug. And it works.
-
- Posts: 37
- Joined: Fri Aug 30, 2013 4:27 pm
- Contact:
Re: CP._cpBodyGetPos(_handle) return Vector2(NaN,NaN)
The bug still exist. When multiple object overlaped seriously at a time, it happens. The shapes are segments shapes.
-
- Posts: 37
- Joined: Fri Aug 30, 2013 4:27 pm
- Contact:
Re: CP._cpBodyGetPos(_handle) return Vector2(NaN,NaN)
I have a question. What Chipmunk2D will do while a object hit two other objects that have different collision handle functions.
For example:
player, A, B
they overlapped
and there are handle functions:
player_A, player_B
will Chipmunk2D call player_A first and then player_B? I tested the situation in mono developer debugger. It seems to call one after another. Will this cause bugs? Since the collision happened at the same time, but the collision manager do not know which collision should be handled first.
For example:
player, A, B
they overlapped
and there are handle functions:
player_A, player_B
will Chipmunk2D call player_A first and then player_B? I tested the situation in mono developer debugger. It seems to call one after another. Will this cause bugs? Since the collision happened at the same time, but the collision manager do not know which collision should be handled first.
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: CP._cpBodyGetPos(_handle) return Vector2(NaN,NaN)
NaNs happen when you do certain math operations with undefined answers. Divide zero by zero, multiply infinity by zero, etc. In Chipmunk they generally happen because you've either passed a NaN value to Chipmunk as input or did something odd with infinite mass bodies (or kinematic ones).
So the problem you are seeing is due to normal (not infinite mass or segment shapes overlapping a lot? Possibly the collision detection is returning a bad normal? I don't know of any bugs where that would happen, but it's the best lead I can think of. The collision handler shouldn't break the collision detection at all. You could use it to verify the normal though. Print it out if it's not close to 1.0 in length.
So the problem you are seeing is due to normal (not infinite mass or segment shapes overlapping a lot? Possibly the collision detection is returning a bad normal? I don't know of any bugs where that would happen, but it's the best lead I can think of. The collision handler shouldn't break the collision detection at all. You could use it to verify the normal though. Print it out if it's not close to 1.0 in length.
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: 37
- Joined: Fri Aug 30, 2013 4:27 pm
- Contact:
Re: CP._cpBodyGetPos(_handle) return Vector2(NaN,NaN)
I avoid the overlaping situation, but it still happens. I think it may related to isKinematic( infinite mass or 0 mass ). And I have added break points to cpBodySetPos and position{set}, observed all the values passing in. None of those values are NaN.slembcke wrote:NaNs happen when you do certain math operations with undefined answers. Divide zero by zero, multiply infinity by zero, etc. In Chipmunk they generally happen because you've either passed a NaN value to Chipmunk as input or did something odd with infinite mass bodies (or kinematic ones).
So the problem you are seeing is due to normal (not infinite mass or segment shapes overlapping a lot? Possibly the collision detection is returning a bad normal? I don't know of any bugs where that would happen, but it's the best lead I can think of. The collision handler shouldn't break the collision detection at all. You could use it to verify the normal though. Print it out if it's not close to 1.0 in length.
I will going to check the isKinematic related codes. Thanks !!
-
- Posts: 37
- Joined: Fri Aug 30, 2013 4:27 pm
- Contact:
Re: CP._cpBodyGetPos(_handle) return Vector2(NaN,NaN)
It seems related to isKinematic. After I replaced the isKinematic to disable/enable chipmunk body. The bug disappeared.
Who is online
Users browsing this forum: No registered users and 2 guests