Hello everyone,
i am using 25 objects ( shapes) in my game, cpHashSet size is 47, after collision object(shape) will remove from the space.
I think after removing the objects the cpHashSet size should be decrese, but its not.
I am unable to understand what exactly happening.
plz give explanation for this
thank you
sudheer
cpHashset size does not decrease after removal of shape obje
-
- Posts: 4
- Joined: Tue Dec 29, 2009 1:19 am
- Contact:
- Tam Toucan
- Posts: 141
- Joined: Tue Jun 23, 2009 4:26 pm
- Contact:
Re: cpHashset size does not decrease after removal of shape obje
Code: Select all
typedef struct cpHashSet {
// Number of elements stored in the table.
int entries;
// Number of cells in the table.
int size;
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: cpHashset size does not decrease after removal of shape obje
As Tam pointed out, hash tables have a separate table size and number of entries they store. Think of it as the amount of space allocated compared to the amount of space used.
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: 4
- Joined: Tue Dec 29, 2009 1:19 am
- Contact:
Re: cpHashset size does not decrease after removal of shape obje
Thanks Tam and slembcke,
Now I understand concept of Hashset,and also able to visualize it. Thank you once again.
Actually I am developing a game and have to do a performance tuning. I think game performance can be improve by applying collision filtering(previously I filtering collision in call back function). recently I implement group filtering and performance improve a little bit. I think, more performance improve if I implement Bounding Box but I don't understand it and unable to implement it.
can you please explain me.
Thanks
Now I understand concept of Hashset,and also able to visualize it. Thank you once again.
Actually I am developing a game and have to do a performance tuning. I think game performance can be improve by applying collision filtering(previously I filtering collision in call back function). recently I implement group filtering and performance improve a little bit. I think, more performance improve if I implement Bounding Box but I don't understand it and unable to implement it.
can you please explain me.
Thanks
-
- Posts: 157
- Joined: Mon Aug 20, 2007 12:53 pm
- Location: London, UK
- Contact:
Re: cpHashset size does not decrease after removal of shape obje
Chipmunk automatically rejects collisions if the bounding boxes don't intersect. There's no need to do anything extra there.
-
- Posts: 4
- Joined: Tue Dec 29, 2009 1:19 am
- Contact:
Re: cpHashset size does not decrease after removal of shape obje
Thanks maxmile,
is chipmunk automatically define bounding boxes for shape we create ?
and also are we able to define layer and group to same shape?
can you please explain me,How we can use layer I think description in the document is insufficient.
is chipmunk automatically define bounding boxes for shape we create ?
and also are we able to define layer and group to same shape?
can you please explain me,How we can use layer I think description in the document is insufficient.
- Tam Toucan
- Posts: 141
- Joined: Tue Jun 23, 2009 4:26 pm
- Contact:
Re: cpHashset size does not decrease after removal of shape obje
For chipmunk to try the "expensive" collision code checking it first does the following fast checks to do early rejection.
So Chipmunk automatically does BB checking, it then checks that the shapes aren't in the same group (so you generally give all shapes for the same object the same (non-zero) group value.
Finally it checks that the two shapes share the same layer. Think of the layer a 32 flat planes stacked parallel to each other. The bit pattern of the layer value determines which planes the shape is on. For two shapes to collide they must have a common plane.
So if shapeA has layer = 0x00000001 and shapeB has layer = 0x00000003 they can collide since they are both on the plane for bit0. If shapeB didn't have bit0 set then it could never collide with shapeA.
Code: Select all
queryReject(cpShape *a, cpShape *b)
{
return
// BBoxes must overlap
!cpBBintersects(a->bb, b->bb)
// Don't collide shapes attached to the same body.
|| a->body == b->body
// Don't collide objects in the same non-zero group
|| (a->group && b->group && a->group == b->group)
// Don't collide objects that don't share at least on layer.
|| !(a->layers & b->layers);
}
Finally it checks that the two shapes share the same layer. Think of the layer a 32 flat planes stacked parallel to each other. The bit pattern of the layer value determines which planes the shape is on. For two shapes to collide they must have a common plane.
So if shapeA has layer = 0x00000001 and shapeB has layer = 0x00000003 they can collide since they are both on the plane for bit0. If shapeB didn't have bit0 set then it could never collide with shapeA.
-
- Posts: 4
- Joined: Tue Dec 29, 2009 1:19 am
- Contact:
Re: cpHashset size does not decrease after removal of shape obje
Hi Tam,
Thank you very much for such a good explanation about collision filtering.
I have implement group and layer, now game has much better performance.
Thanks
Thank you very much for such a good explanation about collision filtering.
I have implement group and layer, now game has much better performance.
Thanks
Who is online
Users browsing this forum: No registered users and 6 guests