mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-15 03:21:35 +08:00
[cpp] 4.3 porting WIP
This commit is contained in:
parent
df2292460f
commit
ea8194a927
@ -30,20 +30,21 @@
|
||||
#ifndef Spine_Slot_h
|
||||
#define Spine_Slot_h
|
||||
|
||||
#include <spine/Posed.h>
|
||||
#include <spine/SlotData.h>
|
||||
#include <spine/SlotPose.h>
|
||||
#include <spine/Vector.h>
|
||||
#include <spine/SpineObject.h>
|
||||
#include <spine/Color.h>
|
||||
|
||||
namespace spine {
|
||||
class SlotData;
|
||||
|
||||
class Bone;
|
||||
|
||||
class Skeleton;
|
||||
|
||||
class Attachment;
|
||||
|
||||
class SP_API Slot : public SpineObject {
|
||||
/// Stores a slot's current pose. Slots organize attachments for Skeleton drawOrder purposes and provide a place to store
|
||||
/// state for an attachment. State cannot be stored in an attachment itself because attachments are stateless and may be shared
|
||||
/// across multiple skeletons.
|
||||
class SP_API Slot : public Posed<SlotData, SlotPose, SlotPose> {
|
||||
friend class VertexAttachment;
|
||||
|
||||
friend class Skeleton;
|
||||
@ -91,48 +92,17 @@ namespace spine {
|
||||
friend class TwoColorTimeline;
|
||||
|
||||
public:
|
||||
Slot(SlotData &data, Bone &bone);
|
||||
|
||||
void setToSetupPose();
|
||||
|
||||
SlotData &getData();
|
||||
Slot(SlotData &data, Skeleton &skeleton);
|
||||
|
||||
/// The bone this slot belongs to.
|
||||
Bone &getBone();
|
||||
|
||||
Skeleton &getSkeleton();
|
||||
|
||||
Color &getColor();
|
||||
|
||||
Color &getDarkColor();
|
||||
|
||||
bool hasDarkColor();
|
||||
|
||||
/// May be NULL.
|
||||
Attachment *getAttachment();
|
||||
|
||||
void setAttachment(Attachment *inValue);
|
||||
|
||||
int getAttachmentState();
|
||||
|
||||
void setAttachmentState(int state);
|
||||
|
||||
Vector<float> &getDeform();
|
||||
|
||||
int getSequenceIndex();
|
||||
|
||||
void setSequenceIndex(int index);
|
||||
void setupPose();
|
||||
|
||||
private:
|
||||
SlotData &_data;
|
||||
Bone &_bone;
|
||||
Skeleton &_skeleton;
|
||||
Color _color;
|
||||
Color _darkColor;
|
||||
bool _hasDarkColor;
|
||||
Attachment *_attachment;
|
||||
Bone &_bone;
|
||||
int _attachmentState;
|
||||
int _sequenceIndex;
|
||||
Vector<float> _deform;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -41,6 +41,7 @@ namespace spine {
|
||||
class VertexAttachment;
|
||||
|
||||
class SP_API SlotPose : public Pose<SlotPose> {
|
||||
friend class Slot;
|
||||
friend class SlotCurveTimeline;
|
||||
friend class RGBATimeline;
|
||||
friend class RGBTimeline;
|
||||
|
||||
@ -29,101 +29,40 @@
|
||||
|
||||
#include <spine/Slot.h>
|
||||
|
||||
#include <spine/Attachment.h>
|
||||
#include <spine/Bone.h>
|
||||
#include <spine/Skeleton.h>
|
||||
#include <spine/SlotData.h>
|
||||
#include <spine/VertexAttachment.h>
|
||||
#include <spine/SlotPose.h>
|
||||
#include <spine/Color.h>
|
||||
|
||||
using namespace spine;
|
||||
|
||||
Slot::Slot(SlotData &data, Bone &bone) : _data(data),
|
||||
_bone(bone),
|
||||
_skeleton(bone.getSkeleton()),
|
||||
_color(1, 1, 1, 1),
|
||||
_darkColor(0, 0, 0, 0),
|
||||
_hasDarkColor(data.hasDarkColor()),
|
||||
_attachment(NULL),
|
||||
_attachmentState(0),
|
||||
_sequenceIndex(0) {
|
||||
setToSetupPose();
|
||||
}
|
||||
|
||||
void Slot::setToSetupPose() {
|
||||
_color.set(_data.getColor());
|
||||
if (_hasDarkColor) _darkColor.set(_data.getDarkColor());
|
||||
|
||||
const String &attachmentName = _data.getAttachmentName();
|
||||
if (attachmentName.length() > 0) {
|
||||
_attachment = NULL;
|
||||
setAttachment(_skeleton.getAttachment(_data.getIndex(), attachmentName));
|
||||
} else {
|
||||
setAttachment(NULL);
|
||||
Slot::Slot(SlotData &data, Skeleton &skeleton) :
|
||||
Posed<SlotData, SlotPose, SlotPose>(data),
|
||||
_skeleton(skeleton),
|
||||
_bone(*skeleton.getBones()[data.getBoneData().getIndex()]),
|
||||
_attachmentState(0) {
|
||||
|
||||
if (data.getSetupPose().hasDarkColor()) {
|
||||
_pose._hasDarkColor = true;
|
||||
_constrained._hasDarkColor = true;
|
||||
}
|
||||
setupPose();
|
||||
}
|
||||
|
||||
SlotData &Slot::getData() {
|
||||
return _data;
|
||||
}
|
||||
|
||||
Bone &Slot::getBone() {
|
||||
return _bone;
|
||||
}
|
||||
|
||||
Skeleton &Slot::getSkeleton() {
|
||||
return _skeleton;
|
||||
}
|
||||
|
||||
Color &Slot::getColor() {
|
||||
return _color;
|
||||
}
|
||||
|
||||
Color &Slot::getDarkColor() {
|
||||
return _darkColor;
|
||||
}
|
||||
|
||||
bool Slot::hasDarkColor() {
|
||||
return _hasDarkColor;
|
||||
}
|
||||
|
||||
Attachment *Slot::getAttachment() {
|
||||
return _attachment;
|
||||
}
|
||||
|
||||
void Slot::setAttachment(Attachment *inValue) {
|
||||
if (_attachment == inValue) {
|
||||
return;
|
||||
void Slot::setupPose() {
|
||||
_pose.getColor().set(_data.getSetupPose().getColor());
|
||||
if (_pose.hasDarkColor()) _pose.getDarkColor().set(_data.getSetupPose().getDarkColor());
|
||||
_pose.setSequenceIndex(_data.getSetupPose().getSequenceIndex());
|
||||
if (_data.getAttachmentName().isEmpty())
|
||||
_pose.setAttachment(NULL);
|
||||
else {
|
||||
_pose.setAttachment(NULL);
|
||||
_pose.setAttachment(_skeleton.getAttachment(_data.getIndex(), _data.getAttachmentName()));
|
||||
}
|
||||
|
||||
if (!inValue ||
|
||||
!_attachment ||
|
||||
!inValue->getRTTI().instanceOf(VertexAttachment::rtti) ||
|
||||
!_attachment->getRTTI().instanceOf(VertexAttachment::rtti) ||
|
||||
static_cast<VertexAttachment *>(inValue)->getTimelineAttachment() !=
|
||||
static_cast<VertexAttachment *>(_attachment)->getTimelineAttachment()) {
|
||||
_deform.clear();
|
||||
}
|
||||
|
||||
_attachment = inValue;
|
||||
_sequenceIndex = -1;
|
||||
}
|
||||
|
||||
int Slot::getAttachmentState() {
|
||||
return _attachmentState;
|
||||
}
|
||||
|
||||
void Slot::setAttachmentState(int state) {
|
||||
_attachmentState = state;
|
||||
}
|
||||
|
||||
Vector<float> &Slot::getDeform() {
|
||||
return _deform;
|
||||
}
|
||||
|
||||
int Slot::getSequenceIndex() {
|
||||
return _sequenceIndex;
|
||||
}
|
||||
|
||||
void Slot::setSequenceIndex(int index) {
|
||||
_sequenceIndex = index;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user