Compare commits

..

3 Commits

6 changed files with 207 additions and 70 deletions
+126
View File
@@ -42,6 +42,24 @@ declare namespace spine {
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;
@@ -708,6 +726,10 @@ declare namespace spine {
ikConstraints: Array<IkConstraint>;
transformConstraints: Array<TransformConstraint>;
pathConstraints: Array<PathConstraint>;
/**
* @version 4.2
*/
physicsConstraints: Array<PhysicsConstraint>;
_updateCache: Updatable[];
skin: Skin;
color: Color;
@@ -735,8 +757,24 @@ declare namespace spine {
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[];
@@ -812,6 +850,10 @@ declare namespace spine {
ikConstraints: IkConstraintData[];
transformConstraints: TransformConstraintData[];
pathConstraints: PathConstraintData[];
/**
* @version 4.2
*/
physicsConstraints: PhysicsConstraintData[];
x: number;
y: number;
width: number;
@@ -835,6 +877,14 @@ declare namespace spine {
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;
@@ -1005,6 +1055,82 @@ declare namespace spine {
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;
@@ -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*>;
@@ -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)
@@ -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);
@@ -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);
@@ -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*))
@@ -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")
@@ -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)
@@ -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);
@@ -178,6 +178,11 @@ long FileUtilsOpenHarmony::getFileSize(const std::string &filepath) {
if (fullPath.empty()) {
return 0;
}
if(fullPath[0] == '/') {
return FileUtils::getFileSize(fullPath);
}
if (nullptr == _nativeResourceManager) {
CC_LOG_ERROR("nativeResourceManager is nullptr");
return 0;
@@ -201,11 +206,11 @@ bool FileUtilsOpenHarmony::isFileExistInternal(const std::string &strFilePath) c
return false;
}
if (strFilePath[0] != '/') {
if (strFilePath[0] != '/') {
const char *s = strFilePath.c_str();
// Found "@assets/" at the beginning of the path and we don't want it
if (strFilePath.find(ASSETS_FOLDER_NAME) == 0) s += strlen(ASSETS_FOLDER_NAME);
if (nullptr == _nativeResourceManager) {
CC_LOG_ERROR("nativeResourceManager is nullptr");
return false;
@@ -217,7 +222,7 @@ bool FileUtilsOpenHarmony::isFileExistInternal(const std::string &strFilePath) c
return true;
}
return false;
}
}
FILE *fp = fopen(strFilePath.c_str(), "r");
if (fp) {
fclose(fp);
+1 -1
View File
@@ -3,6 +3,6 @@
"type": "github",
"owner": "cocos",
"name": "cocos-engine-external",
"checkout": "v4.0.0-3"
"checkout": "v4.0.0-4"
}
}
+2 -62
View File
@@ -1,12 +1,12 @@
{
"name": "cocos-creator",
"version": "4.0.0-alpha.9",
"version": "4.0.0-alpha.10",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "cocos-creator",
"version": "4.0.0-alpha.9",
"version": "4.0.0-alpha.10",
"hasInstallScript": true,
"license": "MIT",
"dependencies": {
@@ -9532,14 +9532,6 @@
"integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==",
"dev": true
},
"node_modules/growly": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
"integrity": "sha512-+xGQY0YyAWCnqy7Cd++hc2JqMYzlm0dG30Jd0beaA64sROr8C4nt8Yc9V5Ro3avlSUDTN0ulqP/VBKi1/lLygw==",
"dev": true,
"optional": true,
"peer": true
},
"node_modules/gulp": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/gulp/-/gulp-4.0.2.tgz",
@@ -14590,39 +14582,6 @@
"integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==",
"dev": true
},
"node_modules/node-notifier": {
"version": "8.0.2",
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.2.tgz",
"integrity": "sha512-oJP/9NAdd9+x2Q+rfphB2RJCHjod70RcRLjosiPMMu5gjIfwVnOUGq2nbTjTUbmy0DJ/tFIVT30+Qe3nzl4TJg==",
"dev": true,
"optional": true,
"peer": true,
"dependencies": {
"growly": "^1.3.0",
"is-wsl": "^2.2.0",
"semver": "^7.3.2",
"shellwords": "^0.1.1",
"uuid": "^8.3.0",
"which": "^2.0.2"
}
},
"node_modules/node-notifier/node_modules/semver": {
"version": "7.5.4",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
"integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==",
"dev": true,
"optional": true,
"peer": true,
"dependencies": {
"lru-cache": "^6.0.0"
},
"bin": {
"semver": "bin/semver.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/node-releases": {
"version": "2.0.13",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.13.tgz",
@@ -16490,14 +16449,6 @@
"integrity": "sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==",
"dev": true
},
"node_modules/shellwords": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz",
"integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==",
"dev": true,
"optional": true,
"peer": true
},
"node_modules/side-channel": {
"version": "1.0.4",
"resolved": "https://registry.npmmirror.com/side-channel/-/side-channel-1.0.4.tgz",
@@ -18165,17 +18116,6 @@
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
},
"node_modules/uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
"dev": true,
"optional": true,
"peer": true,
"bin": {
"uuid": "dist/bin/uuid"
}
},
"node_modules/v8-to-istanbul": {
"version": "9.1.0",
"resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.1.0.tgz",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "cocos-creator",
"version": "4.0.0-alpha.9",
"version": "4.0.0-alpha.10",
"description": "Cocos Creator is a cross-platform 2D & 3D game engine written in C++ and TypeScript, licensed under MIT.",
"homepage": "http://www.cocos.com",
"license": "MIT",