diff --git a/spine-cpp/spine-cpp/include/spine/PathConstraint.h b/spine-cpp/spine-cpp/include/spine/PathConstraint.h index f35151419..c9795598a 100644 --- a/spine-cpp/spine-cpp/include/spine/PathConstraint.h +++ b/spine-cpp/spine-cpp/include/spine/PathConstraint.h @@ -59,13 +59,18 @@ namespace spine { public: PathConstraint(PathConstraintData &data, Skeleton &skeleton); - /// Applies the constraint to the constrained bones. - void apply(); - virtual void update(); virtual int getOrder(); + PathConstraintData &getData(); + + Vector &getBones(); + + Slot *getTarget(); + + void setTarget(Slot *inValue); + float getPosition(); void setPosition(float inValue); @@ -86,14 +91,6 @@ namespace spine { void setMixY(float inValue); - Vector &getBones(); - - Slot *getTarget(); - - void setTarget(Slot *inValue); - - PathConstraintData &getData(); - bool isActive(); void setActive(bool inValue); diff --git a/spine-flutter/lib/spine_flutter.dart b/spine-flutter/lib/spine_flutter.dart index c9a20eb5c..53ddd023e 100644 --- a/spine-flutter/lib/spine_flutter.dart +++ b/spine-flutter/lib/spine_flutter.dart @@ -426,6 +426,33 @@ enum TransformMode { const TransformMode(this.value); } +enum PositionMode { + Fixed(0), + Percent(1); + + final int value; + const PositionMode(this.value); +} + +enum SpacingMode { + Length(0), + Fixed(1), + Percent(2), + Proportional(3); + + final int value; + const SpacingMode(this.value); +} + +enum RotateMode { + Tangent(0), + Chain(1), + ChainScale(2); + + final int value; + const RotateMode(this.value); +} + class BoneData { final spine_bone_data _data; @@ -1221,6 +1248,10 @@ class TransformConstraintData extends ConstraintData { return BoneData._(_bindings.spine_ik_constraint_data_get_target(_data)); } + void setTarget(BoneData target) { + _bindings.spine_transform_constraint_data_set_target(_data, target._data); + } + double getMixRotate() { return _bindings.spine_transform_constraint_data_get_mix_rotate(_data); } @@ -1426,16 +1457,178 @@ class TransformConstraint { } } -// FIXME class PathConstraintData extends ConstraintData { PathConstraintData._(spine_path_constraint_data data): super._(data); + + List getBones() { + final List result = []; + final numBones = _bindings.spine_path_constraint_data_get_num_bones(_data); + final nativeBones = _bindings.spine_path_constraint_data_get_bones(_data); + for (int i = 0; i < numBones; i++) { + result.add(BoneData._(nativeBones[i])); + } + return result; + } + + SlotData getTarget() { + return SlotData._(_bindings.spine_path_constraint_data_get_target(_data)); + } + + void setTarget(SlotData target) { + _bindings.spine_path_constraint_data_set_target(_data, target._data); + } + + PositionMode getPositionMode() { + return PositionMode.values[_bindings.spine_path_constraint_data_get_position_mode(_data)]; + } + + void setPositionMode(PositionMode positionMode) { + _bindings.spine_path_constraint_data_set_position_mode(_data, positionMode.value); + } + + SpacingMode getSpacingMode() { + return SpacingMode.values[_bindings.spine_path_constraint_data_get_spacing_mode(_data)]; + } + + void setSpacingMode(SpacingMode spacingMode) { + _bindings.spine_path_constraint_data_set_spacing_mode(_data, spacingMode.value); + } + + RotateMode getRotateMode() { + return RotateMode.values[_bindings.spine_path_constraint_data_get_rotate_mode(_data)]; + } + + void setRotateMode(RotateMode rotateMode) { + _bindings.spine_path_constraint_data_set_rotate_mode(_data, rotateMode.value); + } + + double getOffsetRotation() { + return _bindings.spine_path_constraint_data_get_offset_rotation(_data); + } + + void setOffsetRotation(double offsetRotation) { + _bindings.spine_path_constraint_data_set_offset_rotation(_data, offsetRotation); + } + + double getPosition() { + return _bindings.spine_path_constraint_data_get_position(_data); + } + + void setPosition(double position) { + _bindings.spine_path_constraint_data_set_position(_data, position); + } + + double getSpacing() { + return _bindings.spine_path_constraint_data_get_spacing(_data); + } + + void setSpacing(double spacing) { + _bindings.spine_path_constraint_data_set_spacing(_data, spacing); + } + + double getMixRotate() { + return _bindings.spine_path_constraint_data_get_mix_rotate(_data); + } + + void setMixRotate(double mixRotate) { + _bindings.spine_path_constraint_data_set_mix_rotate(_data, mixRotate); + } + + double getMixX() { + return _bindings.spine_path_constraint_data_get_mix_x(_data); + } + + void setMixX(double mixX) { + _bindings.spine_path_constraint_data_set_mix_x(_data, mixX); + } + + double getMixY() { + return _bindings.spine_path_constraint_data_get_mix_x(_data); + } + + void setMixY(double mixY) { + _bindings.spine_path_constraint_data_set_mix_y(_data, mixY); + } } -// FIXME class PathConstraint { final spine_path_constraint _constraint; PathConstraint._(this._constraint); + + void update() { + _bindings.spine_path_constraint_update(_constraint); + } + + int getOrder() { + return _bindings.spine_path_constraint_get_order(_constraint); + } + + List getBones() { + List result = []; + final num = _bindings.spine_path_constraint_get_num_bones(_constraint); + final nativeBones = _bindings.spine_path_constraint_get_bones(_constraint); + for (int i = 0; i < num; i++) { + result.add(Bone._(nativeBones[i])); + } + return result; + } + + Slot getTarget() { + return Slot._(_bindings.spine_path_constraint_get_target(_constraint)); + } + + void setTarget(Slot target) { + _bindings.spine_path_constraint_set_target(_constraint, target._slot); + } + + double getPosition() { + return _bindings.spine_path_constraint_get_position(_constraint); + } + + void setPosition(double position) { + _bindings.spine_path_constraint_set_position(_constraint, position); + } + + double getSpacing() { + return _bindings.spine_path_constraint_get_spacing(_constraint); + } + + void setSpacing(double spacing) { + _bindings.spine_path_constraint_set_spacing(_constraint, spacing); + } + + double getMixRotate() { + return _bindings.spine_path_constraint_get_mix_rotate(_constraint); + } + + void setMixRotate(double mixRotate) { + _bindings.spine_path_constraint_set_mix_rotate(_constraint, mixRotate); + } + + double getMixX() { + return _bindings.spine_path_constraint_get_mix_x(_constraint); + } + + void setMixX(double mixX) { + _bindings.spine_path_constraint_set_mix_x(_constraint, mixX); + } + + double getMixY() { + return _bindings.spine_path_constraint_get_mix_y(_constraint); + } + + void setMixY(double mixY) { + _bindings.spine_path_constraint_set_mix_y(_constraint, mixY); + } + + bool isActive() { + return _bindings.spine_path_constraint_get_is_active(_constraint) == -1; + } + + void setIsActive(bool isActive) { + _bindings.spine_path_constraint_set_is_active(_constraint, isActive ? -1 : 0); + } } class Skeleton { diff --git a/spine-flutter/lib/spine_flutter_bindings_generated.dart b/spine-flutter/lib/spine_flutter_bindings_generated.dart index ceb815f31..bdad4be11 100644 --- a/spine-flutter/lib/spine_flutter_bindings_generated.dart +++ b/spine-flutter/lib/spine_flutter_bindings_generated.dart @@ -5419,6 +5419,24 @@ class SpineFlutterBindings { _spine_transform_constraint_data_get_targetPtr.asFunction< spine_bone_data Function(spine_transform_constraint_data)>(); + void spine_transform_constraint_data_set_target( + spine_transform_constraint_data data, + spine_bone_data target, + ) { + return _spine_transform_constraint_data_set_target( + data, + target, + ); + } + + late final _spine_transform_constraint_data_set_targetPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(spine_transform_constraint_data, + spine_bone_data)>>('spine_transform_constraint_data_set_target'); + late final _spine_transform_constraint_data_set_target = + _spine_transform_constraint_data_set_targetPtr.asFunction< + void Function(spine_transform_constraint_data, spine_bone_data)>(); + double spine_transform_constraint_data_get_mix_rotate( spine_transform_constraint_data data, ) { @@ -6237,6 +6255,676 @@ class SpineFlutterBindings { late final _spine_transform_constraint_set_is_active = _spine_transform_constraint_set_is_activePtr .asFunction(); + + int spine_path_constraint_data_get_num_bones( + spine_path_constraint_data data, + ) { + return _spine_path_constraint_data_get_num_bones( + data, + ); + } + + late final _spine_path_constraint_data_get_num_bonesPtr = _lookup< + ffi.NativeFunction>( + 'spine_path_constraint_data_get_num_bones'); + late final _spine_path_constraint_data_get_num_bones = + _spine_path_constraint_data_get_num_bonesPtr + .asFunction(); + + ffi.Pointer spine_path_constraint_data_get_bones( + spine_path_constraint_data data, + ) { + return _spine_path_constraint_data_get_bones( + data, + ); + } + + late final _spine_path_constraint_data_get_bonesPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + spine_path_constraint_data)>>( + 'spine_path_constraint_data_get_bones'); + late final _spine_path_constraint_data_get_bones = + _spine_path_constraint_data_get_bonesPtr.asFunction< + ffi.Pointer Function(spine_path_constraint_data)>(); + + spine_slot_data spine_path_constraint_data_get_target( + spine_path_constraint_data data, + ) { + return _spine_path_constraint_data_get_target( + data, + ); + } + + late final _spine_path_constraint_data_get_targetPtr = _lookup< + ffi.NativeFunction< + spine_slot_data Function(spine_path_constraint_data)>>( + 'spine_path_constraint_data_get_target'); + late final _spine_path_constraint_data_get_target = + _spine_path_constraint_data_get_targetPtr + .asFunction(); + + void spine_path_constraint_data_set_target( + spine_path_constraint_data data, + spine_slot_data target, + ) { + return _spine_path_constraint_data_set_target( + data, + target, + ); + } + + late final _spine_path_constraint_data_set_targetPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(spine_path_constraint_data, + spine_slot_data)>>('spine_path_constraint_data_set_target'); + late final _spine_path_constraint_data_set_target = + _spine_path_constraint_data_set_targetPtr.asFunction< + void Function(spine_path_constraint_data, spine_slot_data)>(); + + int spine_path_constraint_data_get_position_mode( + spine_path_constraint_data data, + ) { + return _spine_path_constraint_data_get_position_mode( + data, + ); + } + + late final _spine_path_constraint_data_get_position_modePtr = _lookup< + ffi.NativeFunction>( + 'spine_path_constraint_data_get_position_mode'); + late final _spine_path_constraint_data_get_position_mode = + _spine_path_constraint_data_get_position_modePtr + .asFunction(); + + void spine_path_constraint_data_set_position_mode( + spine_path_constraint_data data, + int positionMode, + ) { + return _spine_path_constraint_data_set_position_mode( + data, + positionMode, + ); + } + + late final _spine_path_constraint_data_set_position_modePtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(spine_path_constraint_data, + ffi.Int32)>>('spine_path_constraint_data_set_position_mode'); + late final _spine_path_constraint_data_set_position_mode = + _spine_path_constraint_data_set_position_modePtr + .asFunction(); + + int spine_path_constraint_data_get_spacing_mode( + spine_path_constraint_data data, + ) { + return _spine_path_constraint_data_get_spacing_mode( + data, + ); + } + + late final _spine_path_constraint_data_get_spacing_modePtr = _lookup< + ffi.NativeFunction>( + 'spine_path_constraint_data_get_spacing_mode'); + late final _spine_path_constraint_data_get_spacing_mode = + _spine_path_constraint_data_get_spacing_modePtr + .asFunction(); + + void spine_path_constraint_data_set_spacing_mode( + spine_path_constraint_data data, + int spacingMode, + ) { + return _spine_path_constraint_data_set_spacing_mode( + data, + spacingMode, + ); + } + + late final _spine_path_constraint_data_set_spacing_modePtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(spine_path_constraint_data, + ffi.Int32)>>('spine_path_constraint_data_set_spacing_mode'); + late final _spine_path_constraint_data_set_spacing_mode = + _spine_path_constraint_data_set_spacing_modePtr + .asFunction(); + + int spine_path_constraint_data_get_rotate_mode( + spine_path_constraint_data data, + ) { + return _spine_path_constraint_data_get_rotate_mode( + data, + ); + } + + late final _spine_path_constraint_data_get_rotate_modePtr = _lookup< + ffi.NativeFunction>( + 'spine_path_constraint_data_get_rotate_mode'); + late final _spine_path_constraint_data_get_rotate_mode = + _spine_path_constraint_data_get_rotate_modePtr + .asFunction(); + + void spine_path_constraint_data_set_rotate_mode( + spine_path_constraint_data data, + int rotateMode, + ) { + return _spine_path_constraint_data_set_rotate_mode( + data, + rotateMode, + ); + } + + late final _spine_path_constraint_data_set_rotate_modePtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(spine_path_constraint_data, + ffi.Int32)>>('spine_path_constraint_data_set_rotate_mode'); + late final _spine_path_constraint_data_set_rotate_mode = + _spine_path_constraint_data_set_rotate_modePtr + .asFunction(); + + double spine_path_constraint_data_get_offset_rotation( + spine_path_constraint_data data, + ) { + return _spine_path_constraint_data_get_offset_rotation( + data, + ); + } + + late final _spine_path_constraint_data_get_offset_rotationPtr = _lookup< + ffi.NativeFunction>( + 'spine_path_constraint_data_get_offset_rotation'); + late final _spine_path_constraint_data_get_offset_rotation = + _spine_path_constraint_data_get_offset_rotationPtr + .asFunction(); + + void spine_path_constraint_data_set_offset_rotation( + spine_path_constraint_data data, + double offsetRotation, + ) { + return _spine_path_constraint_data_set_offset_rotation( + data, + offsetRotation, + ); + } + + late final _spine_path_constraint_data_set_offset_rotationPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(spine_path_constraint_data, + ffi.Float)>>('spine_path_constraint_data_set_offset_rotation'); + late final _spine_path_constraint_data_set_offset_rotation = + _spine_path_constraint_data_set_offset_rotationPtr + .asFunction(); + + double spine_path_constraint_data_get_position( + spine_path_constraint_data data, + ) { + return _spine_path_constraint_data_get_position( + data, + ); + } + + late final _spine_path_constraint_data_get_positionPtr = _lookup< + ffi.NativeFunction>( + 'spine_path_constraint_data_get_position'); + late final _spine_path_constraint_data_get_position = + _spine_path_constraint_data_get_positionPtr + .asFunction(); + + void spine_path_constraint_data_set_position( + spine_path_constraint_data data, + double position, + ) { + return _spine_path_constraint_data_set_position( + data, + position, + ); + } + + late final _spine_path_constraint_data_set_positionPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(spine_path_constraint_data, + ffi.Float)>>('spine_path_constraint_data_set_position'); + late final _spine_path_constraint_data_set_position = + _spine_path_constraint_data_set_positionPtr + .asFunction(); + + double spine_path_constraint_data_get_spacing( + spine_path_constraint_data data, + ) { + return _spine_path_constraint_data_get_spacing( + data, + ); + } + + late final _spine_path_constraint_data_get_spacingPtr = _lookup< + ffi.NativeFunction>( + 'spine_path_constraint_data_get_spacing'); + late final _spine_path_constraint_data_get_spacing = + _spine_path_constraint_data_get_spacingPtr + .asFunction(); + + void spine_path_constraint_data_set_spacing( + spine_path_constraint_data data, + double spacing, + ) { + return _spine_path_constraint_data_set_spacing( + data, + spacing, + ); + } + + late final _spine_path_constraint_data_set_spacingPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(spine_path_constraint_data, + ffi.Float)>>('spine_path_constraint_data_set_spacing'); + late final _spine_path_constraint_data_set_spacing = + _spine_path_constraint_data_set_spacingPtr + .asFunction(); + + double spine_path_constraint_data_get_mix_rotate( + spine_path_constraint_data data, + ) { + return _spine_path_constraint_data_get_mix_rotate( + data, + ); + } + + late final _spine_path_constraint_data_get_mix_rotatePtr = _lookup< + ffi.NativeFunction>( + 'spine_path_constraint_data_get_mix_rotate'); + late final _spine_path_constraint_data_get_mix_rotate = + _spine_path_constraint_data_get_mix_rotatePtr + .asFunction(); + + void spine_path_constraint_data_set_mix_rotate( + spine_path_constraint_data data, + double mixRotate, + ) { + return _spine_path_constraint_data_set_mix_rotate( + data, + mixRotate, + ); + } + + late final _spine_path_constraint_data_set_mix_rotatePtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(spine_path_constraint_data, + ffi.Float)>>('spine_path_constraint_data_set_mix_rotate'); + late final _spine_path_constraint_data_set_mix_rotate = + _spine_path_constraint_data_set_mix_rotatePtr + .asFunction(); + + double spine_path_constraint_data_get_mix_x( + spine_path_constraint_data data, + ) { + return _spine_path_constraint_data_get_mix_x( + data, + ); + } + + late final _spine_path_constraint_data_get_mix_xPtr = _lookup< + ffi.NativeFunction>( + 'spine_path_constraint_data_get_mix_x'); + late final _spine_path_constraint_data_get_mix_x = + _spine_path_constraint_data_get_mix_xPtr + .asFunction(); + + void spine_path_constraint_data_set_mix_x( + spine_path_constraint_data data, + double mixX, + ) { + return _spine_path_constraint_data_set_mix_x( + data, + mixX, + ); + } + + late final _spine_path_constraint_data_set_mix_xPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(spine_path_constraint_data, + ffi.Float)>>('spine_path_constraint_data_set_mix_x'); + late final _spine_path_constraint_data_set_mix_x = + _spine_path_constraint_data_set_mix_xPtr + .asFunction(); + + double spine_path_constraint_data_get_mix_y( + spine_path_constraint_data data, + ) { + return _spine_path_constraint_data_get_mix_y( + data, + ); + } + + late final _spine_path_constraint_data_get_mix_yPtr = _lookup< + ffi.NativeFunction>( + 'spine_path_constraint_data_get_mix_y'); + late final _spine_path_constraint_data_get_mix_y = + _spine_path_constraint_data_get_mix_yPtr + .asFunction(); + + void spine_path_constraint_data_set_mix_y( + spine_path_constraint_data data, + double mixY, + ) { + return _spine_path_constraint_data_set_mix_y( + data, + mixY, + ); + } + + late final _spine_path_constraint_data_set_mix_yPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(spine_path_constraint_data, + ffi.Float)>>('spine_path_constraint_data_set_mix_y'); + late final _spine_path_constraint_data_set_mix_y = + _spine_path_constraint_data_set_mix_yPtr + .asFunction(); + + void spine_path_constraint_update( + spine_path_constraint constraint, + ) { + return _spine_path_constraint_update( + constraint, + ); + } + + late final _spine_path_constraint_updatePtr = + _lookup>( + 'spine_path_constraint_update'); + late final _spine_path_constraint_update = _spine_path_constraint_updatePtr + .asFunction(); + + int spine_path_constraint_get_order( + spine_path_constraint constraint, + ) { + return _spine_path_constraint_get_order( + constraint, + ); + } + + late final _spine_path_constraint_get_orderPtr = + _lookup>( + 'spine_path_constraint_get_order'); + late final _spine_path_constraint_get_order = + _spine_path_constraint_get_orderPtr + .asFunction(); + + spine_path_constraint_data spine_path_constraint_get_data( + spine_path_constraint constraint, + ) { + return _spine_path_constraint_get_data( + constraint, + ); + } + + late final _spine_path_constraint_get_dataPtr = _lookup< + ffi.NativeFunction< + spine_path_constraint_data Function( + spine_path_constraint)>>('spine_path_constraint_get_data'); + late final _spine_path_constraint_get_data = + _spine_path_constraint_get_dataPtr.asFunction< + spine_path_constraint_data Function(spine_path_constraint)>(); + + int spine_path_constraint_get_num_bones( + spine_path_constraint constraint, + ) { + return _spine_path_constraint_get_num_bones( + constraint, + ); + } + + late final _spine_path_constraint_get_num_bonesPtr = + _lookup>( + 'spine_path_constraint_get_num_bones'); + late final _spine_path_constraint_get_num_bones = + _spine_path_constraint_get_num_bonesPtr + .asFunction(); + + ffi.Pointer spine_path_constraint_get_bones( + spine_path_constraint constraint, + ) { + return _spine_path_constraint_get_bones( + constraint, + ); + } + + late final _spine_path_constraint_get_bonesPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + spine_path_constraint)>>('spine_path_constraint_get_bones'); + late final _spine_path_constraint_get_bones = + _spine_path_constraint_get_bonesPtr.asFunction< + ffi.Pointer Function(spine_path_constraint)>(); + + spine_slot spine_path_constraint_get_target( + spine_path_constraint constraint, + ) { + return _spine_path_constraint_get_target( + constraint, + ); + } + + late final _spine_path_constraint_get_targetPtr = + _lookup>( + 'spine_path_constraint_get_target'); + late final _spine_path_constraint_get_target = + _spine_path_constraint_get_targetPtr + .asFunction(); + + void spine_path_constraint_set_target( + spine_path_constraint constraint, + spine_slot target, + ) { + return _spine_path_constraint_set_target( + constraint, + target, + ); + } + + late final _spine_path_constraint_set_targetPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(spine_path_constraint, + spine_slot)>>('spine_path_constraint_set_target'); + late final _spine_path_constraint_set_target = + _spine_path_constraint_set_targetPtr + .asFunction(); + + double spine_path_constraint_get_position( + spine_path_constraint constraint, + ) { + return _spine_path_constraint_get_position( + constraint, + ); + } + + late final _spine_path_constraint_get_positionPtr = + _lookup>( + 'spine_path_constraint_get_position'); + late final _spine_path_constraint_get_position = + _spine_path_constraint_get_positionPtr + .asFunction(); + + void spine_path_constraint_set_position( + spine_path_constraint constraint, + double position, + ) { + return _spine_path_constraint_set_position( + constraint, + position, + ); + } + + late final _spine_path_constraint_set_positionPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(spine_path_constraint, + ffi.Float)>>('spine_path_constraint_set_position'); + late final _spine_path_constraint_set_position = + _spine_path_constraint_set_positionPtr + .asFunction(); + + double spine_path_constraint_get_spacing( + spine_path_constraint constraint, + ) { + return _spine_path_constraint_get_spacing( + constraint, + ); + } + + late final _spine_path_constraint_get_spacingPtr = + _lookup>( + 'spine_path_constraint_get_spacing'); + late final _spine_path_constraint_get_spacing = + _spine_path_constraint_get_spacingPtr + .asFunction(); + + void spine_path_constraint_set_spacing( + spine_path_constraint constraint, + double spacing, + ) { + return _spine_path_constraint_set_spacing( + constraint, + spacing, + ); + } + + late final _spine_path_constraint_set_spacingPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(spine_path_constraint, + ffi.Float)>>('spine_path_constraint_set_spacing'); + late final _spine_path_constraint_set_spacing = + _spine_path_constraint_set_spacingPtr + .asFunction(); + + double spine_path_constraint_get_mix_rotate( + spine_path_constraint constraint, + ) { + return _spine_path_constraint_get_mix_rotate( + constraint, + ); + } + + late final _spine_path_constraint_get_mix_rotatePtr = + _lookup>( + 'spine_path_constraint_get_mix_rotate'); + late final _spine_path_constraint_get_mix_rotate = + _spine_path_constraint_get_mix_rotatePtr + .asFunction(); + + void spine_path_constraint_set_mix_rotate( + spine_path_constraint constraint, + double mixRotate, + ) { + return _spine_path_constraint_set_mix_rotate( + constraint, + mixRotate, + ); + } + + late final _spine_path_constraint_set_mix_rotatePtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(spine_path_constraint, + ffi.Float)>>('spine_path_constraint_set_mix_rotate'); + late final _spine_path_constraint_set_mix_rotate = + _spine_path_constraint_set_mix_rotatePtr + .asFunction(); + + double spine_path_constraint_get_mix_x( + spine_path_constraint constraint, + ) { + return _spine_path_constraint_get_mix_x( + constraint, + ); + } + + late final _spine_path_constraint_get_mix_xPtr = + _lookup>( + 'spine_path_constraint_get_mix_x'); + late final _spine_path_constraint_get_mix_x = + _spine_path_constraint_get_mix_xPtr + .asFunction(); + + void spine_path_constraint_set_mix_x( + spine_path_constraint constraint, + double mixX, + ) { + return _spine_path_constraint_set_mix_x( + constraint, + mixX, + ); + } + + late final _spine_path_constraint_set_mix_xPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(spine_path_constraint, + ffi.Float)>>('spine_path_constraint_set_mix_x'); + late final _spine_path_constraint_set_mix_x = + _spine_path_constraint_set_mix_xPtr + .asFunction(); + + double spine_path_constraint_get_mix_y( + spine_path_constraint constraint, + ) { + return _spine_path_constraint_get_mix_y( + constraint, + ); + } + + late final _spine_path_constraint_get_mix_yPtr = + _lookup>( + 'spine_path_constraint_get_mix_y'); + late final _spine_path_constraint_get_mix_y = + _spine_path_constraint_get_mix_yPtr + .asFunction(); + + void spine_path_constraint_set_mix_y( + spine_path_constraint constraint, + double mixY, + ) { + return _spine_path_constraint_set_mix_y( + constraint, + mixY, + ); + } + + late final _spine_path_constraint_set_mix_yPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(spine_path_constraint, + ffi.Float)>>('spine_path_constraint_set_mix_y'); + late final _spine_path_constraint_set_mix_y = + _spine_path_constraint_set_mix_yPtr + .asFunction(); + + int spine_path_constraint_get_is_active( + spine_path_constraint constraint, + ) { + return _spine_path_constraint_get_is_active( + constraint, + ); + } + + late final _spine_path_constraint_get_is_activePtr = + _lookup>( + 'spine_path_constraint_get_is_active'); + late final _spine_path_constraint_get_is_active = + _spine_path_constraint_get_is_activePtr + .asFunction(); + + void spine_path_constraint_set_is_active( + spine_path_constraint constraint, + int isActive, + ) { + return _spine_path_constraint_set_is_active( + constraint, + isActive, + ); + } + + late final _spine_path_constraint_set_is_activePtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(spine_path_constraint, + ffi.Int32)>>('spine_path_constraint_set_is_active'); + late final _spine_path_constraint_set_is_active = + _spine_path_constraint_set_is_activePtr + .asFunction(); } class spine_atlas extends ffi.Struct { @@ -6304,6 +6992,24 @@ abstract class spine_transform_mode { static const int SPINE_TRANSFORM_NO_SCALE_OR_REFLECTION = 4; } +abstract class spine_position_mode { + static const int SPINE_POSITION_MODE_FIXED = 0; + static const int SPINE_POSITION_MODE_PERCENT = 1; +} + +abstract class spine_spacing_mode { + static const int SPINE_SPACING_MODE_LENGTH = 0; + static const int SPINE_SPACING_MODE_FIXED = 1; + static const int SPINE_SPACING_MODE_PERCENT = 2; + static const int SPINE_SPACING_MODE_PROPORTIONAL = 3; +} + +abstract class spine_rotate_mode { + static const int SPINE_ROTATE_MODE_TANGENT = 0; + static const int SPINE_ROTATE_MODE_CHAIN = 1; + static const int SPINE_ROTATE_MODE_CHAIN_SCALE = 2; +} + class spine_render_command extends ffi.Struct { external ffi.Pointer positions; diff --git a/spine-flutter/src/spine_flutter.cpp b/spine-flutter/src/spine_flutter.cpp index ac5709769..407d832f3 100644 --- a/spine-flutter/src/spine_flutter.cpp +++ b/spine-flutter/src/spine_flutter.cpp @@ -2319,6 +2319,12 @@ FFI_PLUGIN_EXPORT spine_bone_data spine_transform_constraint_data_get_target(spi return _data->getTarget(); } +FFI_PLUGIN_EXPORT void spine_transform_constraint_data_set_target(spine_transform_constraint_data data, spine_bone_data target) { + if (data == nullptr) return; + TransformConstraintData *_data = (TransformConstraintData*)data; + _data->setTarget((BoneData*)target); +} + FFI_PLUGIN_EXPORT float spine_transform_constraint_data_get_mix_rotate(spine_transform_constraint_data data) { if (data == nullptr) return 0; TransformConstraintData *_data = (TransformConstraintData*)data; @@ -2613,3 +2619,252 @@ FFI_PLUGIN_EXPORT void spine_transform_constraint_set_is_active(spine_transform_ TransformConstraint *_constraint = (TransformConstraint*)constraint; _constraint->setActive(isActive); } + +// PathConstraintData +FFI_PLUGIN_EXPORT int spine_path_constraint_data_get_num_bones(spine_path_constraint_data data) { + if (data == nullptr) return 0; + PathConstraintData *_data = (PathConstraintData*)data; + return (int)_data->getBones().size(); +} + +FFI_PLUGIN_EXPORT spine_bone_data* spine_path_constraint_data_get_bones(spine_path_constraint_data data) { + if (data == nullptr) return nullptr; + PathConstraintData *_data = (PathConstraintData*)data; + return (spine_bone_data*)_data->getBones().buffer(); +} + +FFI_PLUGIN_EXPORT spine_slot_data spine_path_constraint_data_get_target(spine_path_constraint_data data) { + if (data == nullptr) return nullptr; + PathConstraintData *_data = (PathConstraintData*)data; + return (spine_slot_data)_data->getTarget(); +} + +FFI_PLUGIN_EXPORT void spine_path_constraint_data_set_target(spine_path_constraint_data data, spine_slot_data target) { + if (data == nullptr) return; + PathConstraintData *_data = (PathConstraintData*)data; + _data->setTarget((SlotData*)target); +} + +FFI_PLUGIN_EXPORT spine_position_mode spine_path_constraint_data_get_position_mode(spine_path_constraint_data data) { + if (data == nullptr) return SPINE_POSITION_MODE_FIXED; + PathConstraintData *_data = (PathConstraintData*)data; + return (spine_position_mode)_data->getPositionMode(); +} + +FFI_PLUGIN_EXPORT void spine_path_constraint_data_set_position_mode(spine_path_constraint_data data, spine_position_mode positionMode) { + if (data == nullptr) return; + PathConstraintData *_data = (PathConstraintData*)data; + _data->setPositionMode((PositionMode)positionMode); +} + +FFI_PLUGIN_EXPORT spine_spacing_mode spine_path_constraint_data_get_spacing_mode(spine_path_constraint_data data) { + if (data == nullptr) return SPINE_SPACING_MODE_LENGTH; + PathConstraintData *_data = (PathConstraintData*)data; + return (spine_spacing_mode)_data->getSpacingMode(); +} + +FFI_PLUGIN_EXPORT void spine_path_constraint_data_set_spacing_mode(spine_path_constraint_data data, spine_spacing_mode spacingMode) { + if (data == nullptr) return; + PathConstraintData *_data = (PathConstraintData*)data; + _data->setSpacingMode((SpacingMode)spacingMode); +} + +FFI_PLUGIN_EXPORT spine_rotate_mode spine_path_constraint_data_get_rotate_mode(spine_path_constraint_data data) { + if (data == nullptr) return SPINE_ROTATE_MODE_TANGENT; + PathConstraintData *_data = (PathConstraintData*)data; + return (spine_rotate_mode)_data->getRotateMode(); +} + +FFI_PLUGIN_EXPORT void spine_path_constraint_data_set_rotate_mode(spine_path_constraint_data data, spine_rotate_mode rotateMode) { + if (data == nullptr) return; + PathConstraintData *_data = (PathConstraintData*)data; + _data->setRotateMode((RotateMode)rotateMode); +} + +FFI_PLUGIN_EXPORT float spine_path_constraint_data_get_offset_rotation(spine_path_constraint_data data) { + if (data == nullptr) return 0; + PathConstraintData *_data = (PathConstraintData*)data; + return _data->getOffsetRotation(); +} + +FFI_PLUGIN_EXPORT void spine_path_constraint_data_set_offset_rotation(spine_path_constraint_data data, float offsetRotation) { + if (data == nullptr) return; + PathConstraintData *_data = (PathConstraintData*)data; + _data->setOffsetRotation(offsetRotation); +} + +FFI_PLUGIN_EXPORT float spine_path_constraint_data_get_position(spine_path_constraint_data data) { + if (data == nullptr) return 0; + PathConstraintData *_data = (PathConstraintData*)data; + return _data->getPosition(); +} + +FFI_PLUGIN_EXPORT void spine_path_constraint_data_set_position(spine_path_constraint_data data, float position) { + if (data == nullptr) return; + PathConstraintData *_data = (PathConstraintData*)data; + _data->setPosition(position); +} + +FFI_PLUGIN_EXPORT float spine_path_constraint_data_get_spacing(spine_path_constraint_data data) { + if (data == nullptr) return 0; + PathConstraintData *_data = (PathConstraintData*)data; + return _data->getSpacing(); +} + +FFI_PLUGIN_EXPORT void spine_path_constraint_data_set_spacing(spine_path_constraint_data data, float spacing) { + if (data == nullptr) return; + PathConstraintData *_data = (PathConstraintData*)data; + _data->setSpacing(spacing); +} + +FFI_PLUGIN_EXPORT float spine_path_constraint_data_get_mix_rotate(spine_path_constraint_data data) { + if (data == nullptr) return 0; + PathConstraintData *_data = (PathConstraintData*)data; + return _data->getMixRotate(); +} + +FFI_PLUGIN_EXPORT void spine_path_constraint_data_set_mix_rotate(spine_path_constraint_data data, float mixRotate) { + if (data == nullptr) return; + PathConstraintData *_data = (PathConstraintData*)data; + _data->setMixRotate(mixRotate); +} + +FFI_PLUGIN_EXPORT float spine_path_constraint_data_get_mix_x(spine_path_constraint_data data) { + if (data == nullptr) return 0; + PathConstraintData *_data = (PathConstraintData*)data; + return _data->getMixX(); +} + +FFI_PLUGIN_EXPORT void spine_path_constraint_data_set_mix_x(spine_path_constraint_data data, float mixX) { + if (data == nullptr) return; + PathConstraintData *_data = (PathConstraintData*)data; + _data->setMixX(mixX); +} + +FFI_PLUGIN_EXPORT float spine_path_constraint_data_get_mix_y(spine_path_constraint_data data) { + if (data == nullptr) return 0; + PathConstraintData *_data = (PathConstraintData*)data; + return _data->getMixY(); +} + +FFI_PLUGIN_EXPORT void spine_path_constraint_data_set_mix_y(spine_path_constraint_data data, float mixY) { + if (data == nullptr) return; + PathConstraintData *_data = (PathConstraintData*)data; + _data->setMixY(mixY); +} + +// PathConstraint +FFI_PLUGIN_EXPORT void spine_path_constraint_update(spine_path_constraint constraint) { + if (constraint == nullptr) return; + PathConstraint *_constraint = (PathConstraint*)constraint; + _constraint->update(); +} + +FFI_PLUGIN_EXPORT int spine_path_constraint_get_order(spine_path_constraint constraint) { + if (constraint == nullptr) return 0; + PathConstraint *_constraint = (PathConstraint*)constraint; + return _constraint->getOrder(); +} + +FFI_PLUGIN_EXPORT spine_path_constraint_data spine_path_constraint_get_data(spine_path_constraint constraint) { + if (constraint == nullptr) return nullptr; + PathConstraint *_constraint = (PathConstraint*)constraint; + return (spine_path_constraint_data)&_constraint->getData(); +} + +FFI_PLUGIN_EXPORT int spine_path_constraint_get_num_bones(spine_path_constraint constraint) { + if (constraint == nullptr) return 0; + PathConstraint *_constraint = (PathConstraint*)constraint; + return (int)_constraint->getBones().size(); +} + +FFI_PLUGIN_EXPORT spine_bone* spine_path_constraint_get_bones(spine_path_constraint constraint) { + if (constraint == nullptr) return nullptr; + PathConstraint *_constraint = (PathConstraint*)constraint; + return (spine_bone*)_constraint->getBones().buffer(); +} + +FFI_PLUGIN_EXPORT spine_slot spine_path_constraint_get_target(spine_path_constraint constraint) { + if (constraint == nullptr) return nullptr; + PathConstraint *_constraint = (PathConstraint*)constraint; + return (spine_slot)_constraint->getTarget(); +} + +FFI_PLUGIN_EXPORT void spine_path_constraint_set_target(spine_path_constraint constraint, spine_slot target) { + if (constraint == nullptr) return; + PathConstraint *_constraint = (PathConstraint*)constraint; + _constraint->setTarget((Slot*)target); +} + +FFI_PLUGIN_EXPORT float spine_path_constraint_get_position(spine_path_constraint constraint) { + if (constraint == nullptr) return 0; + PathConstraint *_constraint = (PathConstraint*)constraint; + return _constraint->getPosition(); +} + +FFI_PLUGIN_EXPORT void spine_path_constraint_set_position(spine_path_constraint constraint, float position) { + if (constraint == nullptr) return; + PathConstraint *_constraint = (PathConstraint*)constraint; + _constraint->setPosition(position); +} + +FFI_PLUGIN_EXPORT float spine_path_constraint_get_spacing(spine_path_constraint constraint) { + if (constraint == nullptr) return 0; + PathConstraint *_constraint = (PathConstraint*)constraint; + return _constraint->getSpacing(); +} + +FFI_PLUGIN_EXPORT void spine_path_constraint_set_spacing(spine_path_constraint constraint, float spacing) { + if (constraint == nullptr) return; + PathConstraint *_constraint = (PathConstraint*)constraint; + _constraint->setSpacing(spacing); +} + +FFI_PLUGIN_EXPORT float spine_path_constraint_get_mix_rotate(spine_path_constraint constraint) { + if (constraint == nullptr) return 0; + PathConstraint *_constraint = (PathConstraint*)constraint; + return _constraint->getMixRotate(); +} + +FFI_PLUGIN_EXPORT void spine_path_constraint_set_mix_rotate(spine_path_constraint constraint, float mixRotate) { + if (constraint == nullptr) return; + PathConstraint *_constraint = (PathConstraint*)constraint; + _constraint->setMixRotate(mixRotate); +} + +FFI_PLUGIN_EXPORT float spine_path_constraint_get_mix_x(spine_path_constraint constraint) { + if (constraint == nullptr) return 0; + PathConstraint *_constraint = (PathConstraint*)constraint; + return _constraint->getMixX(); +} + +FFI_PLUGIN_EXPORT void spine_path_constraint_set_mix_x(spine_path_constraint constraint, float mixX) { + if (constraint == nullptr) return; + PathConstraint *_constraint = (PathConstraint*)constraint; + _constraint->setMixX(mixX); +} + +FFI_PLUGIN_EXPORT float spine_path_constraint_get_mix_y(spine_path_constraint constraint) { + if (constraint == nullptr) return 0; + PathConstraint *_constraint = (PathConstraint*)constraint; + return _constraint->getMixY(); +} + +FFI_PLUGIN_EXPORT void spine_path_constraint_set_mix_y(spine_path_constraint constraint, float mixY) { + if (constraint == nullptr) return; + PathConstraint *_constraint = (PathConstraint*)constraint; + _constraint->setMixY(mixY); +} + +FFI_PLUGIN_EXPORT int spine_path_constraint_get_is_active(spine_path_constraint constraint) { + if (constraint == nullptr) return 0; + PathConstraint *_constraint = (PathConstraint*)constraint; + return _constraint->isActive() ? -1 : 0; +} + +FFI_PLUGIN_EXPORT void spine_path_constraint_set_is_active(spine_path_constraint constraint, int isActive) { + if (constraint == nullptr) return; + PathConstraint *_constraint = (PathConstraint*)constraint; + _constraint->setActive(isActive); +} + diff --git a/spine-flutter/src/spine_flutter.h b/spine-flutter/src/spine_flutter.h index 5441a0c2a..b529b625f 100644 --- a/spine-flutter/src/spine_flutter.h +++ b/spine-flutter/src/spine_flutter.h @@ -104,6 +104,24 @@ typedef enum spine_transform_mode { SPINE_TRANSFORM_NO_SCALE_OR_REFLECTION } spine_transform_mode; +typedef enum spine_position_mode { + SPINE_POSITION_MODE_FIXED = 0, + SPINE_POSITION_MODE_PERCENT +} spine_position_mode; + +typedef enum spine_spacing_mode { + SPINE_SPACING_MODE_LENGTH = 0, + SPINE_SPACING_MODE_FIXED, + SPINE_SPACING_MODE_PERCENT, + SPINE_SPACING_MODE_PROPORTIONAL +} spine_spacing_mode; + +typedef enum spine_rotate_mode { + SPINE_ROTATE_MODE_TANGENT = 0, + SPINE_ROTATE_MODE_CHAIN, + SPINE_ROTATE_MODE_CHAIN_SCALE +} spine_rotate_mode; + typedef struct spine_render_command { float *positions; float *uvs; @@ -506,6 +524,7 @@ FFI_PLUGIN_EXPORT void spine_ik_constraint_set_is_active(spine_ik_constraint con FFI_PLUGIN_EXPORT int spine_transform_constraint_data_get_num_bones(spine_transform_constraint_data data); FFI_PLUGIN_EXPORT spine_bone_data* spine_transform_constraint_data_get_bones(spine_transform_constraint_data data); FFI_PLUGIN_EXPORT spine_bone_data spine_transform_constraint_data_get_target(spine_transform_constraint_data data); +FFI_PLUGIN_EXPORT void spine_transform_constraint_data_set_target(spine_transform_constraint_data data, spine_bone_data target); FFI_PLUGIN_EXPORT float spine_transform_constraint_data_get_mix_rotate(spine_transform_constraint_data data); FFI_PLUGIN_EXPORT void spine_transform_constraint_data_set_mix_rotate(spine_transform_constraint_data data, float mixRotate); FFI_PLUGIN_EXPORT float spine_transform_constraint_data_get_mix_x(spine_transform_constraint_data data); @@ -557,4 +576,45 @@ FFI_PLUGIN_EXPORT void spine_transform_constraint_set_mix_shear_y(spine_transfor FFI_PLUGIN_EXPORT float spine_transform_constraint_get_is_active(spine_transform_constraint constraint); FFI_PLUGIN_EXPORT void spine_transform_constraint_set_is_active(spine_transform_constraint constraint, int isActive); +FFI_PLUGIN_EXPORT int spine_path_constraint_data_get_num_bones(spine_path_constraint_data data); +FFI_PLUGIN_EXPORT spine_bone_data* spine_path_constraint_data_get_bones(spine_path_constraint_data data); +FFI_PLUGIN_EXPORT spine_slot_data spine_path_constraint_data_get_target(spine_path_constraint_data data); +FFI_PLUGIN_EXPORT void spine_path_constraint_data_set_target(spine_path_constraint_data data, spine_slot_data target); +FFI_PLUGIN_EXPORT spine_position_mode spine_path_constraint_data_get_position_mode(spine_path_constraint_data data); +FFI_PLUGIN_EXPORT void spine_path_constraint_data_set_position_mode(spine_path_constraint_data data, spine_position_mode positionMode); +FFI_PLUGIN_EXPORT spine_spacing_mode spine_path_constraint_data_get_spacing_mode(spine_path_constraint_data data); +FFI_PLUGIN_EXPORT void spine_path_constraint_data_set_spacing_mode(spine_path_constraint_data data, spine_spacing_mode spacingMode); +FFI_PLUGIN_EXPORT spine_rotate_mode spine_path_constraint_data_get_rotate_mode(spine_path_constraint_data data); +FFI_PLUGIN_EXPORT void spine_path_constraint_data_set_rotate_mode(spine_path_constraint_data data, spine_rotate_mode rotateMode); +FFI_PLUGIN_EXPORT float spine_path_constraint_data_get_offset_rotation(spine_path_constraint_data data); +FFI_PLUGIN_EXPORT void spine_path_constraint_data_set_offset_rotation(spine_path_constraint_data data, float offsetRotation); +FFI_PLUGIN_EXPORT float spine_path_constraint_data_get_position(spine_path_constraint_data data); +FFI_PLUGIN_EXPORT void spine_path_constraint_data_set_position(spine_path_constraint_data data, float position); +FFI_PLUGIN_EXPORT float spine_path_constraint_data_get_spacing(spine_path_constraint_data data); +FFI_PLUGIN_EXPORT void spine_path_constraint_data_set_spacing(spine_path_constraint_data data, float spacing); +FFI_PLUGIN_EXPORT float spine_path_constraint_data_get_mix_rotate(spine_path_constraint_data data); +FFI_PLUGIN_EXPORT void spine_path_constraint_data_set_mix_rotate(spine_path_constraint_data data, float mixRotate); +FFI_PLUGIN_EXPORT float spine_path_constraint_data_get_mix_x(spine_path_constraint_data data); +FFI_PLUGIN_EXPORT void spine_path_constraint_data_set_mix_x(spine_path_constraint_data data, float mixX); +FFI_PLUGIN_EXPORT float spine_path_constraint_data_get_mix_y(spine_path_constraint_data data); +FFI_PLUGIN_EXPORT void spine_path_constraint_data_set_mix_y(spine_path_constraint_data data, float mixY); +FFI_PLUGIN_EXPORT void spine_path_constraint_update(spine_path_constraint constraint); +FFI_PLUGIN_EXPORT int spine_path_constraint_get_order(spine_path_constraint constraint); +FFI_PLUGIN_EXPORT spine_path_constraint_data spine_path_constraint_get_data(spine_path_constraint constraint); +FFI_PLUGIN_EXPORT int spine_path_constraint_get_num_bones(spine_path_constraint constraint); +FFI_PLUGIN_EXPORT spine_bone* spine_path_constraint_get_bones(spine_path_constraint constraint); +FFI_PLUGIN_EXPORT spine_slot spine_path_constraint_get_target(spine_path_constraint constraint); +FFI_PLUGIN_EXPORT void spine_path_constraint_set_target(spine_path_constraint constraint, spine_slot target); +FFI_PLUGIN_EXPORT float spine_path_constraint_get_position(spine_path_constraint constraint); +FFI_PLUGIN_EXPORT void spine_path_constraint_set_position(spine_path_constraint constraint, float position); +FFI_PLUGIN_EXPORT float spine_path_constraint_get_spacing(spine_path_constraint constraint); +FFI_PLUGIN_EXPORT void spine_path_constraint_set_spacing(spine_path_constraint constraint, float spacing); +FFI_PLUGIN_EXPORT float spine_path_constraint_get_mix_rotate(spine_path_constraint constraint); +FFI_PLUGIN_EXPORT void spine_path_constraint_set_mix_rotate(spine_path_constraint constraint, float mixRotate); +FFI_PLUGIN_EXPORT float spine_path_constraint_get_mix_x(spine_path_constraint constraint); +FFI_PLUGIN_EXPORT void spine_path_constraint_set_mix_x(spine_path_constraint constraint, float mixX); +FFI_PLUGIN_EXPORT float spine_path_constraint_get_mix_y(spine_path_constraint constraint); +FFI_PLUGIN_EXPORT void spine_path_constraint_set_mix_y(spine_path_constraint constraint, float mixY); +FFI_PLUGIN_EXPORT int spine_path_constraint_get_is_active(spine_path_constraint constraint); +FFI_PLUGIN_EXPORT void spine_path_constraint_set_is_active(spine_path_constraint constraint, int isActive); \ No newline at end of file