Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
Added Get Contact Coords node
Browse files Browse the repository at this point in the history
Get Contact Coords exposes the contact the set object has with other physics objects.
  • Loading branch information
Simonrazer committed Jan 25, 2020
1 parent 4e2b7cc commit 67784d1
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Sources/armory/logicnode/GetContactCoordsNode.hx
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;
}
}
17 changes: 17 additions & 0 deletions logicnode_definitions/physics_get_contact_coords.py
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')

0 comments on commit 67784d1

Please sign in to comment.