This repository has been archived by the owner on Jan 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get Contact Coords exposes the contact the set object has with other physics objects.
- Loading branch information
1 parent
4e2b7cc
commit 67784d1
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package armory.logicnode; | ||
|
||
import iron.object.Object; | ||
import armory.trait.physics.RigidBody; | ||
|
||
class GetContactCoordsNode extends LogicNode { | ||
|
||
public function new(tree: LogicTree) { | ||
super(tree); | ||
} | ||
|
||
override function get(from: Int): Dynamic { | ||
var object: Object = inputs[0].get(); | ||
if (object == null) return null; | ||
|
||
#if arm_physics | ||
if (from == 0){ | ||
var physics = armory.trait.physics.PhysicsWorld.active; | ||
var rbs = physics.getContacts(object.getTrait(RigidBody)); | ||
var obs = []; | ||
if (rbs != null) for (rb in rbs) if (rb != null) obs.push(rb.object); | ||
return obs; | ||
} | ||
else if (from == 1){ | ||
var physics = armory.trait.physics.PhysicsWorld.active; | ||
var cps = physics.getContactPairs(object.getTrait(RigidBody)); | ||
var obs = []; | ||
if (cps != null) for (cp in cps) if (cp != null) obs.push(cp.posA); | ||
return obs; | ||
} | ||
#end | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import bpy | ||
from bpy.props import * | ||
from bpy.types import Node, NodeSocket | ||
from arm.logicnode.arm_nodes import * | ||
|
||
class GetContactCoordsNode(Node, ArmLogicTreeNode): | ||
'''Get contact coords Node''' | ||
bl_idname = 'LNGetContactCoordsNode' | ||
bl_label = 'Get Contact Coords' | ||
bl_icon = 'QUESTION' | ||
|
||
def init(self, context): | ||
self.inputs.new('ArmNodeSocketObject', 'Object') | ||
self.outputs.new('ArmNodeSocketArray', 'Array') | ||
self.outputs.new('ArmNodeSocketArray', 'Coords') | ||
|
||
add_node(GetContactCoordsNode, category='Physics') |