jesses / wck

Box2d Flash Alchemy Port + World Construction Kit (AS3 Physics Engine)
http://sideroller.com/wck
358 stars 55 forks source link

Implement RayCast #11

Open yderidde opened 12 years ago

yderidde commented 12 years ago

I saw in the codebase that RayCast is not implemented. Is there a chance you implement it ?

Here the snippet from b2Fixture: /// Cast a ray against this shape. /// @param output the ray-cast results. /// @param input the ray-cast input parameters. /// void RayCast(b2RayCastOutput* output, const b2RayCastInput& input) const; public function RayCast():void { /// NOT IMPLEMENTED. }

jesses commented 12 years ago

You could probably just use the b2World RayCast and check if that shape is in the results for now. Waiting until the new Adobe Alchemy comes out before I make any big changes.

yderidde commented 12 years ago

I would need a b2RayCastOutput with the calculated fraction etc ... which is not what the RayCast in b2World provide so this is not an alternative for me i'm afraid :(

Considering that you know pretty well your code. I'm wondering why you didn't implement RayCast in b2Fixture ? is there a show-stopper or some kind of complexity that prevented you to implement it ?

jesses commented 12 years ago

You do get the fraction with the b2World::RayCast. It's passed into the raycast callback function.

Can't remember why I didn't implement it. Must've been a difficult function that I didn't think was worth the effort. No one has asked for it before now...

yderidde commented 12 years ago

Ok i will try with the b2World RayCast function but before that I have a very nasty issue and not sure at all where it comes from .. it is probably not the best place to discuss about it here but while I have you I will tell you :)

I'm getting an RTE when creating a b2Fixture from a shape or from the body. Here the stack: TypeError: Error #1006: value is not a function. at cmodule.Box2D::FSM__Z20b2Body_CreateFixturePvP8_AS3_Val/work() at Function/() at Function/() at Box2DAS.Dynamics::b2Fixture()[/Developer/Repositories/app/app-client/src/main/air/Box2DAS/Dynamics/b2Fixture.as:25] at Box2DAS.Collision.Shapes::b2Shape/create()[/Developer/Repositories/app/app-client/src/main/air/Box2DAS/Collision/Shapes/b2Shape.as:26]

Maybe we can take this one offline if you are ok with helping me figuring out what can it be :)

jesses commented 12 years ago

Can you post this to the Box2D WCK forums? I check that more than github. Please post the part of your code that results in that error. The forums are here:

http://box2d.org/forum/viewforum.php?f=19

yderidde commented 12 years ago

Done: http://box2d.org/forum/viewtopic.php?f=19&t=8178

yderidde commented 12 years ago

Jesses, can you please have a look at the thread here http://box2d.org/forum/viewtopic.php?f=19&t=8178 Would like to have your input on it. Thanks in advance. :)

jesses commented 12 years ago

Can't figure it out at first glance I'll take a look when I get some free time, probably this weekend.

yderidde commented 12 years ago

thanks for this !

jesses commented 12 years ago

Fixed: http://box2d.org/forum/viewtopic.php?f=19&t=8178&p=35143#p35143