Path: blob/master/scene/resources/2d/skeleton/skeleton_modification_2d_lookat.h
9903 views
/**************************************************************************/1/* skeleton_modification_2d_lookat.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "scene/2d/skeleton_2d.h"33#include "scene/resources/2d/skeleton/skeleton_modification_2d.h"3435///////////////////////////////////////36// SkeletonModification2DLookAt37///////////////////////////////////////3839class SkeletonModification2DLookAt : public SkeletonModification2D {40GDCLASS(SkeletonModification2DLookAt, SkeletonModification2D);4142private:43int bone_idx = -1;44NodePath bone2d_node;45ObjectID bone2d_node_cache;4647NodePath target_node;48ObjectID target_node_cache;49Node2D *target_node_reference = nullptr;5051float additional_rotation = 0;52bool enable_constraint = false;53float constraint_angle_min = 0;54float constraint_angle_max = (2.0 * Math::PI);55bool constraint_angle_invert = false;56bool constraint_in_localspace = true;5758void update_bone2d_cache();59void update_target_cache();6061protected:62static void _bind_methods();63bool _set(const StringName &p_path, const Variant &p_value);64bool _get(const StringName &p_path, Variant &r_ret) const;65void _get_property_list(List<PropertyInfo> *p_list) const;6667public:68void _execute(float p_delta) override;69void _setup_modification(SkeletonModificationStack2D *p_stack) override;70void _draw_editor_gizmo() override;7172void set_bone2d_node(const NodePath &p_target_node);73NodePath get_bone2d_node() const;74void set_bone_index(int p_idx);75int get_bone_index() const;7677void set_target_node(const NodePath &p_target_node);78NodePath get_target_node() const;7980void set_additional_rotation(float p_rotation);81float get_additional_rotation() const;8283void set_enable_constraint(bool p_constraint);84bool get_enable_constraint() const;85void set_constraint_angle_min(float p_angle_min);86float get_constraint_angle_min() const;87void set_constraint_angle_max(float p_angle_max);88float get_constraint_angle_max() const;89void set_constraint_angle_invert(bool p_invert);90bool get_constraint_angle_invert() const;91void set_constraint_in_localspace(bool p_constraint_in_localspace);92bool get_constraint_in_localspace() const;9394SkeletonModification2DLookAt();95~SkeletonModification2DLookAt();96};979899