mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 23:34:53 +08:00
[godot] Clean-up SpinePathConstraintData, rename common.h
This commit is contained in:
parent
f9fd3f54d4
commit
676a7443dd
@ -27,11 +27,11 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "common.h"
|
||||
#include "SpineAnimation.h"
|
||||
#include "SpineSkeleton.h"
|
||||
#include "SpineEvent.h"
|
||||
#include "SpineTimeline.h"
|
||||
#include "SpineCommon.h"
|
||||
|
||||
#include "core/method_bind_ext.gen.inc"
|
||||
|
||||
|
||||
@ -27,8 +27,8 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "common.h"
|
||||
#include "SpineAnimationState.h"
|
||||
#include "SpineCommon.h"
|
||||
|
||||
void SpineAnimationState::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("update", "delta"), &SpineAnimationState::update, DEFVAL(0));
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#include "SpineAttachment.h"
|
||||
#include "common.h"
|
||||
#include "SpineCommon.h"
|
||||
|
||||
void SpineAttachment::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_attachment_name"), &SpineAttachment::get_attachment_name);
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
#include "SpineBone.h"
|
||||
#include "SpineSprite.h"
|
||||
#include "SpineSkeleton.h"
|
||||
#include "common.h"
|
||||
#include "SpineCommon.h"
|
||||
|
||||
void SpineBone::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("update_world_transform"), &SpineBone::update_world_transform);
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#include "SpineBoneData.h"
|
||||
#include "common.h"
|
||||
#include "SpineCommon.h"
|
||||
|
||||
void SpineBoneData::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_index"), &SpineBoneData::get_index);
|
||||
@ -192,4 +192,4 @@ Color SpineBoneData::get_color() {
|
||||
void SpineBoneData::set_color(Color color) {
|
||||
SPINE_CHECK(bone_data,)
|
||||
bone_data->getColor().set(color.r, color.g, color.b, color.a);
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,4 +64,15 @@ void SpineConstant::_bind_methods() {
|
||||
BIND_ENUM_CONSTANT(TransformMode_NoRotationOrReflection)
|
||||
BIND_ENUM_CONSTANT(TransformMode_NoScale)
|
||||
BIND_ENUM_CONSTANT(TransformMode_NoScaleOrReflection)
|
||||
|
||||
BIND_ENUM_CONSTANT(PositionMode_Fixed)
|
||||
BIND_ENUM_CONSTANT(PositionMode_Percent)
|
||||
|
||||
BIND_ENUM_CONSTANT(SpacingMode_Length)
|
||||
BIND_ENUM_CONSTANT(SpacingMode_Fixed)
|
||||
BIND_ENUM_CONSTANT(SpacingMode_Percent)
|
||||
|
||||
BIND_ENUM_CONSTANT(RotateMode_Tangent)
|
||||
BIND_ENUM_CONSTANT(RotateMode_Chain)
|
||||
BIND_ENUM_CONSTANT(RotateMode_ChainScale)
|
||||
}
|
||||
|
||||
@ -81,11 +81,31 @@ public:
|
||||
TransformMode_NoScale,
|
||||
TransformMode_NoScaleOrReflection
|
||||
};
|
||||
|
||||
enum PositionMode {
|
||||
PositionMode_Fixed = 0,
|
||||
PositionMode_Percent
|
||||
};
|
||||
|
||||
enum SpacingMode {
|
||||
SpacingMode_Length = 0,
|
||||
SpacingMode_Fixed,
|
||||
SpacingMode_Percent
|
||||
};
|
||||
|
||||
enum RotateMode {
|
||||
RotateMode_Tangent = 0,
|
||||
RotateMode_Chain,
|
||||
RotateMode_ChainScale
|
||||
};
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(SpineConstant::MixBlend);
|
||||
VARIANT_ENUM_CAST(SpineConstant::MixDirection);
|
||||
VARIANT_ENUM_CAST(SpineConstant::PropertyId);
|
||||
VARIANT_ENUM_CAST(SpineConstant::TransformMode);
|
||||
VARIANT_ENUM_CAST(SpineConstant::PositionMode);
|
||||
VARIANT_ENUM_CAST(SpineConstant::SpacingMode);
|
||||
VARIANT_ENUM_CAST(SpineConstant::RotateMode);
|
||||
|
||||
#endif//GODOT_SPINECONSTANT_H
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
|
||||
#include "SpineConstraintData.h"
|
||||
#include <spine/ConstraintData.h>
|
||||
#include "common.h"
|
||||
#include "SpineCommon.h"
|
||||
|
||||
void SpineConstraintData::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_constraint_name"), &SpineConstraintData::get_constraint_name);
|
||||
|
||||
@ -28,8 +28,7 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#include "SpineEvent.h"
|
||||
#include <spine/Event.h>
|
||||
#include "common.h"
|
||||
#include "SpineCommon.h"
|
||||
|
||||
void SpineEvent::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_data"), &SpineEvent::get_data);
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#include "SpineEventData.h"
|
||||
#include "common.h"
|
||||
#include "SpineCommon.h"
|
||||
|
||||
void SpineEventData::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_event_name"), &SpineEventData::get_event_name);
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
|
||||
#include "SpineIkConstraint.h"
|
||||
#include "SpineBone.h"
|
||||
#include "common.h"
|
||||
#include "SpineCommon.h"
|
||||
|
||||
void SpineIkConstraint::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("update"), &SpineIkConstraint::update);
|
||||
|
||||
@ -28,8 +28,7 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#include "SpineIkConstraintData.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "SpineCommon.h"
|
||||
|
||||
void SpineIkConstraintData::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_bones"), &SpineIkConstraintData::get_bones);
|
||||
|
||||
@ -38,7 +38,7 @@ class SpineIkConstraintData : public SpineConstraintData {
|
||||
GDCLASS(SpineIkConstraintData, SpineConstraintData)
|
||||
|
||||
spine::IkConstraintData *get_spine_constraint_data() { return (spine::IkConstraintData *)get_spine_object(); }
|
||||
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
@ -49,31 +49,31 @@ public:
|
||||
Array get_bones();
|
||||
|
||||
Ref<SpineBoneData> get_target();
|
||||
|
||||
|
||||
void set_target(Ref<SpineBoneData> v);
|
||||
|
||||
int get_bend_direction();
|
||||
|
||||
|
||||
void set_bend_direction(int v);
|
||||
|
||||
bool get_compress();
|
||||
|
||||
|
||||
void set_compress(bool v);
|
||||
|
||||
bool get_stretch();
|
||||
|
||||
|
||||
void set_stretch(bool v);
|
||||
|
||||
bool get_uniform();
|
||||
|
||||
|
||||
void set_uniform(bool v);
|
||||
|
||||
float get_mix();
|
||||
|
||||
|
||||
void set_mix(float v);
|
||||
|
||||
float get_softness();
|
||||
|
||||
|
||||
void set_softness(float v);
|
||||
};
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
|
||||
#include "SpinePathConstraint.h"
|
||||
#include "SpineBone.h"
|
||||
#include "common.h"
|
||||
#include "SpineCommon.h"
|
||||
|
||||
void SpinePathConstraint::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("update"), &SpinePathConstraint::update);
|
||||
|
||||
@ -28,10 +28,10 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#include "SpinePathConstraintData.h"
|
||||
|
||||
#include "SpineCommon.h"
|
||||
|
||||
void SpinePathConstraintData::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_all_bone_data"), &SpinePathConstraintData::get_bones);
|
||||
ClassDB::bind_method(D_METHOD("get_bones"), &SpinePathConstraintData::get_bones);
|
||||
ClassDB::bind_method(D_METHOD("get_target"), &SpinePathConstraintData::get_target);
|
||||
ClassDB::bind_method(D_METHOD("set_target", "V"), &SpinePathConstraintData::set_target);
|
||||
ClassDB::bind_method(D_METHOD("get_position_mode"), &SpinePathConstraintData::get_position_mode);
|
||||
@ -52,117 +52,121 @@ void SpinePathConstraintData::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_mix_x", "V"), &SpinePathConstraintData::set_mix_x);
|
||||
ClassDB::bind_method(D_METHOD("get_mix_y"), &SpinePathConstraintData::get_mix_y);
|
||||
ClassDB::bind_method(D_METHOD("set_mix_y", "V"), &SpinePathConstraintData::set_mix_y);
|
||||
|
||||
BIND_ENUM_CONSTANT(POSITIONMODE_FIXED);
|
||||
BIND_ENUM_CONSTANT(POSITIONMODE_PERCENT);
|
||||
|
||||
BIND_ENUM_CONSTANT(SPACINGMODE_LENGTH);
|
||||
BIND_ENUM_CONSTANT(SPACINGMODE_FIXED);
|
||||
BIND_ENUM_CONSTANT(SPACINGMODE_PERCENT);
|
||||
|
||||
BIND_ENUM_CONSTANT(ROTATEMODE_TANGENT);
|
||||
BIND_ENUM_CONSTANT(ROTATEMODE_CHAIN);
|
||||
BIND_ENUM_CONSTANT(ROTATEMODE_CHAINSCALE);
|
||||
}
|
||||
|
||||
SpinePathConstraintData::SpinePathConstraintData() {}
|
||||
SpinePathConstraintData::~SpinePathConstraintData() {}
|
||||
|
||||
Array SpinePathConstraintData::get_bones() {
|
||||
auto bs = get_spine_constraint_data()->getBones();
|
||||
Array gd_bs;
|
||||
gd_bs.resize(bs.size());
|
||||
for (size_t i = 0; i < bs.size(); ++i) {
|
||||
if (bs[i] == NULL) gd_bs[i] = Ref<SpineBoneData>(NULL);
|
||||
else {
|
||||
Ref<SpineBoneData> gd_b(memnew(SpineBoneData));
|
||||
gd_b->set_spine_object(bs[i]);
|
||||
gd_bs[i] = gd_b;
|
||||
}
|
||||
Array result;
|
||||
SPINE_CHECK(get_spine_constraint_data(), result)
|
||||
auto bones = get_spine_constraint_data()->getBones();
|
||||
result.resize((int)bones.size());
|
||||
for (int i = 0; i < bones.size(); ++i) {
|
||||
Ref<SpineBoneData> bone_ref(memnew(SpineBoneData));
|
||||
bone_ref->set_spine_object(bones[i]);
|
||||
result[i] = bone_ref;
|
||||
}
|
||||
return gd_bs;
|
||||
return result;
|
||||
}
|
||||
|
||||
Ref<SpineSlotData> SpinePathConstraintData::get_target() {
|
||||
auto s = get_spine_constraint_data()->getTarget();
|
||||
if (s == NULL) return NULL;
|
||||
Ref<SpineSlotData> gd_s(memnew(SpineSlotData));
|
||||
gd_s->set_spine_object(s);
|
||||
return gd_s;
|
||||
SPINE_CHECK(get_spine_constraint_data(), nullptr)
|
||||
auto slot = get_spine_constraint_data()->getTarget();
|
||||
if (!slot) return nullptr;
|
||||
Ref<SpineSlotData> slot_ref(memnew(SpineSlotData));
|
||||
slot_ref->set_spine_object(slot);
|
||||
return slot_ref;
|
||||
}
|
||||
|
||||
void SpinePathConstraintData::set_target(Ref<SpineSlotData> v) {
|
||||
if (v.is_valid()) {
|
||||
get_spine_constraint_data()->setTarget(v->get_spine_object());
|
||||
} else {
|
||||
get_spine_constraint_data()->setTarget(NULL);
|
||||
}
|
||||
SPINE_CHECK(get_spine_constraint_data(),)
|
||||
get_spine_constraint_data()->setTarget(v.is_valid() ? v->get_spine_object() : nullptr);
|
||||
}
|
||||
|
||||
SpinePathConstraintData::PositionMode SpinePathConstraintData::get_position_mode() {
|
||||
auto m = (int) get_spine_constraint_data()->getPositionMode();
|
||||
return (PositionMode) m;
|
||||
}
|
||||
void SpinePathConstraintData::set_position_mode(PositionMode v) {
|
||||
auto m = (int) v;
|
||||
get_spine_constraint_data()->setPositionMode((spine::PositionMode) m);
|
||||
SpineConstant::PositionMode SpinePathConstraintData::get_position_mode() {
|
||||
SPINE_CHECK(get_spine_constraint_data(), SpineConstant::PositionMode_Fixed)
|
||||
return (SpineConstant::PositionMode) get_spine_constraint_data()->getPositionMode();
|
||||
}
|
||||
|
||||
SpinePathConstraintData::SpacingMode SpinePathConstraintData::get_spacing_mode() {
|
||||
auto m = (int) get_spine_constraint_data()->getSpacingMode();
|
||||
return (SpacingMode) m;
|
||||
}
|
||||
void SpinePathConstraintData::set_spacing_mode(SpacingMode v) {
|
||||
auto m = (int) v;
|
||||
get_spine_constraint_data()->setSpacingMode((spine::SpacingMode) m);
|
||||
void SpinePathConstraintData::set_position_mode(SpineConstant::PositionMode v) {
|
||||
SPINE_CHECK(get_spine_constraint_data(),)
|
||||
get_spine_constraint_data()->setPositionMode((spine::PositionMode)v);
|
||||
}
|
||||
|
||||
SpinePathConstraintData::RotateMode SpinePathConstraintData::get_rotate_mode() {
|
||||
auto m = (int) get_spine_constraint_data()->getRotateMode();
|
||||
return (RotateMode) m;
|
||||
SpineConstant::SpacingMode SpinePathConstraintData::get_spacing_mode() {
|
||||
SPINE_CHECK(get_spine_constraint_data(),SpineConstant::SpacingMode_Fixed)
|
||||
return (SpineConstant::SpacingMode) get_spine_constraint_data()->getSpacingMode();
|
||||
}
|
||||
void SpinePathConstraintData::set_rotate_mode(RotateMode v) {
|
||||
auto m = (int) v;
|
||||
get_spine_constraint_data()->setRotateMode((spine::RotateMode) m);
|
||||
|
||||
void SpinePathConstraintData::set_spacing_mode(SpineConstant::SpacingMode v) {
|
||||
SPINE_CHECK(get_spine_constraint_data(),)
|
||||
get_spine_constraint_data()->setSpacingMode((spine::SpacingMode) v);
|
||||
}
|
||||
|
||||
SpineConstant::RotateMode SpinePathConstraintData::get_rotate_mode() {
|
||||
SPINE_CHECK(get_spine_constraint_data(),SpineConstant::RotateMode_Tangent)
|
||||
return (SpineConstant::RotateMode)get_spine_constraint_data()->getRotateMode();
|
||||
}
|
||||
|
||||
void SpinePathConstraintData::set_rotate_mode(SpineConstant::RotateMode v) {
|
||||
SPINE_CHECK(get_spine_constraint_data(),)
|
||||
get_spine_constraint_data()->setRotateMode((spine::RotateMode) v);
|
||||
}
|
||||
|
||||
float SpinePathConstraintData::get_offset_rotation() {
|
||||
SPINE_CHECK(get_spine_constraint_data(), 0)
|
||||
return get_spine_constraint_data()->getOffsetRotation();
|
||||
}
|
||||
|
||||
void SpinePathConstraintData::set_offset_rotation(float v) {
|
||||
SPINE_CHECK(get_spine_constraint_data(),)
|
||||
get_spine_constraint_data()->setOffsetRotation(v);
|
||||
}
|
||||
|
||||
float SpinePathConstraintData::get_position() {
|
||||
SPINE_CHECK(get_spine_constraint_data(), 0)
|
||||
return get_spine_constraint_data()->getPosition();
|
||||
}
|
||||
|
||||
void SpinePathConstraintData::set_position(float v) {
|
||||
SPINE_CHECK(get_spine_constraint_data(),)
|
||||
get_spine_constraint_data()->setPosition(v);
|
||||
}
|
||||
|
||||
float SpinePathConstraintData::get_spacing() {
|
||||
SPINE_CHECK(get_spine_constraint_data(), 0)
|
||||
return get_spine_constraint_data()->getSpacing();
|
||||
}
|
||||
|
||||
void SpinePathConstraintData::set_spacing(float v) {
|
||||
SPINE_CHECK(get_spine_constraint_data(),)
|
||||
get_spine_constraint_data()->setSpacing(v);
|
||||
}
|
||||
|
||||
float SpinePathConstraintData::get_mix_rotate() {
|
||||
SPINE_CHECK(get_spine_constraint_data(), 0)
|
||||
return get_spine_constraint_data()->getMixRotate();
|
||||
}
|
||||
|
||||
void SpinePathConstraintData::set_mix_rotate(float v) {
|
||||
SPINE_CHECK(get_spine_constraint_data(),)
|
||||
get_spine_constraint_data()->setMixRotate(v);
|
||||
}
|
||||
|
||||
float SpinePathConstraintData::get_mix_x() {
|
||||
SPINE_CHECK(get_spine_constraint_data(), 0)
|
||||
return get_spine_constraint_data()->getMixX();
|
||||
}
|
||||
|
||||
void SpinePathConstraintData::set_mix_x(float v) {
|
||||
SPINE_CHECK(get_spine_constraint_data(),)
|
||||
get_spine_constraint_data()->setMixX(v);
|
||||
}
|
||||
|
||||
float SpinePathConstraintData::get_mix_y() {
|
||||
SPINE_CHECK(get_spine_constraint_data(), 0)
|
||||
return get_spine_constraint_data()->getMixY();
|
||||
}
|
||||
|
||||
void SpinePathConstraintData::set_mix_y(float v) {
|
||||
SPINE_CHECK(get_spine_constraint_data(),)
|
||||
get_spine_constraint_data()->setMixY(v);
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
#define GODOT_SPINEPATHCONSTRAINTDATA_H
|
||||
|
||||
#include "SpineConstraintData.h"
|
||||
#include "SpineConstant.h"
|
||||
#include "SpineBoneData.h"
|
||||
#include "SpineSlotData.h"
|
||||
#include <spine/PathConstraintData.h>
|
||||
@ -39,65 +40,54 @@ class SpinePathConstraintData : public SpineConstraintData {
|
||||
GDCLASS(SpinePathConstraintData, SpineConstraintData);
|
||||
|
||||
spine::PathConstraintData *get_spine_constraint_data() { return (spine::PathConstraintData *)get_spine_object(); }
|
||||
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
SpinePathConstraintData();
|
||||
~SpinePathConstraintData();
|
||||
|
||||
enum PositionMode {
|
||||
POSITIONMODE_FIXED = 0,
|
||||
POSITIONMODE_PERCENT
|
||||
};
|
||||
|
||||
enum SpacingMode {
|
||||
SPACINGMODE_LENGTH = 0,
|
||||
SPACINGMODE_FIXED,
|
||||
SPACINGMODE_PERCENT
|
||||
};
|
||||
|
||||
enum RotateMode {
|
||||
ROTATEMODE_TANGENT = 0,
|
||||
ROTATEMODE_CHAIN,
|
||||
ROTATEMODE_CHAINSCALE
|
||||
};
|
||||
SpinePathConstraintData() = default;
|
||||
~SpinePathConstraintData() = default;
|
||||
|
||||
Array get_bones();
|
||||
|
||||
Ref<SpineSlotData> get_target();
|
||||
|
||||
void set_target(Ref<SpineSlotData> v);
|
||||
|
||||
PositionMode get_position_mode();
|
||||
void set_position_mode(PositionMode v);
|
||||
SpineConstant::PositionMode get_position_mode();
|
||||
|
||||
SpacingMode get_spacing_mode();
|
||||
void set_spacing_mode(SpacingMode v);
|
||||
void set_position_mode(SpineConstant::PositionMode v);
|
||||
|
||||
RotateMode get_rotate_mode();
|
||||
void set_rotate_mode(RotateMode v);
|
||||
SpineConstant::SpacingMode get_spacing_mode();
|
||||
|
||||
void set_spacing_mode(SpineConstant::SpacingMode v);
|
||||
|
||||
SpineConstant::RotateMode get_rotate_mode();
|
||||
|
||||
void set_rotate_mode(SpineConstant::RotateMode v);
|
||||
|
||||
float get_offset_rotation();
|
||||
|
||||
void set_offset_rotation(float v);
|
||||
|
||||
float get_position();
|
||||
|
||||
void set_position(float v);
|
||||
|
||||
float get_spacing();
|
||||
|
||||
void set_spacing(float v);
|
||||
|
||||
float get_mix_rotate();
|
||||
|
||||
void set_mix_rotate(float v);
|
||||
|
||||
float get_mix_x();
|
||||
|
||||
void set_mix_x(float v);
|
||||
|
||||
float get_mix_y();
|
||||
|
||||
void set_mix_y(float v);
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(SpinePathConstraintData::PositionMode);
|
||||
VARIANT_ENUM_CAST(SpinePathConstraintData::SpacingMode);
|
||||
VARIANT_ENUM_CAST(SpinePathConstraintData::RotateMode);
|
||||
#endif//GODOT_SPINEPATHCONSTRAINTDATA_H
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user