mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 22:34:53 +08:00
wip
This commit is contained in:
parent
19687d9957
commit
8b53400425
@ -46,7 +46,7 @@ namespace Spine
|
||||
///
|
||||
class AtlasAttachmentLoader : public AttachmentLoader
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
AtlasAttachmentLoader(Vector<Atlas*>& inAtlasArray);
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
#ifndef Spine_Attachment_h
|
||||
#define Spine_Attachment_h
|
||||
|
||||
#include <spine/SpineRTTI.h>
|
||||
#include <spine/RTTI.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -39,7 +39,7 @@ namespace Spine
|
||||
{
|
||||
class Attachment
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
Attachment(std::string name);
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
#ifndef Spine_AttachmentLoader_h
|
||||
#define Spine_AttachmentLoader_h
|
||||
|
||||
#include <spine/SpineRTTI.h>
|
||||
#include <spine/RTTI.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -47,7 +47,7 @@ namespace Spine
|
||||
|
||||
class AttachmentLoader
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
AttachmentLoader();
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@ namespace Spine
|
||||
|
||||
class AttachmentTimeline : public Timeline
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
AttachmentTimeline(int frameCount);
|
||||
|
||||
@ -47,7 +47,7 @@ namespace Spine
|
||||
/// constraint or application code modifies the world transform after it was computed from the local transform.
|
||||
class Bone : public Updatable
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
friend class RotateTimeline;
|
||||
friend class IkConstraint;
|
||||
|
||||
@ -38,7 +38,7 @@ namespace Spine
|
||||
/// Attachment that has a polygon for bounds checking.
|
||||
class BoundingBoxAttachment : public VertexAttachment
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
BoundingBoxAttachment(std::string name);
|
||||
};
|
||||
|
||||
@ -39,7 +39,7 @@ namespace Spine
|
||||
|
||||
class ClippingAttachment : public VertexAttachment
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
friend class SkeletonClipping;
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ namespace Spine
|
||||
{
|
||||
class ColorTimeline : public CurveTimeline
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
static const int ENTRIES;
|
||||
|
||||
@ -38,7 +38,7 @@ namespace Spine
|
||||
/// The interface for all constraints.
|
||||
class Constraint : public Updatable
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
Constraint();
|
||||
|
||||
@ -41,7 +41,7 @@ namespace Spine
|
||||
/// Base class for frames that use an interpolation bezier curve.
|
||||
class CurveTimeline : public Timeline
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
CurveTimeline(int frameCount);
|
||||
|
||||
@ -39,7 +39,7 @@ namespace Spine
|
||||
|
||||
class DeformTimeline : public CurveTimeline
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
DeformTimeline(int frameCount);
|
||||
|
||||
@ -37,7 +37,7 @@ namespace Spine
|
||||
{
|
||||
class DrawOrderTimeline : public Timeline
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
DrawOrderTimeline(int frameCount);
|
||||
|
||||
@ -37,7 +37,7 @@ namespace Spine
|
||||
{
|
||||
class EventTimeline : public Timeline
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction);
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ namespace Spine
|
||||
{
|
||||
friend class Skeleton;
|
||||
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
/// Adjusts the bone rotation so the tip is as close to the target position as possible. The target is specified
|
||||
|
||||
@ -37,7 +37,7 @@ namespace Spine
|
||||
{
|
||||
class IkConstraintTimeline : public CurveTimeline
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
static const int ENTRIES;
|
||||
|
||||
@ -42,7 +42,7 @@ namespace Spine
|
||||
/// Attachment that displays a texture region using a mesh.
|
||||
class MeshAttachment : public VertexAttachment
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
friend class AtlasAttachmentLoader;
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ namespace Spine
|
||||
{
|
||||
class PathAttachment : public VertexAttachment
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
PathAttachment(std::string name);
|
||||
|
||||
@ -47,7 +47,7 @@ namespace Spine
|
||||
{
|
||||
friend class Skeleton;
|
||||
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
PathConstraint(PathConstraintData& data, Skeleton& skeleton);
|
||||
|
||||
@ -37,7 +37,7 @@ namespace Spine
|
||||
{
|
||||
class PathConstraintMixTimeline : public CurveTimeline
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction);
|
||||
|
||||
@ -37,7 +37,7 @@ namespace Spine
|
||||
{
|
||||
class PathConstraintPositionTimeline : public CurveTimeline
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
static const int ENTRIES;
|
||||
|
||||
@ -37,7 +37,7 @@ namespace Spine
|
||||
{
|
||||
class PathConstraintSpacingTimeline : public PathConstraintPositionTimeline
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
PathConstraintSpacingTimeline(int frameCount);
|
||||
|
||||
@ -46,7 +46,7 @@ namespace Spine
|
||||
///
|
||||
class PointAttachment : public Attachment
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
PointAttachment(std::string name);
|
||||
|
||||
@ -28,48 +28,48 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef Spine_SPINE_RTTI_h
|
||||
#define Spine_SPINE_RTTI_h
|
||||
#ifndef Spine_RTTI_h
|
||||
#define Spine_RTTI_h
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
class SPINE_RTTI
|
||||
class RTTI
|
||||
{
|
||||
public:
|
||||
SPINE_RTTI(const std::string& className);
|
||||
RTTI(const std::string& className);
|
||||
|
||||
SPINE_RTTI(const std::string& className, const SPINE_RTTI& baseSPINE_RTTI);
|
||||
RTTI(const std::string& className, const RTTI& baseRTTI);
|
||||
|
||||
const std::string& getClassName() const;
|
||||
|
||||
bool isExactly(const SPINE_RTTI& rtti) const;
|
||||
bool isExactly(const RTTI& rtti) const;
|
||||
|
||||
bool derivesFrom(const SPINE_RTTI& rtti) const;
|
||||
bool derivesFrom(const RTTI& rtti) const;
|
||||
|
||||
private:
|
||||
// Prevent copying
|
||||
SPINE_RTTI(const SPINE_RTTI& obj);
|
||||
SPINE_RTTI& operator=(const SPINE_RTTI& obj);
|
||||
RTTI(const RTTI& obj);
|
||||
RTTI& operator=(const RTTI& obj);
|
||||
|
||||
const std::string m_className;
|
||||
const SPINE_RTTI *m_pBaseSPINE_RTTI;
|
||||
const RTTI *m_pBaseRTTI;
|
||||
};
|
||||
}
|
||||
|
||||
#define SPINE_RTTI_DECL \
|
||||
#define RTTI_DECL \
|
||||
public: \
|
||||
static const Spine::SPINE_RTTI rtti; \
|
||||
virtual const Spine::SPINE_RTTI& getRTTI();
|
||||
static const Spine::RTTI rtti; \
|
||||
virtual const Spine::RTTI& getRTTI();
|
||||
|
||||
#define SPINE_RTTI_IMPL_NOPARENT(name) \
|
||||
const Spine::SPINE_RTTI name::rtti(#name); \
|
||||
const Spine::SPINE_RTTI& name::getRTTI() { return rtti; }
|
||||
#define RTTI_IMPL_NOPARENT(name) \
|
||||
const Spine::RTTI name::rtti(#name); \
|
||||
const Spine::RTTI& name::getRTTI() { return rtti; }
|
||||
|
||||
#define SPINE_RTTI_IMPL(name,parent) \
|
||||
const Spine::SPINE_RTTI name::rtti(#name, parent::rtti); \
|
||||
const Spine::SPINE_RTTI& name::getRTTI() { return rtti; }
|
||||
#define RTTI_IMPL(name,parent) \
|
||||
const Spine::RTTI name::rtti(#name, parent::rtti); \
|
||||
const Spine::RTTI& name::getRTTI() { return rtti; }
|
||||
|
||||
#endif /* Spine_SPINE_RTTI_h */
|
||||
#endif /* Spine_RTTI_h */
|
||||
|
||||
@ -46,7 +46,7 @@ namespace Spine
|
||||
/// Attachment that displays a texture region.
|
||||
class RegionAttachment : public Attachment
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
friend class AtlasAttachmentLoader;
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ namespace Spine
|
||||
{
|
||||
class RotateTimeline : public CurveTimeline
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
static const int ENTRIES = 2;
|
||||
|
||||
@ -37,7 +37,7 @@ namespace Spine
|
||||
{
|
||||
class ScaleTimeline : public TranslateTimeline
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction);
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ namespace Spine
|
||||
{
|
||||
class ShearTimeline : public TranslateTimeline
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction);
|
||||
|
||||
@ -51,6 +51,9 @@ namespace Spine
|
||||
|
||||
class Skeleton
|
||||
{
|
||||
friend class SkeletonBounds;
|
||||
friend class SkeletonClipping;
|
||||
|
||||
friend class AttachmentTimeline;
|
||||
friend class ColorTimeline;
|
||||
friend class DeformTimeline;
|
||||
|
||||
@ -69,7 +69,7 @@ namespace Spine
|
||||
bool aabbIntersectsSkeleton(SkeletonBounds bounds);
|
||||
|
||||
/// Returns true if the polygon contains the point.
|
||||
bool containsPoint(Polygon polygon, float x, float y);
|
||||
bool containsPoint(Polygon* polygon, float x, float y);
|
||||
|
||||
/// Returns the first bounding box attachment that contains the point, or NULL. When doing many checks, it is usually more
|
||||
/// efficient to only call this method if {@link #aabbcontainsPoint(float, float)} returns true.
|
||||
|
||||
@ -63,7 +63,7 @@ namespace Spine
|
||||
Vector<float> _clippedUVs;
|
||||
Vector<float> _scratch;
|
||||
ClippingAttachment* _clipAttachment;
|
||||
Vector< Vector<float> > _clippingPolygons;
|
||||
Vector< Vector<float>* > _clippingPolygons;
|
||||
|
||||
/** Clips the input triangle against the convex, clockwise clipping area. If the triangle lies entirely within the clipping
|
||||
* area, false is returned. The clipping area must duplicate the first vertex at the end of the vertices list. */
|
||||
|
||||
@ -46,6 +46,7 @@ namespace Spine
|
||||
{
|
||||
friend class VertexAttachment;
|
||||
friend class Skeleton;
|
||||
friend class SkeletonBounds;
|
||||
friend class SkeletonClipping;
|
||||
|
||||
friend class AttachmentTimeline;
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
#ifndef Spine_Timeline_h
|
||||
#define Spine_Timeline_h
|
||||
|
||||
#include <spine/SpineRTTI.h>
|
||||
#include <spine/RTTI.h>
|
||||
#include <spine/Vector.h>
|
||||
#include <spine/MixPose.h>
|
||||
#include <spine/MixDirection.h>
|
||||
@ -43,7 +43,7 @@ namespace Spine
|
||||
|
||||
class Timeline
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
Timeline();
|
||||
|
||||
@ -45,7 +45,7 @@ namespace Spine
|
||||
{
|
||||
friend class Skeleton;
|
||||
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
TransformConstraint(TransformConstraintData& data, Skeleton& skeleton);
|
||||
|
||||
@ -37,7 +37,7 @@ namespace Spine
|
||||
{
|
||||
class TransformConstraintTimeline : public CurveTimeline
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
static const int ENTRIES;
|
||||
|
||||
@ -40,7 +40,7 @@ namespace Spine
|
||||
{
|
||||
class TranslateTimeline : public CurveTimeline
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction);
|
||||
|
||||
@ -37,7 +37,7 @@ namespace Spine
|
||||
{
|
||||
class TwoColorTimeline : public CurveTimeline
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction);
|
||||
|
||||
@ -31,13 +31,13 @@
|
||||
#ifndef Spine_Updatable_h
|
||||
#define Spine_Updatable_h
|
||||
|
||||
#include <spine/SpineRTTI.h>
|
||||
#include <spine/RTTI.h>
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
class Updatable
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
public:
|
||||
Updatable();
|
||||
|
||||
@ -42,7 +42,7 @@ namespace Spine
|
||||
/// An attachment with vertices that are transformed by one or more bones and can be deformed by a slot's vertices.
|
||||
class VertexAttachment : public Attachment
|
||||
{
|
||||
SPINE_RTTI_DECL;
|
||||
RTTI_DECL;
|
||||
|
||||
friend class DeformTimeline;
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(AtlasAttachmentLoader, AttachmentLoader);
|
||||
RTTI_IMPL(AtlasAttachmentLoader, AttachmentLoader);
|
||||
|
||||
AtlasAttachmentLoader::AtlasAttachmentLoader(Vector<Atlas*>& inAtlasArray) : AttachmentLoader(), _atlasArray(inAtlasArray)
|
||||
{
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL_NOPARENT(Attachment);
|
||||
RTTI_IMPL_NOPARENT(Attachment);
|
||||
|
||||
Attachment::Attachment(std::string name) : _name(name)
|
||||
{
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL_NOPARENT(AttachmentLoader);
|
||||
RTTI_IMPL_NOPARENT(AttachmentLoader);
|
||||
|
||||
AttachmentLoader::AttachmentLoader()
|
||||
{
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(AttachmentTimeline, Timeline);
|
||||
RTTI_IMPL(AttachmentTimeline, Timeline);
|
||||
|
||||
AttachmentTimeline::AttachmentTimeline(int frameCount) : Timeline(), _slotIndex(0)
|
||||
{
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(Bone, Updatable);
|
||||
RTTI_IMPL(Bone, Updatable);
|
||||
|
||||
bool Bone::yDown = false;
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(BoundingBoxAttachment, VertexAttachment);
|
||||
RTTI_IMPL(BoundingBoxAttachment, VertexAttachment);
|
||||
|
||||
BoundingBoxAttachment::BoundingBoxAttachment(std::string name) : VertexAttachment(name)
|
||||
{
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(ClippingAttachment, VertexAttachment);
|
||||
RTTI_IMPL(ClippingAttachment, VertexAttachment);
|
||||
|
||||
ClippingAttachment::ClippingAttachment(std::string name) : VertexAttachment(name)
|
||||
{
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(ColorTimeline, CurveTimeline);
|
||||
RTTI_IMPL(ColorTimeline, CurveTimeline);
|
||||
|
||||
const int ColorTimeline::ENTRIES = 5;
|
||||
const int ColorTimeline::PREV_TIME = -5;
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(Constraint, Updatable);
|
||||
RTTI_IMPL(Constraint, Updatable);
|
||||
|
||||
Constraint::Constraint()
|
||||
{
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(CurveTimeline, Timeline);
|
||||
RTTI_IMPL(CurveTimeline, Timeline);
|
||||
|
||||
const float CurveTimeline::LINEAR = 0;
|
||||
const float CurveTimeline::STEPPED = 1;
|
||||
|
||||
@ -42,7 +42,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(DeformTimeline, CurveTimeline);
|
||||
RTTI_IMPL(DeformTimeline, CurveTimeline);
|
||||
|
||||
DeformTimeline::DeformTimeline(int frameCount) : CurveTimeline(frameCount), _slotIndex(0), _attachment(NULL)
|
||||
{
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(DrawOrderTimeline, Timeline);
|
||||
RTTI_IMPL(DrawOrderTimeline, Timeline);
|
||||
|
||||
DrawOrderTimeline::DrawOrderTimeline(int frameCount) : Timeline()
|
||||
{
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(EventTimeline, Timeline);
|
||||
RTTI_IMPL(EventTimeline, Timeline);
|
||||
|
||||
void EventTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction)
|
||||
{
|
||||
|
||||
@ -39,7 +39,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(IkConstraint, Constraint);
|
||||
RTTI_IMPL(IkConstraint, Constraint);
|
||||
|
||||
void IkConstraint::apply(Bone& bone, float targetX, float targetY, float alpha)
|
||||
{
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(IkConstraintTimeline, CurveTimeline);
|
||||
RTTI_IMPL(IkConstraintTimeline, CurveTimeline);
|
||||
|
||||
const int IkConstraintTimeline::ENTRIES = 3;
|
||||
const int IkConstraintTimeline::PREV_TIME = -3;
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(MeshAttachment, VertexAttachment);
|
||||
RTTI_IMPL(MeshAttachment, VertexAttachment);
|
||||
|
||||
MeshAttachment::MeshAttachment(std::string name) : VertexAttachment(name),
|
||||
_regionOffsetX(0),
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(PathAttachment, VertexAttachment);
|
||||
RTTI_IMPL(PathAttachment, VertexAttachment);
|
||||
|
||||
PathAttachment::PathAttachment(std::string name) : VertexAttachment(name)
|
||||
{
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(PathConstraint, Constraint);
|
||||
RTTI_IMPL(PathConstraint, Constraint);
|
||||
|
||||
const float PathConstraint::EPSILON = 0.00001f;
|
||||
const int PathConstraint::NONE = -1;
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(PathConstraintMixTimeline, CurveTimeline);
|
||||
RTTI_IMPL(PathConstraintMixTimeline, CurveTimeline);
|
||||
|
||||
void PathConstraintMixTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction)
|
||||
{
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(PathConstraintPositionTimeline, CurveTimeline);
|
||||
RTTI_IMPL(PathConstraintPositionTimeline, CurveTimeline);
|
||||
|
||||
const int PathConstraintPositionTimeline::ENTRIES = 2;
|
||||
const int PathConstraintPositionTimeline::PREV_TIME = -2;
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(PathConstraintSpacingTimeline, PathConstraintPositionTimeline);
|
||||
RTTI_IMPL(PathConstraintSpacingTimeline, PathConstraintPositionTimeline);
|
||||
|
||||
PathConstraintSpacingTimeline::PathConstraintSpacingTimeline(int frameCount) : PathConstraintPositionTimeline(frameCount)
|
||||
{
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(PointAttachment, Attachment);
|
||||
RTTI_IMPL(PointAttachment, Attachment);
|
||||
|
||||
PointAttachment::PointAttachment(std::string name) : Attachment(name)
|
||||
{
|
||||
|
||||
@ -28,33 +28,33 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
#include <spine/SpineRTTI.h>
|
||||
#include <spine/RTTI.h>
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI::SPINE_RTTI(const std::string& className) : m_className(className), m_pBaseSPINE_RTTI(NULL)
|
||||
RTTI::RTTI(const std::string& className) : m_className(className), m_pBaseRTTI(NULL)
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
SPINE_RTTI::SPINE_RTTI(const std::string& className, const SPINE_RTTI& baseSPINE_RTTI) : m_className(className), m_pBaseSPINE_RTTI(&baseSPINE_RTTI)
|
||||
RTTI::RTTI(const std::string& className, const RTTI& baseRTTI) : m_className(className), m_pBaseRTTI(&baseRTTI)
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
const std::string& SPINE_RTTI::getClassName() const
|
||||
const std::string& RTTI::getClassName() const
|
||||
{
|
||||
return m_className;
|
||||
}
|
||||
|
||||
bool SPINE_RTTI::isExactly(const SPINE_RTTI& rtti) const
|
||||
bool RTTI::isExactly(const RTTI& rtti) const
|
||||
{
|
||||
return (this == &rtti);
|
||||
}
|
||||
|
||||
bool SPINE_RTTI::derivesFrom(const SPINE_RTTI& rtti) const
|
||||
bool RTTI::derivesFrom(const RTTI& rtti) const
|
||||
{
|
||||
const SPINE_RTTI * pCompare = this;
|
||||
const RTTI * pCompare = this;
|
||||
|
||||
while (pCompare)
|
||||
{
|
||||
@ -63,7 +63,7 @@ namespace Spine
|
||||
return true;
|
||||
}
|
||||
|
||||
pCompare = pCompare->m_pBaseSPINE_RTTI;
|
||||
pCompare = pCompare->m_pBaseRTTI;
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -38,7 +38,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(RegionAttachment, Attachment);
|
||||
RTTI_IMPL(RegionAttachment, Attachment);
|
||||
|
||||
const int RegionAttachment::BLX = 0;
|
||||
const int RegionAttachment::BLY = 1;
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(RotateTimeline, CurveTimeline);
|
||||
RTTI_IMPL(RotateTimeline, CurveTimeline);
|
||||
|
||||
RotateTimeline::RotateTimeline(int frameCount) : CurveTimeline(frameCount), _boneIndex(0)
|
||||
{
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(ScaleTimeline, TranslateTimeline);
|
||||
RTTI_IMPL(ScaleTimeline, TranslateTimeline);
|
||||
|
||||
void ScaleTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction)
|
||||
{
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(ShearTimeline, TranslateTimeline);
|
||||
RTTI_IMPL(ShearTimeline, TranslateTimeline);
|
||||
|
||||
void ShearTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction)
|
||||
{
|
||||
|
||||
@ -33,6 +33,9 @@
|
||||
#include <spine/Skeleton.h>
|
||||
#include <spine/BoundingBoxAttachment.h>
|
||||
|
||||
#include <spine/Slot.h>
|
||||
#include <spine/MathUtil.h>
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SkeletonBounds::SkeletonBounds() : _minX(0), _minY(0), _maxX(0), _maxY(0)
|
||||
@ -42,63 +45,65 @@ namespace Spine
|
||||
|
||||
void SkeletonBounds::update(Skeleton& skeleton, bool updateAabb)
|
||||
{
|
||||
// Vector<Slot> slots = skeleton._slots;
|
||||
// int slotCount = slots.Count;
|
||||
//
|
||||
// _boundingBoxes.clear();
|
||||
// for (int i = 0, n = _polygons.size(); i < n; ++i)
|
||||
// {
|
||||
// _polygonPool.push_back(_polygons[i]);
|
||||
// }
|
||||
//
|
||||
// _polygons.clear();
|
||||
//
|
||||
// for (int i = 0; i < slotCount; i++)
|
||||
// {
|
||||
// Slot slot = slots.Items[i];
|
||||
// BoundingBoxAttachment boundingBox = slot.attachment as BoundingBoxAttachment;
|
||||
// if (boundingBox == NULL)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
// _boundingBoxes.push_back(boundingBox);
|
||||
//
|
||||
// Polygon* polygonP = NULL;
|
||||
// int poolCount = _polygonPool.size();
|
||||
// if (poolCount > 0)
|
||||
// {
|
||||
// polygonP = _polygonPool[poolCount - 1];
|
||||
// _polygonPool.erase(poolCount - 1);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// polygonP = new Polygon();
|
||||
// }
|
||||
//
|
||||
// _polygons.push_back(polygonP);
|
||||
//
|
||||
// Polygon& polygon = *polygonP;
|
||||
//
|
||||
// int count = boundingBox.worldVerticesLength;
|
||||
// polygon._count = count;
|
||||
// if (polygon._vertices.size() < count)
|
||||
// {
|
||||
// polygon._vertices.reserve(count);
|
||||
// }
|
||||
// boundingBox.computeWorldVertices(slot, polygon._vertices);
|
||||
// }
|
||||
//
|
||||
// if (updateAabb)
|
||||
// {
|
||||
// aabbCompute();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// minX = int.MinValue;
|
||||
// minY = int.MinValue;
|
||||
// maxX = int.MaxValue;
|
||||
// maxY = int.MaxValue;
|
||||
// }
|
||||
Vector<Slot*>& slots = skeleton._slots;
|
||||
int slotCount = static_cast<int>(slots.size());
|
||||
|
||||
_boundingBoxes.clear();
|
||||
for (int i = 0, n = static_cast<int>(_polygons.size()); i < n; ++i)
|
||||
{
|
||||
_polygonPool.push_back(_polygons[i]);
|
||||
}
|
||||
|
||||
_polygons.clear();
|
||||
|
||||
for (int i = 0; i < slotCount; i++)
|
||||
{
|
||||
Slot* slot = slots[i];
|
||||
Attachment* attachment = slot->_attachment;
|
||||
if (attachment == NULL || !attachment->getRTTI().derivesFrom(BoundingBoxAttachment::rtti))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
BoundingBoxAttachment* boundingBox = static_cast<BoundingBoxAttachment*>(attachment);
|
||||
_boundingBoxes.push_back(boundingBox);
|
||||
|
||||
Polygon* polygonP = NULL;
|
||||
int poolCount = static_cast<int>(_polygonPool.size());
|
||||
if (poolCount > 0)
|
||||
{
|
||||
polygonP = _polygonPool[poolCount - 1];
|
||||
_polygonPool.erase(poolCount - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Polygon* polygonP = MALLOC(Polygon, 1);
|
||||
new (polygonP) Polygon();
|
||||
}
|
||||
|
||||
_polygons.push_back(polygonP);
|
||||
|
||||
Polygon& polygon = *polygonP;
|
||||
|
||||
int count = boundingBox->getWorldVerticesLength();
|
||||
polygon._count = count;
|
||||
if (polygon._vertices.size() < count)
|
||||
{
|
||||
polygon._vertices.reserve(count);
|
||||
}
|
||||
boundingBox->computeWorldVertices(*slot, polygon._vertices);
|
||||
}
|
||||
|
||||
if (updateAabb)
|
||||
{
|
||||
aabbCompute();
|
||||
}
|
||||
else
|
||||
{
|
||||
_minX = std::numeric_limits<int>::min();
|
||||
_minY = std::numeric_limits<int>::min();
|
||||
_maxX = std::numeric_limits<int>::max();
|
||||
_maxY = std::numeric_limits<int>::max();
|
||||
}
|
||||
}
|
||||
|
||||
bool SkeletonBounds::aabbcontainsPoint(float x, float y)
|
||||
@ -147,80 +152,82 @@ namespace Spine
|
||||
return _minX < bounds._maxX && _maxX > bounds._minX && _minY < bounds._maxY && _maxY > bounds._minY;
|
||||
}
|
||||
|
||||
bool SkeletonBounds::containsPoint(Polygon polygon, float x, float y)
|
||||
bool SkeletonBounds::containsPoint(Polygon* polygon, float x, float y)
|
||||
{
|
||||
// float[] vertices = polygon.Vertices;
|
||||
// int nn = polygon.Count;
|
||||
//
|
||||
// int prevIndex = nn - 2;
|
||||
Vector<float>& vertices = polygon->_vertices;
|
||||
int nn = polygon->_count;
|
||||
|
||||
int prevIndex = nn - 2;
|
||||
bool inside = false;
|
||||
// for (int ii = 0; ii < nn; ii += 2)
|
||||
// {
|
||||
// float vertexY = vertices[ii + 1];
|
||||
// float prevY = vertices[prevIndex + 1];
|
||||
// if ((vertexY < y && prevY >= y) || (prevY < y && vertexY >= y))
|
||||
// {
|
||||
// float vertexX = vertices[ii];
|
||||
// if (vertexX + (y - vertexY) / (prevY - vertexY) * (vertices[prevIndex] - vertexX) < x)
|
||||
// {
|
||||
// inside = !inside;
|
||||
// }
|
||||
// }
|
||||
// prevIndex = ii;
|
||||
// }
|
||||
for (int ii = 0; ii < nn; ii += 2)
|
||||
{
|
||||
float vertexY = vertices[ii + 1];
|
||||
float prevY = vertices[prevIndex + 1];
|
||||
if ((vertexY < y && prevY >= y) || (prevY < y && vertexY >= y))
|
||||
{
|
||||
float vertexX = vertices[ii];
|
||||
if (vertexX + (y - vertexY) / (prevY - vertexY) * (vertices[prevIndex] - vertexX) < x)
|
||||
{
|
||||
inside = !inside;
|
||||
}
|
||||
}
|
||||
prevIndex = ii;
|
||||
}
|
||||
return inside;
|
||||
}
|
||||
|
||||
BoundingBoxAttachment* SkeletonBounds::containsPoint(float x, float y)
|
||||
{
|
||||
// for (int i = 0, n = _polygons.size(); i < n; ++i)
|
||||
// {
|
||||
// if (containsPoint(_polygons[i], x, y))
|
||||
// {
|
||||
// return _boundingBoxes[i];
|
||||
// }
|
||||
// }
|
||||
for (int i = 0, n = static_cast<int>(_polygons.size()); i < n; ++i)
|
||||
{
|
||||
if (containsPoint(_polygons[i], x, y))
|
||||
{
|
||||
return _boundingBoxes[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BoundingBoxAttachment* SkeletonBounds::intersectsSegment(float x1, float y1, float x2, float y2)
|
||||
{
|
||||
// for (int i = 0, n = _polygons.size(); i < n; ++i)
|
||||
// {
|
||||
// if (intersectsSegment(_polygons[i], x1, y1, x2, y2))
|
||||
// {
|
||||
// return _boundingBoxes[i];
|
||||
// }
|
||||
// }
|
||||
for (int i = 0, n = static_cast<int>(_polygons.size()); i < n; ++i)
|
||||
{
|
||||
if (intersectsSegment(_polygons[i], x1, y1, x2, y2))
|
||||
{
|
||||
return _boundingBoxes[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool SkeletonBounds::intersectsSegment(Polygon* polygon, float x1, float y1, float x2, float y2)
|
||||
{
|
||||
// Vector<float>& vertices = polygon->_vertices;
|
||||
// int nn = polygon.Count;
|
||||
//
|
||||
// float width12 = x1 - x2, height12 = y1 - y2;
|
||||
// float det1 = x1 * y2 - y1 * x2;
|
||||
// float x3 = vertices[nn - 2], y3 = vertices[nn - 1];
|
||||
// for (int ii = 0; ii < nn; ii += 2)
|
||||
// {
|
||||
// float x4 = vertices[ii], y4 = vertices[ii + 1];
|
||||
// float det2 = x3 * y4 - y3 * x4;
|
||||
// float width34 = x3 - x4, height34 = y3 - y4;
|
||||
// float det3 = width12 * height34 - height12 * width34;
|
||||
// float x = (det1 * width34 - width12 * det2) / det3;
|
||||
// if (((x >= x3 && x <= x4) || (x >= x4 && x <= x3)) && ((x >= x1 && x <= x2) || (x >= x2 && x <= x1)))
|
||||
// {
|
||||
// float y = (det1 * height34 - height12 * det2) / det3;
|
||||
// if (((y >= y3 && y <= y4) || (y >= y4 && y <= y3)) && ((y >= y1 && y <= y2) || (y >= y2 && y <= y1)))
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// x3 = x4;
|
||||
// y3 = y4;
|
||||
// }
|
||||
Vector<float>& vertices = polygon->_vertices;
|
||||
int nn = polygon->_count;
|
||||
|
||||
float width12 = x1 - x2, height12 = y1 - y2;
|
||||
float det1 = x1 * y2 - y1 * x2;
|
||||
float x3 = vertices[nn - 2], y3 = vertices[nn - 1];
|
||||
for (int ii = 0; ii < nn; ii += 2)
|
||||
{
|
||||
float x4 = vertices[ii], y4 = vertices[ii + 1];
|
||||
float det2 = x3 * y4 - y3 * x4;
|
||||
float width34 = x3 - x4, height34 = y3 - y4;
|
||||
float det3 = width12 * height34 - height12 * width34;
|
||||
float x = (det1 * width34 - width12 * det2) / det3;
|
||||
if (((x >= x3 && x <= x4) || (x >= x4 && x <= x3)) && ((x >= x1 && x <= x2) || (x >= x2 && x <= x1)))
|
||||
{
|
||||
float y = (det1 * height34 - height12 * det2) / det3;
|
||||
if (((y >= y3 && y <= y4) || (y >= y4 && y <= y3)) && ((y >= y1 && y <= y2) || (y >= y2 && y <= y1)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
x3 = x4;
|
||||
y3 = y4;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -243,25 +250,29 @@ namespace Spine
|
||||
|
||||
void SkeletonBounds::aabbCompute()
|
||||
{
|
||||
// float minX = int.MaxValue, minY = int.MaxValue, maxX = int.MinValue, maxY = int.MinValue;
|
||||
// for (int i = 0, n = _polygons.size(); i < n; i++)
|
||||
// {
|
||||
// Polygon* polygon = _polygons[i];
|
||||
// Vector<float>& vertices = polygon->_vertices;
|
||||
// for (int ii = 0, nn = polygon.Count; ii < nn; ii += 2)
|
||||
// {
|
||||
// float x = vertices[ii];
|
||||
// float y = vertices[ii + 1];
|
||||
// minX = Math.Min(minX, x);
|
||||
// minY = Math.Min(minY, y);
|
||||
// maxX = Math.Max(maxX, x);
|
||||
// maxY = Math.Max(maxY, y);
|
||||
// }
|
||||
// }
|
||||
// _minX = minX;
|
||||
// _minY = minY;
|
||||
// _maxX = maxX;
|
||||
// _maxY = maxY;
|
||||
float minX = std::numeric_limits<int>::min();
|
||||
float minY = std::numeric_limits<int>::min();
|
||||
float maxX = std::numeric_limits<int>::max();
|
||||
float maxY = std::numeric_limits<int>::max();
|
||||
|
||||
for (int i = 0, n = static_cast<int>(_polygons.size()); i < n; ++i)
|
||||
{
|
||||
Polygon* polygon = _polygons[i];
|
||||
Vector<float>& vertices = polygon->_vertices;
|
||||
for (int ii = 0, nn = polygon->_count; ii < nn; ii += 2)
|
||||
{
|
||||
float x = vertices[ii];
|
||||
float y = vertices[ii + 1];
|
||||
minX = MIN(minX, x);
|
||||
minY = MIN(minY, y);
|
||||
maxX = MAX(maxX, x);
|
||||
maxY = MAX(maxY, y);
|
||||
}
|
||||
}
|
||||
_minX = minX;
|
||||
_minY = minY;
|
||||
_maxX = maxX;
|
||||
_maxY = maxY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -45,19 +45,28 @@ namespace Spine
|
||||
|
||||
int SkeletonClipping::clipStart(Slot& slot, ClippingAttachment* clip)
|
||||
{
|
||||
// if (clipAttachment != NULL) return 0;
|
||||
// clipAttachment = clip;
|
||||
//
|
||||
// int n = clip.worldVerticesLength;
|
||||
// float[] vertices = clippingPolygon.Resize(n).Items;
|
||||
// clip.ComputeWorldVertices(slot, 0, n, vertices, 0, 2);
|
||||
// makeClockwise(clippingPolygon);
|
||||
// clippingPolygons = triangulator.Decompose(clippingPolygon, triangulator.Triangulate(clippingPolygon));
|
||||
// foreach (var polygon in clippingPolygons) {
|
||||
// makeClockwise(polygon);
|
||||
// polygon.push_back(polygon.Items[0]);
|
||||
// polygon.push_back(polygon.Items[1]);
|
||||
// }
|
||||
if (_clipAttachment != NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
_clipAttachment = clip;
|
||||
|
||||
int n = clip->getWorldVerticesLength();
|
||||
_clippingPolygon.reserve(n);
|
||||
clip->computeWorldVertices(slot, 0, n, _clippingPolygon, 0, 2);
|
||||
makeClockwise(_clippingPolygon);
|
||||
_clippingPolygons = _triangulator.decompose(_clippingPolygon, _triangulator.triangulate(_clippingPolygon));
|
||||
|
||||
for (Vector<float>** i = _clippingPolygons.begin(); i != _clippingPolygons.end(); ++i)
|
||||
{
|
||||
Vector<float>* polygonP = (*i);
|
||||
Vector<float>& polygon = *polygonP;
|
||||
makeClockwise(polygon);
|
||||
polygon.push_back(polygon[0]);
|
||||
polygon.push_back(polygon[1]);
|
||||
}
|
||||
|
||||
return static_cast<int>(_clippingPolygons.size());
|
||||
}
|
||||
|
||||
@ -85,34 +94,41 @@ namespace Spine
|
||||
|
||||
void SkeletonClipping::clipTriangles(Vector<float>& vertices, int verticesLength, Vector<int>& triangles, int trianglesLength, Vector<float>& uvs)
|
||||
{
|
||||
// Vector<float> clipOutput = _clipOutput, clippedVertices = _clippedVertices;
|
||||
// var clippedTriangles = _clippedTriangles;
|
||||
// var polygons = clippingPolygons.Items;
|
||||
// int polygonsCount = clippingPolygons.Count;
|
||||
//
|
||||
// int index = 0;
|
||||
// clippedVertices.Clear();
|
||||
// clippedUVs.Clear();
|
||||
// clippedTriangles.Clear();
|
||||
// //outer:
|
||||
// for (int i = 0; i < trianglesLength; i += 3) {
|
||||
// int vertexOffset = triangles[i] << 1;
|
||||
// float x1 = vertices[vertexOffset], y1 = vertices[vertexOffset + 1];
|
||||
// float u1 = uvs[vertexOffset], v1 = uvs[vertexOffset + 1];
|
||||
//
|
||||
// vertexOffset = triangles[i + 1] << 1;
|
||||
// float x2 = vertices[vertexOffset], y2 = vertices[vertexOffset + 1];
|
||||
// float u2 = uvs[vertexOffset], v2 = uvs[vertexOffset + 1];
|
||||
//
|
||||
// vertexOffset = triangles[i + 2] << 1;
|
||||
// float x3 = vertices[vertexOffset], y3 = vertices[vertexOffset + 1];
|
||||
// float u3 = uvs[vertexOffset], v3 = uvs[vertexOffset + 1];
|
||||
//
|
||||
// for (int p = 0; p < polygonsCount; p++) {
|
||||
// int s = clippedVertices.Count;
|
||||
// if (clip(x1, y1, x2, y2, x3, y3, polygons[p], clipOutput)) {
|
||||
Vector<float>& clipOutput = _clipOutput, clippedVertices = _clippedVertices;
|
||||
Vector<int>& clippedTriangles = _clippedTriangles;
|
||||
Vector< Vector<float>* >& polygons = _clippingPolygons;
|
||||
int polygonsCount = _clippingPolygons.size();
|
||||
|
||||
int index = 0;
|
||||
clippedVertices.clear();
|
||||
_clippedUVs.clear();
|
||||
clippedTriangles.clear();
|
||||
|
||||
//outer:
|
||||
for (int i = 0; i < trianglesLength; i += 3)
|
||||
{
|
||||
int vertexOffset = triangles[i] << 1;
|
||||
float x1 = vertices[vertexOffset], y1 = vertices[vertexOffset + 1];
|
||||
float u1 = uvs[vertexOffset], v1 = uvs[vertexOffset + 1];
|
||||
|
||||
vertexOffset = triangles[i + 1] << 1;
|
||||
float x2 = vertices[vertexOffset], y2 = vertices[vertexOffset + 1];
|
||||
float u2 = uvs[vertexOffset], v2 = uvs[vertexOffset + 1];
|
||||
|
||||
vertexOffset = triangles[i + 2] << 1;
|
||||
float x3 = vertices[vertexOffset], y3 = vertices[vertexOffset + 1];
|
||||
float u3 = uvs[vertexOffset], v3 = uvs[vertexOffset + 1];
|
||||
|
||||
for (int p = 0; p < polygonsCount; p++)
|
||||
{
|
||||
int s = clippedVertices.size();
|
||||
// if (clip(x1, y1, x2, y2, x3, y3, polygons[p], clipOutput))
|
||||
// {
|
||||
// int clipOutputLength = clipOutput.Count;
|
||||
// if (clipOutputLength == 0) continue;
|
||||
// if (clipOutputLength == 0)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
// float d0 = y2 - y3, d1 = x3 - x2, d2 = x1 - x3, d4 = y3 - y1;
|
||||
// float d = 1 / (d0 * d2 + d1 * (y1 - y3));
|
||||
//
|
||||
@ -120,7 +136,8 @@ namespace Spine
|
||||
// float[] clipOutputItems = clipOutput.Items;
|
||||
// float[] clippedVerticesItems = clippedVertices.Resize(s + clipOutputCount * 2).Items;
|
||||
// float[] clippedUVsItems = clippedUVs.Resize(s + clipOutputCount * 2).Items;
|
||||
// for (int ii = 0; ii < clipOutputLength; ii += 2) {
|
||||
// for (int ii = 0; ii < clipOutputLength; ii += 2)
|
||||
// {
|
||||
// float x = clipOutputItems[ii], y = clipOutputItems[ii + 1];
|
||||
// clippedVerticesItems[s] = x;
|
||||
// clippedVerticesItems[s + 1] = y;
|
||||
@ -136,7 +153,8 @@ namespace Spine
|
||||
// s = clippedTriangles.Count;
|
||||
// int[] clippedTrianglesItems = clippedTriangles.Resize(s + 3 * (clipOutputCount - 2)).Items;
|
||||
// clipOutputCount--;
|
||||
// for (int ii = 1; ii < clipOutputCount; ii++) {
|
||||
// for (int ii = 1; ii < clipOutputCount; ii++)
|
||||
// {
|
||||
// clippedTrianglesItems[s] = index;
|
||||
// clippedTrianglesItems[s + 1] = index + ii;
|
||||
// clippedTrianglesItems[s + 2] = index + ii + 1;
|
||||
@ -144,7 +162,8 @@ namespace Spine
|
||||
// }
|
||||
// index += clipOutputCount + 1;
|
||||
// }
|
||||
// else {
|
||||
// else
|
||||
// {
|
||||
// float[] clippedVerticesItems = clippedVertices.Resize(s + 3 * 2).Items;
|
||||
// float[] clippedUVsItems = clippedUVs.Resize(s + 3 * 2).Items;
|
||||
// clippedVerticesItems[s] = x1;
|
||||
@ -169,8 +188,8 @@ namespace Spine
|
||||
// index += 3;
|
||||
// break; //continue outer;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool SkeletonClipping::isClipping()
|
||||
@ -180,15 +199,18 @@ namespace Spine
|
||||
|
||||
bool SkeletonClipping::clip(float x1, float y1, float x2, float y2, float x3, float y3, Vector<float>& clippingArea, Vector<float>& output)
|
||||
{
|
||||
// var originalOutput = output;
|
||||
Vector<float> originalOutput = output;
|
||||
bool clipped = false;
|
||||
//
|
||||
// // Avoid copy at the end.
|
||||
// Vector<float> input = NULL;
|
||||
// if (clippingArea.Count % 4 >= 2) {
|
||||
// if (clippingArea.Count % 4 >= 2)
|
||||
// {
|
||||
// input = output;
|
||||
// output = scratch;
|
||||
// } else {
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// input = scratch;
|
||||
// }
|
||||
//
|
||||
@ -205,19 +227,24 @@ namespace Spine
|
||||
//
|
||||
// Vector<float> clippingVertices = clippingArea.Items;
|
||||
// int clippingVerticesLast = clippingArea.Count - 4;
|
||||
// for (int i = 0; ; i += 2) {
|
||||
// for (int i = 0; ; i += 2)
|
||||
// {
|
||||
// float edgeX = clippingVertices[i], edgeY = clippingVertices[i + 1];
|
||||
// float edgeX2 = clippingVertices[i + 2], edgeY2 = clippingVertices[i + 3];
|
||||
// float deltaX = edgeX - edgeX2, deltaY = edgeY - edgeY2;
|
||||
//
|
||||
// Vector<float> inputVertices = input.Items;
|
||||
// int inputVerticesLength = input.Count - 2, outputStart = output.Count;
|
||||
// for (int ii = 0; ii < inputVerticesLength; ii += 2) {
|
||||
// for (int ii = 0; ii < inputVerticesLength; ii += 2)
|
||||
// {
|
||||
// float inputX = inputVertices[ii], inputY = inputVertices[ii + 1];
|
||||
// float inputX2 = inputVertices[ii + 2], inputY2 = inputVertices[ii + 3];
|
||||
// bool side2 = deltaX * (inputY2 - edgeY2) - deltaY * (inputX2 - edgeX2) > 0;
|
||||
// if (deltaX * (inputY - edgeY2) - deltaY * (inputX - edgeX2) > 0) {
|
||||
// if (side2) { // v1 inside, v2 inside
|
||||
// if (deltaX * (inputY - edgeY2) - deltaY * (inputX - edgeX2) > 0)
|
||||
// {
|
||||
// if (side2)
|
||||
// {
|
||||
// // v1 inside, v2 inside
|
||||
// output.push_back(inputX2);
|
||||
// output.push_back(inputY2);
|
||||
// continue;
|
||||
@ -228,7 +255,9 @@ namespace Spine
|
||||
// output.push_back(edgeX + (edgeX2 - edgeX) * ua);
|
||||
// output.push_back(edgeY + (edgeY2 - edgeY) * ua);
|
||||
// }
|
||||
// else if (side2) { // v1 outside, v2 inside
|
||||
// else if (side2)
|
||||
// {
|
||||
// // v1 outside, v2 inside
|
||||
// float c0 = inputY2 - inputY, c2 = inputX2 - inputX;
|
||||
// float ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / (c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY));
|
||||
// output.push_back(edgeX + (edgeX2 - edgeX) * ua);
|
||||
@ -239,7 +268,9 @@ namespace Spine
|
||||
// clipped = true;
|
||||
// }
|
||||
//
|
||||
// if (outputStart == output.Count) { // All edges outside.
|
||||
// if (outputStart == output.Count)
|
||||
// {
|
||||
// // All edges outside.
|
||||
// originalOutput.Clear();
|
||||
// return true;
|
||||
// }
|
||||
@ -247,19 +278,26 @@ namespace Spine
|
||||
// output.push_back(output.Items[0]);
|
||||
// output.push_back(output.Items[1]);
|
||||
//
|
||||
// if (i == clippingVerticesLast) break;
|
||||
// if (i == clippingVerticesLast)
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
// var temp = output;
|
||||
// output = input;
|
||||
// output.Clear();
|
||||
// input = temp;
|
||||
// }
|
||||
//
|
||||
// if (originalOutput != output) {
|
||||
// if (originalOutput != output)
|
||||
// {
|
||||
// originalOutput.Clear();
|
||||
// for (int i = 0, n = output.Count - 2; i < n; i++) {
|
||||
// for (int i = 0, n = output.Count - 2; i < n; i++)
|
||||
// {
|
||||
// originalOutput.push_back(output.Items[i]);
|
||||
// }
|
||||
// } else {
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// originalOutput.Resize(originalOutput.Count - 2);
|
||||
// }
|
||||
|
||||
@ -268,26 +306,32 @@ namespace Spine
|
||||
|
||||
void SkeletonClipping::makeClockwise(Vector<float>& polygon)
|
||||
{
|
||||
// Vector<float> vertices = polygon.Items;
|
||||
// int verticeslength = polygon.Count;
|
||||
//
|
||||
// float area = vertices[verticeslength - 2] * vertices[1] - vertices[0] * vertices[verticeslength - 1], p1x, p1y, p2x, p2y;
|
||||
// for (int i = 0, n = verticeslength - 3; i < n; i += 2) {
|
||||
// p1x = vertices[i];
|
||||
// p1y = vertices[i + 1];
|
||||
// p2x = vertices[i + 2];
|
||||
// p2y = vertices[i + 3];
|
||||
// area += p1x * p2y - p2x * p1y;
|
||||
// }
|
||||
// if (area < 0) return;
|
||||
//
|
||||
// for (int i = 0, lastX = verticeslength - 2, n = verticeslength >> 1; i < n; i += 2) {
|
||||
// float x = vertices[i], y = vertices[i + 1];
|
||||
// int other = lastX - i;
|
||||
// vertices[i] = vertices[other];
|
||||
// vertices[i + 1] = vertices[other + 1];
|
||||
// vertices[other] = x;
|
||||
// vertices[other + 1] = y;
|
||||
// }
|
||||
int verticeslength = static_cast<int>(polygon.size());
|
||||
|
||||
float area = polygon[verticeslength - 2] * polygon[1] - polygon[0] * polygon[verticeslength - 1], p1x, p1y, p2x, p2y;
|
||||
|
||||
for (int i = 0, n = verticeslength - 3; i < n; i += 2)
|
||||
{
|
||||
p1x = polygon[i];
|
||||
p1y = polygon[i + 1];
|
||||
p2x = polygon[i + 2];
|
||||
p2y = polygon[i + 3];
|
||||
area += p1x * p2y - p2x * p1y;
|
||||
}
|
||||
|
||||
if (area < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0, lastX = verticeslength - 2, n = verticeslength >> 1; i < n; i += 2)
|
||||
{
|
||||
float x = polygon[i], y = polygon[i + 1];
|
||||
int other = lastX - i;
|
||||
polygon[i] = polygon[other];
|
||||
polygon[i + 1] = polygon[other + 1];
|
||||
polygon[other] = x;
|
||||
polygon[other + 1] = y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL_NOPARENT(Timeline);
|
||||
RTTI_IMPL_NOPARENT(Timeline);
|
||||
|
||||
Timeline::Timeline()
|
||||
{
|
||||
|
||||
@ -39,7 +39,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(TransformConstraint, Constraint);
|
||||
RTTI_IMPL(TransformConstraint, Constraint);
|
||||
|
||||
TransformConstraint::TransformConstraint(TransformConstraintData& data, Skeleton& skeleton) : Constraint(),
|
||||
_data(data),
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(TransformConstraintTimeline, CurveTimeline);
|
||||
RTTI_IMPL(TransformConstraintTimeline, CurveTimeline);
|
||||
|
||||
const int TransformConstraintTimeline::ENTRIES = 5;
|
||||
const int TransformConstraintTimeline::PREV_TIME = -5;
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(TranslateTimeline, CurveTimeline);
|
||||
RTTI_IMPL(TranslateTimeline, CurveTimeline);
|
||||
|
||||
void TranslateTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction)
|
||||
{
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(TwoColorTimeline, CurveTimeline);
|
||||
RTTI_IMPL(TwoColorTimeline, CurveTimeline);
|
||||
|
||||
void TwoColorTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction)
|
||||
{
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL_NOPARENT(Updatable);
|
||||
RTTI_IMPL_NOPARENT(Updatable);
|
||||
|
||||
Updatable::Updatable()
|
||||
{
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
|
||||
namespace Spine
|
||||
{
|
||||
SPINE_RTTI_IMPL(VertexAttachment, Attachment);
|
||||
RTTI_IMPL(VertexAttachment, Attachment);
|
||||
|
||||
VertexAttachment::VertexAttachment(std::string name) : Attachment(name), _worldVerticesLength(0), _id(getNextID())
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user