mayobutter wrote:
AdamAdept wrote:
I tried it that way at first, however I have situations where a body needs to change solidity in the middle of contact. Right now I change the contact mask, then just flag the body involved for refiltering and the contact will automatically add or remove. It would be an improvement however, if I could set the contact to act as a sensor, so I could still reference it but it wouldn't collide, and later set it solid again. Is there a way to do that? And if you disable the contact, can you still get the "remove contact" event?
Check out how the "extras/Platform.as" class disables the contact for one-way platforms:
https://github.com/jesses/wck/blob/mast ... latform.asSo that's how you could ignore / disable a contact before it has any effect. Then after the timestep you could just turn it into a sensor or whatever. Not sure exactly what you're trying to make.
Thanks, I'll look into doing this. I just need to get an end contact event, even when a contact is disabled. If that works, I should be able to ditch the filter.
mayobutter wrote:
AdamAdept wrote:
OK, I made an optimized version of QueryPoint which very rarely needs to callback to AS3 (in my use cases anyway). I do this by allowing exclusion of a body and filtering by category:With this code, most of the time I don't get a single callback to AS3. And the result? QueryPoint is still my bottleneck. So, I guess QueryPoint is just slow and the AS3 callback wasn't a big factor. Well that was fun.
Why are you calling QueryPoint so much? I think your original idea of pushing them to an array and returning all results at once might work but seriously, why do you need to call it so much?
I have a world with 30+ moving boxes, that can be conveyed up or down moving ladders. The ladders may have a thin cover over the top, in which case the box needs to see past the cover, to whether there is a down-ladder under it to grab. In this case there's no contact available, and I don't want to put a sensor sticking out the top of every ladder because there could be 100+ ladders in the world. So I was doing a QueryPoint just underneath each box, every step. I didn't realize that call was crazy-slow. I'm seeing 0.56ms per call in a production build, and that's using my optimized version! On one level, the entire box2d.step is only 2.48ms, so 5 QueryPoint()'s is equal to one box2d step. Crazy.
While we're on the subject, setting up a new b2Body is about 0.65ms, which is my next bottleneck. I'm trying to generate mass amounts of smoke that spawns/destroys very quickly, and uses a body to flow around objects, only the body creation is killing me. I really wish b2Body's were true objects that could be reused/created independent of a world. I think this is a limitation of the C version though.