forked from LeenkxTeam/LNXSDK
Update leenkx/Sources/leenkx/trait/physics/bullet/PhysicsWorld.hx
This commit is contained in:
parent
07d98639f2
commit
8d1c2c51bd
@ -397,6 +397,7 @@ class PhysicsWorld extends Trait {
|
|||||||
rayTo.setValue(to.x, to.y, to.z);
|
rayTo.setValue(to.x, to.y, to.z);
|
||||||
|
|
||||||
var rayCallback = new bullet.Bt.ClosestRayResultCallback(rayFrom, rayTo);
|
var rayCallback = new bullet.Bt.ClosestRayResultCallback(rayFrom, rayTo);
|
||||||
|
|
||||||
#if js
|
#if js
|
||||||
rayCallback.set_m_collisionFilterGroup(group);
|
rayCallback.set_m_collisionFilterGroup(group);
|
||||||
rayCallback.set_m_collisionFilterMask(mask);
|
rayCallback.set_m_collisionFilterMask(mask);
|
||||||
@ -406,12 +407,20 @@ class PhysicsWorld extends Trait {
|
|||||||
#end
|
#end
|
||||||
var worldDyn: bullet.Bt.DynamicsWorld = world;
|
var worldDyn: bullet.Bt.DynamicsWorld = world;
|
||||||
var worldCol: bullet.Bt.CollisionWorld = worldDyn;
|
var worldCol: bullet.Bt.CollisionWorld = worldDyn;
|
||||||
|
|
||||||
|
if (this.drawRaycasts && this.debugDrawHelper != null) {
|
||||||
|
this.debugDrawHelper.drawRayCast(
|
||||||
|
rayFrom.x(), rayFrom.y(), rayFrom.z(),
|
||||||
|
rayTo.x(), rayTo.y(), rayTo.z(),
|
||||||
|
0.73, 0.341, 1.0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
worldCol.rayTest(rayFrom, rayTo, rayCallback);
|
worldCol.rayTest(rayFrom, rayTo, rayCallback);
|
||||||
var rb: RigidBody = null;
|
var rb: RigidBody = null;
|
||||||
var hitInfo: Hit = null;
|
var hitInfo: Hit = null;
|
||||||
|
|
||||||
var rc: bullet.Bt.RayResultCallback = rayCallback;
|
if (rayCallback.hasHit()) {
|
||||||
if (rc.hasHit()) {
|
|
||||||
#if js
|
#if js
|
||||||
var co = rayCallback.get_m_collisionObject();
|
var co = rayCallback.get_m_collisionObject();
|
||||||
var body = untyped bullet.Bt.Ammo.btRigidBody.prototype.upcast(co);
|
var body = untyped bullet.Bt.Ammo.btRigidBody.prototype.upcast(co);
|
||||||
@ -471,8 +480,7 @@ class PhysicsWorld extends Trait {
|
|||||||
|
|
||||||
var hitInfo: ConvexHit = null;
|
var hitInfo: ConvexHit = null;
|
||||||
|
|
||||||
var cc: bullet.Bt.ClosestConvexResultCallback = convexCallback;
|
if (convexCallback.hasHit()) {
|
||||||
if (cc.hasHit()) {
|
|
||||||
#if js
|
#if js
|
||||||
var hit = convexCallback.get_m_hitPointWorld();
|
var hit = convexCallback.get_m_hitPointWorld();
|
||||||
convexHitPointWorld.set(hit.x(), hit.y(), hit.z());
|
convexHitPointWorld.set(hit.x(), hit.y(), hit.z());
|
||||||
@ -509,16 +517,22 @@ class PhysicsWorld extends Trait {
|
|||||||
|
|
||||||
public function setDebugDrawMode(debugDrawMode: DebugDrawMode) {
|
public function setDebugDrawMode(debugDrawMode: DebugDrawMode) {
|
||||||
if (debugDrawHelper == null) {
|
if (debugDrawHelper == null) {
|
||||||
|
// Initialize if helper is null AND (standard debug mode is requested OR our custom raycast drawing is requested)
|
||||||
if (debugDrawMode != NoDebug || this.drawRaycasts) {
|
if (debugDrawMode != NoDebug || this.drawRaycasts) {
|
||||||
initDebugDrawing();
|
initDebugDrawing();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// Helper is null and no debug drawing needed, so exit
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we reached here, the helper is initialized (or was already)
|
||||||
|
// Now set the standard Bullet debug mode on the actual drawer
|
||||||
#if js
|
#if js
|
||||||
world.getDebugDrawer().setDebugMode(debugDrawMode);
|
// Ensure drawer exists before setting mode (might have just been initialized)
|
||||||
|
var drawer = world.getDebugDrawer();
|
||||||
|
if (drawer != null) drawer.setDebugMode(debugDrawMode);
|
||||||
#elseif hl
|
#elseif hl
|
||||||
hlDebugDrawer_setDebugMode(debugDrawMode);
|
hlDebugDrawer_setDebugMode(debugDrawMode);
|
||||||
#end
|
#end
|
||||||
@ -665,10 +679,7 @@ enum abstract DebugDrawMode(Int) from Int to Int {
|
|||||||
// We could use it in the future to toggle depth testing for lines, i.e. draw actual 3D lines if not set and Kha's g2 lines if set.
|
// We could use it in the future to toggle depth testing for lines, i.e. draw actual 3D lines if not set and Kha's g2 lines if set.
|
||||||
var FastWireframe = 1 << 13;
|
var FastWireframe = 1 << 13;
|
||||||
|
|
||||||
/**
|
/** Draw the normal vectors of the triangles of the physics collider meshes. **/
|
||||||
Draw the normal vectors of the triangles of the physics collider meshes.
|
|
||||||
This only works for `Mesh` collision shapes.
|
|
||||||
**/
|
|
||||||
// Outside of Leenkx this works for a few more collision shapes
|
// Outside of Leenkx this works for a few more collision shapes
|
||||||
var DrawNormals = 1 << 14;
|
var DrawNormals = 1 << 14;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user