mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[cpp] Formatting
This commit is contained in:
parent
62080c6c8b
commit
d03f535ed8
@ -96,6 +96,6 @@ void _spAttachmentLoader_setError(spAttachmentLoader *self, const char *error1,
|
|||||||
|
|
||||||
void _spAttachmentLoader_setUnknownTypeError(spAttachmentLoader *self, spAttachmentType type) {
|
void _spAttachmentLoader_setUnknownTypeError(spAttachmentLoader *self, spAttachmentType type) {
|
||||||
char buffer[16];
|
char buffer[16];
|
||||||
snprintf(buffer, 16,"%d", type);
|
snprintf(buffer, 16, "%d", type);
|
||||||
_spAttachmentLoader_setError(self, "Unknown attachment type: ", buffer);
|
_spAttachmentLoader_setError(self, "Unknown attachment type: ", buffer);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,7 +48,7 @@ BoneData::BoneData(int index, const String &name, BoneData *parent) : _index(ind
|
|||||||
_skinRequired(false),
|
_skinRequired(false),
|
||||||
_color(),
|
_color(),
|
||||||
_icon(),
|
_icon(),
|
||||||
_visible(true){
|
_visible(true) {
|
||||||
assert(index >= 0);
|
assert(index >= 0);
|
||||||
assert(_name.length() > 0);
|
assert(_name.length() > 0);
|
||||||
}
|
}
|
||||||
@ -164,4 +164,3 @@ bool BoneData::isVisible() {
|
|||||||
void BoneData::setVisible(bool inValue) {
|
void BoneData::setVisible(bool inValue) {
|
||||||
this->_visible = inValue;
|
this->_visible = inValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -155,7 +155,6 @@ float CurveTimeline1::getRelativeValue(float time, float alpha, MixBlend blend,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return current + value * alpha;
|
return current + value * alpha;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float CurveTimeline1::getAbsoluteValue(float time, float alpha, MixBlend blend, float current, float setup) {
|
float CurveTimeline1::getAbsoluteValue(float time, float alpha, MixBlend blend, float current, float setup) {
|
||||||
|
|||||||
@ -94,7 +94,6 @@ void PathConstraint::update(Physics) {
|
|||||||
float x = setupLength * bone._a;
|
float x = setupLength * bone._a;
|
||||||
float y = setupLength * bone._c;
|
float y = setupLength * bone._c;
|
||||||
_lengths[i] = MathUtil::sqrt(x * x + y * y);
|
_lengths[i] = MathUtil::sqrt(x * x + y * y);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (size_t i = 1; i < spacesCount; ++i) {
|
for (size_t i = 1; i < spacesCount; ++i) {
|
||||||
|
|||||||
@ -38,7 +38,7 @@ using namespace spine;
|
|||||||
|
|
||||||
RTTI_IMPL(PhysicsConstraint, Updatable)
|
RTTI_IMPL(PhysicsConstraint, Updatable)
|
||||||
|
|
||||||
PhysicsConstraint::PhysicsConstraint(PhysicsConstraintData& data, Skeleton& skeleton)
|
PhysicsConstraint::PhysicsConstraint(PhysicsConstraintData &data, Skeleton &skeleton)
|
||||||
: _data(data), _skeleton(skeleton) {
|
: _data(data), _skeleton(skeleton) {
|
||||||
_bone = skeleton.getBones()[data.getBone()->getIndex()];
|
_bone = skeleton.getBones()[data.getBone()->getIndex()];
|
||||||
|
|
||||||
@ -74,11 +74,11 @@ PhysicsConstraintData &PhysicsConstraint::getData() {
|
|||||||
return _data;
|
return _data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsConstraint::setBone(Bone* bone) {
|
void PhysicsConstraint::setBone(Bone *bone) {
|
||||||
_bone = bone;
|
_bone = bone;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bone* PhysicsConstraint::getBone(){
|
Bone *PhysicsConstraint::getBone() {
|
||||||
return _bone;
|
return _bone;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ void PhysicsConstraint::setInertia(float value) {
|
|||||||
_inertia = value;
|
_inertia = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraint::getInertia(){
|
float PhysicsConstraint::getInertia() {
|
||||||
return _inertia;
|
return _inertia;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ void PhysicsConstraint::setStrength(float value) {
|
|||||||
_strength = value;
|
_strength = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraint::getStrength(){
|
float PhysicsConstraint::getStrength() {
|
||||||
return _strength;
|
return _strength;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ void PhysicsConstraint::setDamping(float value) {
|
|||||||
_damping = value;
|
_damping = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraint::getDamping(){
|
float PhysicsConstraint::getDamping() {
|
||||||
return _damping;
|
return _damping;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ void PhysicsConstraint::setMassInverse(float value) {
|
|||||||
_massInverse = value;
|
_massInverse = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraint::getMassInverse(){
|
float PhysicsConstraint::getMassInverse() {
|
||||||
return _massInverse;
|
return _massInverse;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ void PhysicsConstraint::setWind(float value) {
|
|||||||
_wind = value;
|
_wind = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraint::getWind(){
|
float PhysicsConstraint::getWind() {
|
||||||
return _wind;
|
return _wind;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ void PhysicsConstraint::setGravity(float value) {
|
|||||||
_gravity = value;
|
_gravity = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraint::getGravity(){
|
float PhysicsConstraint::getGravity() {
|
||||||
return _gravity;
|
return _gravity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ void PhysicsConstraint::setMix(float value) {
|
|||||||
_mix = value;
|
_mix = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraint::getMix(){
|
float PhysicsConstraint::getMix() {
|
||||||
return _mix;
|
return _mix;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ void PhysicsConstraint::setReset(bool value) {
|
|||||||
_reset = value;
|
_reset = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PhysicsConstraint::getReset(){
|
bool PhysicsConstraint::getReset() {
|
||||||
return _reset;
|
return _reset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +150,7 @@ void PhysicsConstraint::setUx(float value) {
|
|||||||
_ux = value;
|
_ux = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraint::getUx(){
|
float PhysicsConstraint::getUx() {
|
||||||
return _ux;
|
return _ux;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ void PhysicsConstraint::setUy(float value) {
|
|||||||
_uy = value;
|
_uy = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraint::getUy(){
|
float PhysicsConstraint::getUy() {
|
||||||
return _uy;
|
return _uy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ void PhysicsConstraint::setCx(float value) {
|
|||||||
_cx = value;
|
_cx = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraint::getCx(){
|
float PhysicsConstraint::getCx() {
|
||||||
return _cx;
|
return _cx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ void PhysicsConstraint::setCy(float value) {
|
|||||||
_cy = value;
|
_cy = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraint::getCy(){
|
float PhysicsConstraint::getCy() {
|
||||||
return _cy;
|
return _cy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ void PhysicsConstraint::setTx(float value) {
|
|||||||
_tx = value;
|
_tx = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraint::getTx(){
|
float PhysicsConstraint::getTx() {
|
||||||
return _tx;
|
return _tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ void PhysicsConstraint::setTy(float value) {
|
|||||||
_ty = value;
|
_ty = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraint::getTy(){
|
float PhysicsConstraint::getTy() {
|
||||||
return _ty;
|
return _ty;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ void PhysicsConstraint::setXOffset(float value) {
|
|||||||
_xOffset = value;
|
_xOffset = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraint::getXOffset(){
|
float PhysicsConstraint::getXOffset() {
|
||||||
return _xOffset;
|
return _xOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ void PhysicsConstraint::setXVelocity(float value) {
|
|||||||
_xVelocity = value;
|
_xVelocity = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraint::getXVelocity(){
|
float PhysicsConstraint::getXVelocity() {
|
||||||
return _xVelocity;
|
return _xVelocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ void PhysicsConstraint::setYOffset(float value) {
|
|||||||
_yOffset = value;
|
_yOffset = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraint::getYOffset(){
|
float PhysicsConstraint::getYOffset() {
|
||||||
return _yOffset;
|
return _yOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ void PhysicsConstraint::setYVelocity(float value) {
|
|||||||
_yVelocity = value;
|
_yVelocity = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraint::getYVelocity(){
|
float PhysicsConstraint::getYVelocity() {
|
||||||
return _yVelocity;
|
return _yVelocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +230,7 @@ void PhysicsConstraint::setRotateOffset(float value) {
|
|||||||
_rotateOffset = value;
|
_rotateOffset = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraint::getRotateOffset(){
|
float PhysicsConstraint::getRotateOffset() {
|
||||||
return _rotateOffset;
|
return _rotateOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ void PhysicsConstraint::setRotateVelocity(float value) {
|
|||||||
_rotateVelocity = value;
|
_rotateVelocity = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraint::getRotateVelocity(){
|
float PhysicsConstraint::getRotateVelocity() {
|
||||||
return _rotateVelocity;
|
return _rotateVelocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,7 +246,7 @@ void PhysicsConstraint::setScaleOffset(float value) {
|
|||||||
_scaleOffset = value;
|
_scaleOffset = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraint::getScaleOffset(){
|
float PhysicsConstraint::getScaleOffset() {
|
||||||
return _scaleOffset;
|
return _scaleOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,7 +254,7 @@ void PhysicsConstraint::setScaleVelocity(float value) {
|
|||||||
_scaleVelocity = value;
|
_scaleVelocity = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraint::getScaleVelocity(){
|
float PhysicsConstraint::getScaleVelocity() {
|
||||||
return _scaleVelocity;
|
return _scaleVelocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,7 +262,7 @@ void PhysicsConstraint::setActive(bool value) {
|
|||||||
_active = value;
|
_active = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PhysicsConstraint::isActive(){
|
bool PhysicsConstraint::isActive() {
|
||||||
return _active;
|
return _active;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +270,7 @@ void PhysicsConstraint::setRemaining(float value) {
|
|||||||
_remaining = value;
|
_remaining = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraint::getRemaining(){
|
float PhysicsConstraint::getRemaining() {
|
||||||
return _remaining;
|
return _remaining;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ void PhysicsConstraint::setLastTime(float value) {
|
|||||||
_lastTime = value;
|
_lastTime = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraint::getLastTime(){
|
float PhysicsConstraint::getLastTime() {
|
||||||
return _lastTime;
|
return _lastTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,7 +314,7 @@ void PhysicsConstraint::update(Physics physics) {
|
|||||||
bool rotateOrShearX = _data._rotate > 0 || _data._shearX > 0;
|
bool rotateOrShearX = _data._rotate > 0 || _data._shearX > 0;
|
||||||
bool scaleX = _data._scaleX > 0;
|
bool scaleX = _data._scaleX > 0;
|
||||||
|
|
||||||
Bone* bone = _bone;
|
Bone *bone = _bone;
|
||||||
float l = bone->_data.getLength();
|
float l = bone->_data.getLength();
|
||||||
|
|
||||||
switch (physics) {
|
switch (physics) {
|
||||||
@ -389,7 +389,7 @@ void PhysicsConstraint::update(Physics physics) {
|
|||||||
if (remaining >= step) {
|
if (remaining >= step) {
|
||||||
float m = _massInverse * step, e = _strength;
|
float m = _massInverse * step, e = _strength;
|
||||||
float d = MathUtil::pow(_damping, 60 * step);
|
float d = MathUtil::pow(_damping, 60 * step);
|
||||||
while(true) {
|
while (true) {
|
||||||
remaining -= step;
|
remaining -= step;
|
||||||
if (scaleX) {
|
if (scaleX) {
|
||||||
_scaleVelocity += (_wind * c - _gravity * s - _scaleOffset * e) * m;
|
_scaleVelocity += (_wind * c - _gravity * s - _scaleOffset * e) * m;
|
||||||
@ -404,7 +404,7 @@ void PhysicsConstraint::update(Physics physics) {
|
|||||||
float r = _rotateOffset * mr + ca;
|
float r = _rotateOffset * mr + ca;
|
||||||
c = MathUtil::cos(r);
|
c = MathUtil::cos(r);
|
||||||
s = MathUtil::sin(r);
|
s = MathUtil::sin(r);
|
||||||
} else if (remaining < step) //
|
} else if (remaining < step)//
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,16 +42,15 @@ PhysicsConstraintData::PhysicsConstraintData(const String &name) : ConstraintDat
|
|||||||
_x(0), _y(0), _rotate(0), _scaleX(0), _shearX(0),
|
_x(0), _y(0), _rotate(0), _scaleX(0), _shearX(0),
|
||||||
_step(0), _inertia(0), _strength(0), _damping(0), _massInverse(0), _wind(0), _gravity(0), _mix(0),
|
_step(0), _inertia(0), _strength(0), _damping(0), _massInverse(0), _wind(0), _gravity(0), _mix(0),
|
||||||
_inertiaGlobal(false), _strengthGlobal(false), _dampingGlobal(false), _massGlobal(false),
|
_inertiaGlobal(false), _strengthGlobal(false), _dampingGlobal(false), _massGlobal(false),
|
||||||
_windGlobal(false), _gravityGlobal(false), _mixGlobal(false)
|
_windGlobal(false), _gravityGlobal(false), _mixGlobal(false) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PhysicsConstraintData::setBone(BoneData* bone) {
|
void PhysicsConstraintData::setBone(BoneData *bone) {
|
||||||
_bone = bone;
|
_bone = bone;
|
||||||
}
|
}
|
||||||
|
|
||||||
BoneData* PhysicsConstraintData::getBone() const {
|
BoneData *PhysicsConstraintData::getBone() const {
|
||||||
return _bone;
|
return _bone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -61,9 +61,9 @@ PhysicsConstraintTimeline::PhysicsConstraintTimeline(size_t frameCount, size_t b
|
|||||||
void PhysicsConstraintTimeline::apply(Skeleton &skeleton, float, float time, Vector<Event *> *,
|
void PhysicsConstraintTimeline::apply(Skeleton &skeleton, float, float time, Vector<Event *> *,
|
||||||
float alpha, MixBlend blend, MixDirection) {
|
float alpha, MixBlend blend, MixDirection) {
|
||||||
if (_constraintIndex == -1) {
|
if (_constraintIndex == -1) {
|
||||||
float value = time >= _frames[0] ?getCurveValue(time) : 0;
|
float value = time >= _frames[0] ? getCurveValue(time) : 0;
|
||||||
|
|
||||||
Vector<PhysicsConstraint*> &physicsConstraints = skeleton.getPhysicsConstraints();
|
Vector<PhysicsConstraint *> &physicsConstraints = skeleton.getPhysicsConstraints();
|
||||||
for (size_t i = 0; i < physicsConstraints.size(); i++) {
|
for (size_t i = 0; i < physicsConstraints.size(); i++) {
|
||||||
PhysicsConstraint *constraint = physicsConstraints[i];
|
PhysicsConstraint *constraint = physicsConstraints[i];
|
||||||
if (constraint->_active && global(constraint->_data))
|
if (constraint->_active && global(constraint->_data))
|
||||||
@ -82,10 +82,10 @@ void PhysicsConstraintResetTimeline::apply(Skeleton &skeleton, float lastTime, f
|
|||||||
if (!constraint->_active) return;
|
if (!constraint->_active) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastTime > time) { // Apply after lastTime for looped animations.
|
if (lastTime > time) {// Apply after lastTime for looped animations.
|
||||||
apply(skeleton, lastTime, FLT_MAX, nullptr, alpha, blend, direction);
|
apply(skeleton, lastTime, FLT_MAX, nullptr, alpha, blend, direction);
|
||||||
lastTime = -1;
|
lastTime = -1;
|
||||||
} else if (lastTime >= _frames[_frames.size() - 1]) // Last time is after last frame.
|
} else if (lastTime >= _frames[_frames.size() - 1])// Last time is after last frame.
|
||||||
return;
|
return;
|
||||||
if (time < _frames[0]) return;
|
if (time < _frames[0]) return;
|
||||||
|
|
||||||
|
|||||||
@ -62,7 +62,7 @@ Skeleton::Skeleton(SkeletonData *skeletonData) : _data(skeletonData),
|
|||||||
_scaleY(1),
|
_scaleY(1),
|
||||||
_x(0),
|
_x(0),
|
||||||
_y(0),
|
_y(0),
|
||||||
_time(0){
|
_time(0) {
|
||||||
_bones.ensureCapacity(_data->getBones().size());
|
_bones.ensureCapacity(_data->getBones().size());
|
||||||
for (size_t i = 0; i < _data->getBones().size(); ++i) {
|
for (size_t i = 0; i < _data->getBones().size(); ++i) {
|
||||||
BoneData *data = _data->getBones()[i];
|
BoneData *data = _data->getBones()[i];
|
||||||
@ -711,4 +711,3 @@ void Skeleton::setTime(float time) {
|
|||||||
void Skeleton::update(float delta) {
|
void Skeleton::update(float delta) {
|
||||||
_time += delta;
|
_time += delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user