mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-22 10:16:01 +08:00
Formatting
This commit is contained in:
parent
c83a0ba849
commit
3bb48dceb9
@ -37,7 +37,7 @@ BoneLocal::BoneLocal() : _x(0), _y(0), _rotation(0), _scaleX(1), _scaleY(1), _sh
|
||||
BoneLocal::~BoneLocal() {
|
||||
}
|
||||
|
||||
void BoneLocal::set(const BoneLocal& pose) {
|
||||
void BoneLocal::set(const BoneLocal &pose) {
|
||||
_x = pose._x;
|
||||
_y = pose._y;
|
||||
_rotation = pose._rotation;
|
||||
|
||||
@ -40,11 +40,11 @@ BonePose::BonePose() : _bone(nullptr), _a(1), _b(0), _worldX(0), _c(0), _d(1), _
|
||||
BonePose::~BonePose() {
|
||||
}
|
||||
|
||||
void BonePose::update(Skeleton& skeleton, Physics physics) {
|
||||
void BonePose::update(Skeleton &skeleton, Physics physics) {
|
||||
if (_world != skeleton.getUpdate()) updateWorldTransform(skeleton);
|
||||
}
|
||||
|
||||
void BonePose::updateWorldTransform(Skeleton& skeleton) {
|
||||
void BonePose::updateWorldTransform(Skeleton &skeleton) {
|
||||
if (_local == skeleton.getUpdate()) {
|
||||
updateLocalTransform(skeleton);
|
||||
} else {
|
||||
@ -64,7 +64,7 @@ void BonePose::updateWorldTransform(Skeleton& skeleton) {
|
||||
return;
|
||||
}
|
||||
|
||||
BonePose* parent = _bone->getParent()->getApplied();
|
||||
BonePose *parent = _bone->getParent()->getApplied();
|
||||
float pa = parent->_a, pb = parent->_b, pc = parent->_c, pd = parent->_d;
|
||||
_worldX = pa * _x + pb * _y + parent->_worldX;
|
||||
_worldY = pc * _x + pd * _y + parent->_worldY;
|
||||
@ -153,7 +153,7 @@ void BonePose::updateWorldTransform(Skeleton& skeleton) {
|
||||
_d *= skeleton.getScaleY();
|
||||
}
|
||||
|
||||
void BonePose::updateLocalTransform(Skeleton& skeleton) {
|
||||
void BonePose::updateLocalTransform(Skeleton &skeleton) {
|
||||
_local = 0;
|
||||
_world = skeleton.getUpdate();
|
||||
|
||||
@ -169,7 +169,7 @@ void BonePose::updateLocalTransform(Skeleton& skeleton) {
|
||||
return;
|
||||
}
|
||||
|
||||
BonePose* parent = _bone->getParent()->getApplied();
|
||||
BonePose *parent = _bone->getParent()->getApplied();
|
||||
float pa = parent->_a, pb = parent->_b, pc = parent->_c, pd = parent->_d;
|
||||
float pid = 1 / (pa * pd - pb * pc);
|
||||
float ia = pd * pid, ib = pb * pid, ic = pc * pid, id = pa * pid;
|
||||
@ -237,11 +237,11 @@ void BonePose::updateLocalTransform(Skeleton& skeleton) {
|
||||
}
|
||||
}
|
||||
|
||||
void BonePose::validateLocalTransform(Skeleton& skeleton) {
|
||||
void BonePose::validateLocalTransform(Skeleton &skeleton) {
|
||||
if (_local == skeleton.getUpdate()) updateLocalTransform(skeleton);
|
||||
}
|
||||
|
||||
void BonePose::modifyLocal(Skeleton& skeleton) {
|
||||
void BonePose::modifyLocal(Skeleton &skeleton) {
|
||||
if (_local == skeleton.getUpdate()) updateLocalTransform(skeleton);
|
||||
_world = 0;
|
||||
resetWorld(skeleton.getUpdate());
|
||||
@ -254,9 +254,9 @@ void BonePose::modifyWorld(int update) {
|
||||
}
|
||||
|
||||
void BonePose::resetWorld(int update) {
|
||||
Vector<Bone*>& children = _bone->getChildren();
|
||||
Vector<Bone *> &children = _bone->getChildren();
|
||||
for (int i = 0, n = children.size(); i < n; i++) {
|
||||
BonePose* child = children[i]->getApplied();
|
||||
BonePose *child = children[i]->getApplied();
|
||||
if (child->_world == update) {
|
||||
child->_world = 0;
|
||||
child->_local = 0;
|
||||
@ -265,19 +265,19 @@ void BonePose::resetWorld(int update) {
|
||||
}
|
||||
}
|
||||
|
||||
void BonePose::worldToLocal(float worldX, float worldY, float& outLocalX, float& outLocalY) {
|
||||
void BonePose::worldToLocal(float worldX, float worldY, float &outLocalX, float &outLocalY) {
|
||||
float det = _a * _d - _b * _c;
|
||||
float x = worldX - _worldX, y = worldY - _worldY;
|
||||
outLocalX = (x * _d - y * _b) / det;
|
||||
outLocalY = (y * _a - x * _c) / det;
|
||||
}
|
||||
|
||||
void BonePose::localToWorld(float localX, float localY, float& outWorldX, float& outWorldY) {
|
||||
void BonePose::localToWorld(float localX, float localY, float &outWorldX, float &outWorldY) {
|
||||
outWorldX = localX * _a + localY * _b + _worldX;
|
||||
outWorldY = localX * _c + localY * _d + _worldY;
|
||||
}
|
||||
|
||||
void BonePose::worldToParent(float worldX, float worldY, float& outParentX, float& outParentY) {
|
||||
void BonePose::worldToParent(float worldX, float worldY, float &outParentX, float &outParentY) {
|
||||
if (_bone == nullptr || _bone->getParent() == nullptr) {
|
||||
outParentX = worldX;
|
||||
outParentY = worldY;
|
||||
@ -286,7 +286,7 @@ void BonePose::worldToParent(float worldX, float worldY, float& outParentX, floa
|
||||
_bone->getParent()->getApplied()->worldToLocal(worldX, worldY, outParentX, outParentY);
|
||||
}
|
||||
|
||||
void BonePose::parentToWorld(float parentX, float parentY, float& outWorldX, float& outWorldY) {
|
||||
void BonePose::parentToWorld(float parentX, float parentY, float &outWorldX, float &outWorldY) {
|
||||
if (_bone == nullptr || _bone->getParent() == nullptr) {
|
||||
outWorldX = parentX;
|
||||
outWorldY = parentY;
|
||||
|
||||
@ -39,7 +39,7 @@ SlotPose::SlotPose() : _color(1, 1, 1, 1), _darkColor(0, 0, 0, 1), _hasDarkColor
|
||||
SlotPose::~SlotPose() {
|
||||
}
|
||||
|
||||
void SlotPose::set(const SlotPose& pose) {
|
||||
void SlotPose::set(const SlotPose &pose) {
|
||||
_color.set(pose._color);
|
||||
if (_hasDarkColor) _darkColor.set(pose._darkColor);
|
||||
_hasDarkColor = pose._hasDarkColor;
|
||||
@ -49,11 +49,11 @@ void SlotPose::set(const SlotPose& pose) {
|
||||
_deform.addAll(pose._deform);
|
||||
}
|
||||
|
||||
Color& SlotPose::getColor() {
|
||||
Color &SlotPose::getColor() {
|
||||
return _color;
|
||||
}
|
||||
|
||||
Color& SlotPose::getDarkColor() {
|
||||
Color &SlotPose::getDarkColor() {
|
||||
return _darkColor;
|
||||
}
|
||||
|
||||
@ -65,17 +65,17 @@ void SlotPose::setHasDarkColor(bool hasDarkColor) {
|
||||
_hasDarkColor = hasDarkColor;
|
||||
}
|
||||
|
||||
Attachment* SlotPose::getAttachment() {
|
||||
Attachment *SlotPose::getAttachment() {
|
||||
return _attachment;
|
||||
}
|
||||
|
||||
void SlotPose::setAttachment(Attachment* attachment) {
|
||||
void SlotPose::setAttachment(Attachment *attachment) {
|
||||
if (_attachment == attachment) return;
|
||||
|
||||
if (attachment == nullptr || _attachment == nullptr ||
|
||||
!attachment->getRTTI().instanceOf(VertexAttachment::rtti) ||
|
||||
!_attachment->getRTTI().instanceOf(VertexAttachment::rtti) ||
|
||||
((VertexAttachment*)attachment)->getTimelineAttachment() != ((VertexAttachment*)_attachment)->getTimelineAttachment()) {
|
||||
((VertexAttachment *) attachment)->getTimelineAttachment() != ((VertexAttachment *) _attachment)->getTimelineAttachment()) {
|
||||
_deform.clear();
|
||||
}
|
||||
|
||||
@ -91,6 +91,6 @@ void SlotPose::setSequenceIndex(int sequenceIndex) {
|
||||
_sequenceIndex = sequenceIndex;
|
||||
}
|
||||
|
||||
Vector<float>& SlotPose::getDeform() {
|
||||
Vector<float> &SlotPose::getDeform() {
|
||||
return _deform;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user