from lnx.logicnode.lnx_nodes import *

class RayCastOnNode(LnxLogicTreeNode):
    """Casts a physics ray and returns the first object that is hit by
    this ray.

    @seeNode Mask

    @input In: Input trigger
    @input From: the location from where to start the ray, in world
        coordinates
    @input To: the target location of the ray, in world coordinates
    @input Mask: a bit mask value to specify which
        objects are considered

    @output Out: Output after hit
    @output RB: the object that was hit
    @output Hit: the hit position in world coordinates
    @output Normal: the surface normal of the hit position relative to
        the world
    """
    bl_idname = 'LNCastPhysicsRayOnNode'
    bl_label = 'Ray Cast On'
    lnx_section = 'ray'
    lnx_version = 1

    def lnx_init(self, context):
        self.add_input('LnxNodeSocketAction', 'In')
        self.add_input('LnxVectorSocket', 'From')
        self.add_input('LnxVectorSocket', 'To')
        self.add_input('LnxIntSocket', 'Mask', default_value=1)

        self.add_output('LnxNodeSocketAction', 'Out')
        self.add_output('LnxNodeSocketObject', 'RB')
        self.add_output('LnxVectorSocket', 'Hit')
        self.add_output('LnxVectorSocket', 'Normal')