Browse Source

[cpp] 4.3 porting WIP

Mario Zechner 2 tháng trước cách đây
mục cha
commit
5aeceb27c9

+ 1 - 1
spine-cpp/spine-cpp/include/spine/IkConstraint.h

@@ -59,7 +59,7 @@ namespace spine {
 
 		virtual bool isSourceActive() override;
 
-		IkConstraintData &getData();
+		IkConstraintData &getData() override;
 
 		Vector<BonePose *> &getBones();
 

+ 1 - 1
spine-cpp/spine-cpp/include/spine/InheritTimeline.h

@@ -58,7 +58,7 @@ namespace spine {
 
 		virtual void
 		apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
-			  MixDirection direction, bool appliedPose);
+			  MixDirection direction, bool appliedPose) override;
 
 	private:
         static const int ENTRIES = 2;

+ 3 - 0
spine-cpp/spine-cpp/include/spine/Json.h

@@ -31,6 +31,7 @@
 #define Spine_Json_h
 
 #include <spine/SpineObject.h>
+#include <spine/Vector.h>
 
 #ifndef SPINE_JSON_HAVE_PREV
 /* spine doesn't use the "prev" link in the Json sibling lists. */
@@ -53,10 +54,12 @@ namespace spine {
 
 		template <typename T>
 		static bool asArray(Json *value, Vector<T> &array) {
+			if (value == NULL) return false;
 			array.setSize(value->_size, 0);
 			Json *vertex = value->_child;
 			for (int i = 0; vertex; vertex = vertex->_next, i++)
 				array[i] = vertex->_valueInt;
+			return true;
 		}
 
 		/* Get item "string" from object. Case insensitive. */

+ 1 - 1
spine-cpp/spine-cpp/include/spine/PathConstraintMixTimeline.h

@@ -51,7 +51,7 @@ namespace spine {
 
 		virtual void
 		apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
-			  MixDirection direction, bool appliedPose);
+			  MixDirection direction, bool appliedPose) override;
 
 		/// Sets the time and color for the specified frame.
 		/// @param frame Between 0 and frameCount, inclusive.

+ 1 - 1
spine-cpp/spine-cpp/include/spine/PathConstraintPositionTimeline.h

@@ -51,7 +51,7 @@ namespace spine {
 
 		virtual void
 		apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
-			  MixDirection direction, bool appliedPose);
+			  MixDirection direction, bool appliedPose) override;
 	};
 }
 

+ 1 - 1
spine-cpp/spine-cpp/include/spine/PathConstraintSpacingTimeline.h

@@ -48,7 +48,7 @@ namespace spine {
 
 		virtual void
 		apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
-			  MixDirection direction, bool appliedPose);
+			  MixDirection direction, bool appliedPose) override;
 	};
 }
 

+ 2 - 0
spine-cpp/spine-cpp/include/spine/SkeletonBinary.h

@@ -35,6 +35,8 @@
 #include <spine/SpineObject.h>
 #include <spine/SpineString.h>
 #include <spine/Color.h>
+#include <spine/BoneTimeline.h>
+#include <spine/SkeletonData.h>
 
 namespace spine {
 	class SkeletonData;

+ 2 - 2
spine-cpp/spine-cpp/src/spine/SkeletonBinary.cpp

@@ -183,7 +183,7 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
 
 		/* Bones. */
 		Vector<BoneData *> &bones = skeletonData->_bones.setSize(input.readInt(true), NULL);
-		for (int i = 0; i < bones.size(); ++i) {
+		for (int i = 0; i < (int)bones.size(); ++i) {
 			const char *name = input.readString();
 			BoneData *parent = i == 0 ? 0 : bones[input.readInt(true)];
 			BoneData *data = new (__FILE__, __LINE__) BoneData(i, String(name, true), parent);
@@ -208,7 +208,7 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
 
 		/* Slots. */
 		Vector<SlotData *> &slots = skeletonData->_slots.setSize(input.readInt(true), NULL);
-		for (int i = 0; i < slots.size(); ++i) {
+		for (int i = 0; i < (int)slots.size(); ++i) {
 			String slotName = String(input.readString(), true);
 			BoneData *boneData = bones[input.readInt(true)];
 			SlotData *data = new (__FILE__, __LINE__) SlotData(i, slotName, *boneData);

+ 1 - 1
spine-cpp/spine-cpp/src/spine/Slider.cpp

@@ -71,7 +71,7 @@ void Slider::update(Skeleton &skeleton, Physics physics) {
 		if (!_bone->isActive()) return;
 		if (_data._local) _bone->_applied->validateLocalTransform(skeleton);
 		p._time = _data._offset
-			+ (_data._property->value(skeleton, *_bone->_applied, _data._local, _offsets) - _data._property->offset) * _data._scale;
+			+ (_data._property->value(skeleton, *_bone->_applied, _data._local, _offsets) - _data._property->_offset) * _data._scale;
 		if (_data._loop)
 			p._time = animation->getDuration() + MathUtil::fmod(p._time, animation->getDuration());
 		else

+ 6 - 6
spine-cpp/spine-cpp/src/spine/TransformConstraint.cpp

@@ -83,18 +83,18 @@ void TransformConstraint::update(Skeleton &skeleton, Physics physics) {
 		}
 		for (size_t f = 0; f < fn; f++) {
 			FromProperty *from = fromItems[f];
-			float value = from->value(skeleton, source, localSource, offsets) - from->offset;
-			Vector<ToProperty *> &toProps = from->to;
+			float value = from->value(skeleton, source, localSource, offsets) - from->_offset;
+			Vector<ToProperty *> &toProps = from->_to;
 			ToProperty **toItems = toProps.buffer();
 			for (size_t t = 0, tn = toProps.size(); t < tn; t++) {
 				ToProperty *to = toItems[t];
 				if (to->mix(p) != 0) {
-					float clamped = to->offset + value * to->scale;
+					float clamped = to->_offset + value * to->_scale;
 					if (clamp) {
-						if (to->offset < to->max)
-							clamped = MathUtil::clamp(clamped, to->offset, to->max);
+						if (to->_offset < to->_max)
+							clamped = MathUtil::clamp(clamped, to->_offset, to->_max);
 						else
-							clamped = MathUtil::clamp(clamped, to->max, to->offset);
+							clamped = MathUtil::clamp(clamped, to->_max, to->_offset);
 					}
 					to->apply(skeleton, p, *bone, clamped, localTarget, additive);
 				}