Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions cocos/spine/lib/spine-core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,30 @@
delete();
}

/**
* @version 4.2
*/
class SPVectorPhysicsConstraintPtr {
size(): number;
get(index: number): PhysicsConstraint;
delete();
}

/**
* @version 4.2
*/
class SPVectorPhysicsConstraintDataPtr {
size(): number;
get(index: number): PhysicsConstraintData;
delete();
}

class Animation {
constructor(name: string, timelines: Array<Timeline>, duration: number);
duration: number;
name: string;
timelines: Array<Timeline>;
apply(skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;

Check warning on line 68 in cocos/spine/lib/spine-core.d.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

This line has a length of 166. Maximum allowed is 150
hasTimeline(id: number): boolean;
}

Expand All @@ -56,7 +74,7 @@
* @version 4.2
*/
frames: ArrayLike<number>;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;

Check warning on line 77 in cocos/spine/lib/spine-core.d.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

This line has a length of 151. Maximum allowed is 150
/**
* @version 4.2
*/
Expand Down Expand Up @@ -138,7 +156,7 @@
getCurveType(frameIndex: number): number;
setCurve(frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void;
getCurvePercent(frameIndex: number, percent: number): number;
abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;

Check warning on line 159 in cocos/spine/lib/spine-core.d.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

This line has a length of 160. Maximum allowed is 150
}
class RotateTimeline extends CurveTimeline {
static ENTRIES: number;
Expand All @@ -156,7 +174,7 @@
*/
getPropertyId(): number;
setFrame(frameIndex: number, time: number, degrees: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;

Check warning on line 177 in cocos/spine/lib/spine-core.d.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

This line has a length of 151. Maximum allowed is 150
}
class TranslateTimeline extends CurveTimeline {
static readonly ENTRIES: number;
Expand All @@ -170,12 +188,12 @@
*/
getPropertyId(): number;
setFrame(frameIndex: number, time: number, x: number, y: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;

Check warning on line 191 in cocos/spine/lib/spine-core.d.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

This line has a length of 151. Maximum allowed is 150
}
class ScaleTimeline extends TranslateTimeline {
constructor(frameCount: number);
getPropertyId(): number;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;

Check warning on line 196 in cocos/spine/lib/spine-core.d.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

This line has a length of 151. Maximum allowed is 150
}
class ShearTimeline extends TranslateTimeline {
constructor(frameCount: number);
Expand All @@ -183,7 +201,7 @@
* @version 3.8, deprecated in 4.2
*/
getPropertyId(): number;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;

Check warning on line 204 in cocos/spine/lib/spine-core.d.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

This line has a length of 151. Maximum allowed is 150
}

/**
Expand All @@ -198,7 +216,7 @@
getSlotIndex(): number;
setSlotIndex(inValue: number): void;
setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;

Check warning on line 219 in cocos/spine/lib/spine-core.d.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

This line has a length of 151. Maximum allowed is 150
}

/**
Expand All @@ -213,7 +231,7 @@
getSlotIndex(): number;
setSlotIndex(inValue: number): void;
setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number, r2: number, g2: number, b2: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;

Check warning on line 234 in cocos/spine/lib/spine-core.d.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

This line has a length of 151. Maximum allowed is 150
}

/**
Expand All @@ -227,7 +245,7 @@
getPropertyId(): number;
setSlotIndex(inValue: number): void;
setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;

Check warning on line 248 in cocos/spine/lib/spine-core.d.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

This line has a length of 151. Maximum allowed is 150
}

class AttachmentTimeline implements Timeline {
Expand Down Expand Up @@ -708,6 +726,10 @@
ikConstraints: Array<IkConstraint>;
transformConstraints: Array<TransformConstraint>;
pathConstraints: Array<PathConstraint>;
/**
* @version 4.2
*/
physicsConstraints: Array<PhysicsConstraint>;
_updateCache: Updatable[];
skin: Skin;
color: Color;
Expand Down Expand Up @@ -735,8 +757,24 @@
findIkConstraint(constraintName: string): IkConstraint;
findTransformConstraint(constraintName: string): TransformConstraint;
findPathConstraint(constraintName: string): PathConstraint;
/**
* @version 4.2
*/
findPhysicsConstraint(constraintName: string): PhysicsConstraint;
/**
* @version 4.2
*/
getPhysicsConstraints(): SPVectorPhysicsConstraintPtr;
//getBounds(offset: Vector2, size: Vector2, temp?: Array<number>): void;
update(delta: number): void;
/**
* @version 4.2
*/
updateWorldTransform(physics: Physics): void;
/**
* @version 4.2
*/
updateWorldTransform(physics: Physics, parent: Bone): void;
}
class SkeletonBinary {
static AttachmentTypeValues: number[];
Expand Down Expand Up @@ -812,6 +850,10 @@
ikConstraints: IkConstraintData[];
transformConstraints: TransformConstraintData[];
pathConstraints: PathConstraintData[];
/**
* @version 4.2
*/
physicsConstraints: PhysicsConstraintData[];
x: number;
y: number;
width: number;
Expand All @@ -835,6 +877,14 @@
findTransformConstraint(constraintName: string): TransformConstraintData;
findPathConstraint(constraintName: string): PathConstraintData;
findPathConstraintIndex(pathConstraintName: string): number;
/**
* @version 4.2
*/
findPhysicsConstraint(constraintName: string): PhysicsConstraintData;
/**
* @version 4.2
*/
getPhysicsConstraints(): SPVectorPhysicsConstraintDataPtr;
}
class SkeletonJson {
attachmentLoader: AttachmentLoader;
Expand Down Expand Up @@ -920,7 +970,7 @@
MipMapNearestNearest = 9984,
MipMapLinearNearest = 9985,
MipMapNearestLinear = 9986,
MipMapLinearLinear = 9987

Check failure on line 973 in cocos/spine/lib/spine-core.d.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Duplicate enum member value 9987
}
enum TextureWrap {
MirroredRepeat = 33648,
Expand Down Expand Up @@ -1005,6 +1055,82 @@
local: boolean;
constructor(name: string);
}
/**
* @version 4.2
*/
enum Physics {
none = 0,
reset = 1,
update = 2,
pose = 3
}
/**
* @version 4.2
*/
class PhysicsConstraint implements Updatable {
data: PhysicsConstraintData;
bone: Bone;
inertia: number;
strength: number;
damping: number;
massInverse: number;
wind: number;
gravity: number;
mix: number;
_reset: boolean;
ux: number;
uy: number;
cx: number;
cy: number;
tx: number;
ty: number;
xOffset: number;
xVelocity: number;
yOffset: number;
yVelocity: number;
rotateOffset: number;
rotateVelocity: number;
scaleOffset: number;
scaleVelocity: number;
remaining: number;
lastTime: number;
active: boolean;
constructor(data: PhysicsConstraintData, skeleton: Skeleton);
isActive(): boolean;
reset(): void;
setToSetupPose(): void;
update(): void;
translate(x: number, y: number): void;
rotate(x: number, y: number, degrees: number): void;
}
/**
* @version 4.2
*/
class PhysicsConstraintData extends ConstraintData {
bone: BoneData;
x: number;
y: number;
rotate: number;
scaleX: number;
shearX: number;
limit: number;
step: number;
inertia: number;
strength: number;
damping: number;
massInverse: number;
wind: number;
gravity: number;
mix: number;
inertiaGlobal: boolean;
strengthGlobal: boolean;
dampingGlobal: boolean;
massGlobal: boolean;
windGlobal: boolean;
gravityGlobal: boolean;
mixGlobal: boolean;
constructor(name: string);
}
class Triangulator {
private convexPolygons;
private convexPolygonsIndices;
Expand Down
72 changes: 69 additions & 3 deletions native/cocos/editor-support/spine-wasm/4.2/spine-type-export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ using SPVectorIkConstraintPtr = Vector<IkConstraint*>;
using SPVectorIkConstraintDataPtr = Vector<IkConstraintData*>;
using SPVectorTransformConstraintPtr = Vector<TransformConstraint*>;
using SPVectorPathConstraintPtr = Vector<PathConstraint*>;
using SPVectorPhysicsConstraintPtr = Vector<PhysicsConstraint*>;
using SPVectorTimelinePtr = Vector<Timeline*>;
using SPVectorTrackEntryPtr = Vector<TrackEntry*>;
using SPVectorUpdatablePtr = Vector<Updatable*>;
Expand Down Expand Up @@ -207,6 +208,8 @@ DEFINE_ALLOW_RAW_POINTER(TrackEntry)
DEFINE_ALLOW_RAW_POINTER(IkConstraintData)
DEFINE_ALLOW_RAW_POINTER(PathConstraintData)
DEFINE_ALLOW_RAW_POINTER(TransformConstraintData)
DEFINE_ALLOW_RAW_POINTER(PhysicsConstraintData)
DEFINE_ALLOW_RAW_POINTER(PhysicsConstraint)
DEFINE_ALLOW_RAW_POINTER(SPVectorUnsignedShort)
DEFINE_ALLOW_RAW_POINTER(SPVectorFloat)
DEFINE_ALLOW_RAW_POINTER(SPVectorEventPtr)
Expand Down Expand Up @@ -516,7 +519,7 @@ EMSCRIPTEN_BINDINGS(spine) {
REGISTER_SPINE_ENUM(TextureFilter);
REGISTER_SPINE_ENUM(TextureWrap);
REGISTER_SPINE_ENUM(AttachmentType);

REGISTER_SPINE_ENUM(Physics);

REGISTER_SPINE_VECTOR(SPVectorDebugShape, false);

Expand Down Expand Up @@ -544,7 +547,9 @@ EMSCRIPTEN_BINDINGS(spine) {
REGISTER_SPINE_VECTOR(SPVectorIkConstraintDataPtr, false);
REGISTER_SPINE_VECTOR(SPVectorTransformConstraintPtr, false);
REGISTER_SPINE_VECTOR(SPVectorPathConstraintPtr, false);
REGISTER_SPINE_VECTOR(SPVectorTimelinePtr, true); // .set used in Animation constructor
REGISTER_SPINE_VECTOR(SPVectorTimelinePtr, true); // .set used in Animation constructor
REGISTER_SPINE_VECTOR(SPVectorPhysicsConstraintDataPtr, false);
REGISTER_SPINE_VECTOR(SPVectorPhysicsConstraintPtr, false);
REGISTER_SPINE_VECTOR(SPVectorTrackEntryPtr, false);
REGISTER_SPINE_VECTOR(SPVectorUpdatablePtr, false);
REGISTER_SPINE_VECTOR(SPVectorSkinEntryPtr, false);
Expand Down Expand Up @@ -879,6 +884,64 @@ EMSCRIPTEN_BINDINGS(spine) {
.property("mixScaleY", &TransformConstraint::getMixScaleY)
.property("mixShearY", &TransformConstraint::getMixShearY);

class_<PhysicsConstraintData, base<ConstraintData>>("PhysicsConstraintData")
.constructor<const String &>()
.property("bone", &PhysicsConstraintData::getBone)
.property("x", &PhysicsConstraintData::getX, &PhysicsConstraintData::setX)
.property("y", &PhysicsConstraintData::getY, &PhysicsConstraintData::setY)
.property("rotate", &PhysicsConstraintData::getRotate, &PhysicsConstraintData::setRotate)
.property("scaleX", &PhysicsConstraintData::getScaleX, &PhysicsConstraintData::setScaleX)
.property("shearX", &PhysicsConstraintData::getShearX, &PhysicsConstraintData::setShearX)
.property("limit", &PhysicsConstraintData::getLimit, &PhysicsConstraintData::setLimit)
.property("step", &PhysicsConstraintData::getStep, &PhysicsConstraintData::setStep)
.property("inertia", &PhysicsConstraintData::getInertia, &PhysicsConstraintData::setInertia)
.property("strength", &PhysicsConstraintData::getStrength, &PhysicsConstraintData::setStrength)
.property("damping", &PhysicsConstraintData::getDamping, &PhysicsConstraintData::setDamping)
.property("massInverse", &PhysicsConstraintData::getMassInverse, &PhysicsConstraintData::setMassInverse)
.property("wind", &PhysicsConstraintData::getWind, &PhysicsConstraintData::setWind)
.property("gravity", &PhysicsConstraintData::getGravity, &PhysicsConstraintData::setGravity)
.property("mix", &PhysicsConstraintData::getMix, &PhysicsConstraintData::setMix)
.property("inertiaGlobal", &PhysicsConstraintData::isInertiaGlobal, &PhysicsConstraintData::setInertiaGlobal)
.property("strengthGlobal", &PhysicsConstraintData::isStrengthGlobal, &PhysicsConstraintData::setStrengthGlobal)
.property("dampingGlobal", &PhysicsConstraintData::isDampingGlobal, &PhysicsConstraintData::setDampingGlobal)
.property("massGlobal", &PhysicsConstraintData::isMassGlobal, &PhysicsConstraintData::setMassGlobal)
.property("windGlobal", &PhysicsConstraintData::isWindGlobal, &PhysicsConstraintData::setWindGlobal)
.property("gravityGlobal", &PhysicsConstraintData::isGravityGlobal, &PhysicsConstraintData::setGravityGlobal)
.property("mixGlobal", &PhysicsConstraintData::isMixGlobal, &PhysicsConstraintData::setMixGlobal);

class_<PhysicsConstraint, base<Updatable>>("PhysicsConstraint")
.constructor<PhysicsConstraintData &, Skeleton &>()
.property("data", GETTER_RVAL_TO_PTR(PhysicsConstraint, getData, PhysicsConstraintData*))
.property("bone", &PhysicsConstraint::getBone, &PhysicsConstraint::setBone)
.property("inertia", &PhysicsConstraint::getInertia, &PhysicsConstraint::setInertia)
.property("strength", &PhysicsConstraint::getStrength, &PhysicsConstraint::setStrength)
.property("damping", &PhysicsConstraint::getDamping, &PhysicsConstraint::setDamping)
.property("massInverse", &PhysicsConstraint::getMassInverse, &PhysicsConstraint::setMassInverse)
.property("wind", &PhysicsConstraint::getWind, &PhysicsConstraint::setWind)
.property("gravity", &PhysicsConstraint::getGravity, &PhysicsConstraint::setGravity)
.property("mix", &PhysicsConstraint::getMix, &PhysicsConstraint::setMix)
.property("_reset", &PhysicsConstraint::getReset, &PhysicsConstraint::setReset)
.property("ux", &PhysicsConstraint::getUx, &PhysicsConstraint::setUx)
.property("uy", &PhysicsConstraint::getUy, &PhysicsConstraint::setUy)
.property("cx", &PhysicsConstraint::getCx, &PhysicsConstraint::setCx)
.property("cy", &PhysicsConstraint::getCy, &PhysicsConstraint::setCy)
.property("tx", &PhysicsConstraint::getTx, &PhysicsConstraint::setTx)
.property("ty", &PhysicsConstraint::getTy, &PhysicsConstraint::setTy)
.property("xOffset", &PhysicsConstraint::getXOffset, &PhysicsConstraint::setXOffset)
.property("xVelocity", &PhysicsConstraint::getXVelocity, &PhysicsConstraint::setXVelocity)
.property("yOffset", &PhysicsConstraint::getYOffset, &PhysicsConstraint::setYOffset)
.property("yVelocity", &PhysicsConstraint::getYVelocity, &PhysicsConstraint::setYVelocity)
.property("rotateOffset", &PhysicsConstraint::getRotateOffset, &PhysicsConstraint::setRotateOffset)
.property("rotateVelocity", &PhysicsConstraint::getRotateVelocity, &PhysicsConstraint::setRotateVelocity)
.property("scaleOffset", &PhysicsConstraint::getScaleOffset, &PhysicsConstraint::setScaleOffset)
.property("scaleVelocity", &PhysicsConstraint::getScaleVelocity, &PhysicsConstraint::setScaleVelocity)
.property("remaining", &PhysicsConstraint::getRemaining, &PhysicsConstraint::setRemaining)
.property("lastTime", &PhysicsConstraint::getLastTime, &PhysicsConstraint::setLastTime)
.function("reset", &PhysicsConstraint::reset)
.function("setToSetupPose", &PhysicsConstraint::setToSetupPose)
.function("translate", &PhysicsConstraint::translate)
.function("rotate", &PhysicsConstraint::rotate);

class_<Bone, base<Updatable>>("Bone")
.constructor<BoneData &, Skeleton &, Bone *>()
.property("data", GETTER_RVAL_TO_PTR(Bone, getData, BoneData*))
Expand Down Expand Up @@ -1058,7 +1121,7 @@ EMSCRIPTEN_BINDINGS(spine) {
.function("findAnimation", &SkeletonData::findAnimation, allow_raw_pointers())
.function("findIkConstraint", &SkeletonData::findIkConstraint, allow_raw_pointers())
.function("findTransformConstraint", &SkeletonData::findTransformConstraint, allow_raw_pointers())
.function("findPhysicsConstraint", &SkeletonData::findPathConstraint, allow_raw_pointers())
.function("findPhysicsConstraint", &SkeletonData::findPhysicsConstraint, allow_raw_pointers())
.function("findPathConstraint", &SkeletonData::findPathConstraint, allow_raw_pointers());

class_<Animation>("Animation")
Expand Down Expand Up @@ -1295,6 +1358,8 @@ EMSCRIPTEN_BINDINGS(spine) {
return &obj.getTransformConstraints(); }), allow_raw_pointer<SPVectorTransformConstraintPtr>())
.function("getPathConstraints", optional_override([](Skeleton &obj){
return &obj.getPathConstraints(); }), allow_raw_pointer<SPVectorPathConstraintPtr>())
.function("getPhysicsConstraints", optional_override([](Skeleton &obj){
return &obj.getPhysicsConstraints(); }), allow_raw_pointer<SPVectorPhysicsConstraintPtr>())
.function("getUpdateCacheList", optional_override([](Skeleton &obj){
return &obj.getUpdateCacheList(); }), allow_raw_pointer<SPVectorUpdatablePtr>())
.property("skin", &Skeleton::_skin)
Expand Down Expand Up @@ -1322,6 +1387,7 @@ EMSCRIPTEN_BINDINGS(spine) {
.function("findIkConstraint", &Skeleton::findIkConstraint, allow_raw_pointers())
.function("findTransformConstraint", &Skeleton::findTransformConstraint, allow_raw_pointers())
.function("findPathConstraint", &Skeleton::findPathConstraint, allow_raw_pointers())
.function("findPhysicsConstraint", &Skeleton::findPhysicsConstraint, allow_raw_pointers())
//.function("getBounds", optional_override([](Skeleton &obj, &outX, ) {}), allow_raw_pointers())
.function("update", &Skeleton::update);

Expand Down
2 changes: 1 addition & 1 deletion native/external-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"type": "github",
"owner": "cocos",
"name": "cocos-engine-external",
"checkout": "v4.0.0-3"
"checkout": "v4.0.0-4"
}
}
Loading