(callback B2RaycastCallback, point1 B2Vec2, point2 B2Vec2)
| 975 | } |
| 976 | |
| 977 | func (world *B2World) RayCast(callback B2RaycastCallback, point1 B2Vec2, point2 B2Vec2) { |
| 978 | |
| 979 | // B2TreeRayCastCallback |
| 980 | wrapper := func(input B2RayCastInput, nodeId int) float64 { |
| 981 | |
| 982 | userData := world.M_contactManager.M_broadPhase.GetUserData(nodeId) |
| 983 | proxy := userData.(*B2FixtureProxy) |
| 984 | fixture := proxy.Fixture |
| 985 | index := proxy.ChildIndex |
| 986 | output := MakeB2RayCastOutput() |
| 987 | hit := fixture.RayCast(&output, input, index) |
| 988 | |
| 989 | if hit { |
| 990 | fraction := output.Fraction |
| 991 | point := B2Vec2Add(B2Vec2MulScalar((1.0-fraction), input.P1), B2Vec2MulScalar(fraction, input.P2)) |
| 992 | return callback(fixture, point, output.Normal, fraction) |
| 993 | } |
| 994 | |
| 995 | return input.MaxFraction |
| 996 | } |
| 997 | |
| 998 | input := MakeB2RayCastInput() |
| 999 | input.MaxFraction = 1.0 |
| 1000 | input.P1 = point1 |
| 1001 | input.P2 = point2 |
| 1002 | world.M_contactManager.M_broadPhase.RayCast(wrapper, input) |
| 1003 | } |
| 1004 | |
| 1005 | // void (world *B2World) DrawShape(b2Fixture* fixture, const b2Transform& xf, const b2Color& color) |
| 1006 | // { |
nothing calls this directly
no test coverage detected