From cbeae9c4d4f8e1240d7301d0dc90912e6b2acd4c Mon Sep 17 00:00:00 2001 From: Canvas Date: Fri, 4 Aug 2023 15:17:43 +0800 Subject: [PATCH] fix spine-skeleton-instance.cpp 3.8.0 -> 3.8.1 missing code issue. --- .../spine-wasm/spine-type-export.cpp | 229 +++++++++--------- 1 file changed, 117 insertions(+), 112 deletions(-) diff --git a/native/cocos/editor-support/spine-wasm/spine-type-export.cpp b/native/cocos/editor-support/spine-wasm/spine-type-export.cpp index a574fc17fcc..b5c22169054 100644 --- a/native/cocos/editor-support/spine-wasm/spine-type-export.cpp +++ b/native/cocos/editor-support/spine-wasm/spine-type-export.cpp @@ -942,9 +942,11 @@ EMSCRIPTEN_BINDINGS(spine) { .constructor() .function("getDefaultMix", &AnimationStateData::getDefaultMix) .function("getSkeletonData", &AnimationStateData::getSkeletonData, allow_raw_pointers()) - .function("setMix", optional_override([](AnimationStateData &obj, std::string fromName, std::string toName, float duration) { - .function("setMixWith", optional_override([](AnimationStateData &obj, Animation *from, Animation *to, float duration) { return obj.setMix(from, to, duration); }), allow_raw_pointers()) - .function("getMix", &AnimationStateData::getMix, allow_raw_pointers()); + .function("setMix", optional_override([](AnimationStateData &obj, const std::string& fromName, const std::string& toName, float duration) { + return obj.setMix(STRING_STD2SP(fromName), STRING_STD2SP(toName), duration);})) + .function("setMixWith", optional_override([](AnimationStateData &obj, Animation* from, Animation* to, float duration) { + return obj.setMix(from, to, duration);}), allow_raw_pointers()) + .function("getMix", &AnimationStateData::getMix, allow_raw_pointers()); // .function("setMixWith", &Skeleton::setMixWith_Export) //.function("getMix", &Skeleton::setMix_Export); @@ -1071,116 +1073,119 @@ EMSCRIPTEN_BINDINGS(spine) { .function("setSkinByName", optional_override([](Skeleton &obj, const std::string& name) { return obj.setSkin(STRING_STD2SP(name));})) .function("setSkin", static_cast(&Skeleton::setSkin), allow_raw_pointer()) - .function("getAttachmentByName", optional_override([](Skeleton &obj, std::string slotName, std::string attachmentName) { - .function("getAttachment", optional_override([](Skeleton &obj, int slotIndex, std::string attachmentName) { - .function("setAttachment", optional_override([](Skeleton &obj, std::string slotName, std::string attachmentName) { - .function("findIkConstraint", optional_override([](Skeleton &obj, const std::string &name) { return obj.findIkConstraint(STRING_STD2SP(name)); }), allow_raw_pointers()) - .function("findTransformConstraint", optional_override([](Skeleton &obj, const std::string &name) { return obj.findTransformConstraint(STRING_STD2SP(name)); }), allow_raw_pointers()) - .function("findPathConstraint", optional_override([](Skeleton &obj, const std::string &name) { return obj.findPathConstraint(STRING_STD2SP(name)); }), allow_raw_pointers()) - //.function("getBounds", &Skeleton::getBounds) - .function("update", &Skeleton::update); - - // incomplete - // class_("SkeletonBinary") - // .constructor() - // .function("setProp_scale", &SkeletonBinary::setScale); - //.function("getProp_scale", &SkeletonBinary::getScale) - //.function("readSkeletonData", &SkeletonBinary::readSkeletonData) - //.function("setCurve", &SkeletonBinary::setCurve); - // incomplete - - // class_("SkeletonJson") - // .constructor() - // .constructor(); - //.function("readSkeletonData", &SkeletonJson::readSkeletonData) - //.function("getProp_scale", &SkeletonJson::getScale) - - class_("VertexEffect") - .function("begin", &VertexEffect::begin, pure_virtual()) - //.function("transform", &VertexEffect::transform, pure_virtual()) - .function("end", &VertexEffect::end, pure_virtual()); - - class_>("JitterEffect") - .constructor() - .function("getJitterX", &JitterVertexEffect::getJitterX) - .function("setJitterX", &JitterVertexEffect::setJitterX) - .function("getJitterY", &JitterVertexEffect::getJitterY) - .function("setJitterY", &JitterVertexEffect::setJitterY) - .function("begin", &JitterVertexEffect::begin) - //.function("transform", &JitterVertexEffect::transform) - .function("end", &JitterVertexEffect::end); - - class_>("SwirlEffect") - .constructor() - .function("getCenterX", &SwirlVertexEffect::getCenterX) - .function("setCenterX", &SwirlVertexEffect::setCenterX) - .function("getCenterY", &SwirlVertexEffect::getCenterY) - .function("setCenterY", &SwirlVertexEffect::setCenterY) - .function("getRadius", &SwirlVertexEffect::getRadius) - .function("setRadius", &SwirlVertexEffect::setRadius) - .function("getAngle", &SwirlVertexEffect::getAngle) - .function("setAngle", &SwirlVertexEffect::setAngle) - .function("begin", &SwirlVertexEffect::begin) - //.function("transform", &SwirlVertexEffect::transform) - .function("end", &SwirlVertexEffect::end); - - class_("SlotMesh") - .property("vCount", &SlotMesh::vCount) - .property("iCount", &SlotMesh::iCount) - .property("blendMode", &SlotMesh::blendMode) - .property("textureID", &SlotMesh::textureID); - - register_vector("VectorSlotMesh"); - class_("SpineModel") - .property("vCount", &SpineModel::vCount) - .property("iCount", &SpineModel::iCount) - .property("vPtr", &SpineModel::vPtr) - .property("iPtr", &SpineModel::iPtr) - .function("getMeshes", &SpineModel::getMeshes); - - class_("SpineDebugShape") - .property("type", &SpineDebugShape::type) - .property("vOffset", &SpineDebugShape::vOffset) - .property("vCount", &SpineDebugShape::vCount) - .property("iOffset", &SpineDebugShape::iOffset) - .property("iCount", &SpineDebugShape::iCount); - - register_vector("VectorDebugShape"); - class_("SkeletonInstance") - .constructor<>() - .function("initSkeleton", &SpineSkeletonInstance::initSkeleton, allow_raw_pointers()) - .function("setAnimation", &SpineSkeletonInstance::setAnimation, allow_raw_pointers()) - .function("setSkin", &SpineSkeletonInstance::setSkin) - .function("updateAnimation", &SpineSkeletonInstance::updateAnimation) - .function("updateRenderData", &SpineSkeletonInstance::updateRenderData, allow_raw_pointer()) - .function("setPremultipliedAlpha", &SpineSkeletonInstance::setPremultipliedAlpha) - .function("setUseTint", &SpineSkeletonInstance::setUseTint) - .function("setColor", &SpineSkeletonInstance::setColor) - .function("setJitterEffect", &SpineSkeletonInstance::setJitterEffect, allow_raw_pointer()) - .function("setSwirlEffect", &SpineSkeletonInstance::setSwirlEffect, allow_raw_pointer()) - .function("clearEffect", &SpineSkeletonInstance::clearEffect) - .function("getAnimationState", &SpineSkeletonInstance::getAnimationState, allow_raw_pointer()) - .function("setMix", &SpineSkeletonInstance::setMix) - .function("setListener", &SpineSkeletonInstance::setListener) - .function("setDebugMode", &SpineSkeletonInstance::setDebugMode) - .function("getDebugShapes", &SpineSkeletonInstance::getDebugShapes) - .function("resizeSlotRegion", &SpineSkeletonInstance::resizeSlotRegion) - .function("setSlotTexture", &SpineSkeletonInstance::setSlotTexture); + .function("getAttachmentByName", optional_override([](Skeleton &obj, const std::string& slotName, const std::string& attachmentName) { + return obj.getAttachment(STRING_STD2SP(slotName), STRING_STD2SP(attachmentName));}), allow_raw_pointers()) + .function("getAttachment", optional_override([](Skeleton &obj, int slotIndex, const std::string& attachmentName) { + return obj.getAttachment(slotIndex, STRING_STD2SP(attachmentName));}),allow_raw_pointers()) + .function("setAttachment", optional_override([](Skeleton &obj, const std::string& slotName, const std::string& attachmentName) { + return obj.setAttachment(STRING_STD2SP(slotName), STRING_STD2SP(attachmentName));})) + .function("findIkConstraint", optional_override([](Skeleton &obj, const std::string &name) { return obj.findIkConstraint(STRING_STD2SP(name)); }), allow_raw_pointers()) + .function("findTransformConstraint", optional_override([](Skeleton &obj, const std::string &name) { return obj.findTransformConstraint(STRING_STD2SP(name)); }), allow_raw_pointers()) + .function("findPathConstraint", optional_override([](Skeleton &obj, const std::string &name) { return obj.findPathConstraint(STRING_STD2SP(name)); }), allow_raw_pointers()) + //.function("getBounds", &Skeleton::getBounds) + .function("update", &Skeleton::update); + + // incomplete + // class_("SkeletonBinary") + // .constructor() + // .function("setProp_scale", &SkeletonBinary::setScale); + //.function("getProp_scale", &SkeletonBinary::getScale) + //.function("readSkeletonData", &SkeletonBinary::readSkeletonData) + //.function("setCurve", &SkeletonBinary::setCurve); + // incomplete + + // class_("SkeletonJson") + // .constructor() + // .constructor(); + //.function("readSkeletonData", &SkeletonJson::readSkeletonData) + //.function("getProp_scale", &SkeletonJson::getScale) + + class_("VertexEffect") + .function("begin", &VertexEffect::begin, pure_virtual()) + //.function("transform", &VertexEffect::transform, pure_virtual()) + .function("end", &VertexEffect::end, pure_virtual()); + + class_>("JitterEffect") + .constructor() + .function("getJitterX", &JitterVertexEffect::getJitterX) + .function("setJitterX", &JitterVertexEffect::setJitterX) + .function("getJitterY", &JitterVertexEffect::getJitterY) + .function("setJitterY", &JitterVertexEffect::setJitterY) + .function("begin", &JitterVertexEffect::begin) + //.function("transform", &JitterVertexEffect::transform) + .function("end", &JitterVertexEffect::end); + + class_>("SwirlEffect") + .constructor() + .function("getCenterX", &SwirlVertexEffect::getCenterX) + .function("setCenterX", &SwirlVertexEffect::setCenterX) + .function("getCenterY", &SwirlVertexEffect::getCenterY) + .function("setCenterY", &SwirlVertexEffect::setCenterY) + .function("getRadius", &SwirlVertexEffect::getRadius) + .function("setRadius", &SwirlVertexEffect::setRadius) + .function("getAngle", &SwirlVertexEffect::getAngle) + .function("setAngle", &SwirlVertexEffect::setAngle) + .function("begin", &SwirlVertexEffect::begin) + //.function("transform", &SwirlVertexEffect::transform) + .function("end", &SwirlVertexEffect::end); + + class_("SlotMesh") + .property("vCount", &SlotMesh::vCount) + .property("iCount", &SlotMesh::iCount) + .property("blendMode", &SlotMesh::blendMode) + .property("textureID", &SlotMesh::textureID); + + register_vector("VectorSlotMesh"); + class_("SpineModel") + .property("vCount", &SpineModel::vCount) + .property("iCount", &SpineModel::iCount) + .property("vPtr", &SpineModel::vPtr) + .property("iPtr", &SpineModel::iPtr) + .function("getMeshes", &SpineModel::getMeshes); + + class_("SpineDebugShape") + .property("type", &SpineDebugShape::type) + .property("vOffset", &SpineDebugShape::vOffset) + .property("vCount", &SpineDebugShape::vCount) + .property("iOffset", &SpineDebugShape::iOffset) + .property("iCount", &SpineDebugShape::iCount); + + register_vector("VectorDebugShape"); + class_("SkeletonInstance") + .constructor<>() + .function("initSkeleton", &SpineSkeletonInstance::initSkeleton, allow_raw_pointers()) + .function("setAnimation", &SpineSkeletonInstance::setAnimation, allow_raw_pointers()) + .function("setSkin", &SpineSkeletonInstance::setSkin) + .function("updateAnimation", &SpineSkeletonInstance::updateAnimation) + .function("updateRenderData", &SpineSkeletonInstance::updateRenderData, allow_raw_pointer()) + .function("setPremultipliedAlpha", &SpineSkeletonInstance::setPremultipliedAlpha) + .function("setUseTint", &SpineSkeletonInstance::setUseTint) + .function("setColor", &SpineSkeletonInstance::setColor) + .function("setJitterEffect", &SpineSkeletonInstance::setJitterEffect, allow_raw_pointer()) + .function("setSwirlEffect", &SpineSkeletonInstance::setSwirlEffect, allow_raw_pointer()) + .function("clearEffect", &SpineSkeletonInstance::clearEffect) + .function("getAnimationState", &SpineSkeletonInstance::getAnimationState, allow_raw_pointer()) + .function("setMix", &SpineSkeletonInstance::setMix) + .function("setListener", &SpineSkeletonInstance::setListener) + .function("setDebugMode", &SpineSkeletonInstance::setDebugMode) + .function("getDebugShapes", &SpineSkeletonInstance::getDebugShapes) + .function("resizeSlotRegion", &SpineSkeletonInstance::resizeSlotRegion) + .function("setSlotTexture", &SpineSkeletonInstance::setSlotTexture); } EMSCRIPTEN_BINDINGS(cocos_spine) { - class_("SpineWasmUtil") - .class_function("spineWasmInit", &SpineWasmUtil::spineWasmInit) - .class_function("spineWasmDestroy", &SpineWasmUtil::spineWasmDestroy) - .class_function("queryStoreMemory", &SpineWasmUtil::queryStoreMemory) - .class_function("querySpineSkeletonDataByUUID", &SpineWasmUtil::querySpineSkeletonDataByUUID, allow_raw_pointers()) - .class_function("createSpineSkeletonDataWithJson", &SpineWasmUtil::createSpineSkeletonDataWithJson, allow_raw_pointers()) - .class_function("createSpineSkeletonDataWithBinary", &SpineWasmUtil::createSpineSkeletonDataWithBinary, allow_raw_pointers()) - .class_function("registerSpineSkeletonDataWithUUID", &SpineWasmUtil::registerSpineSkeletonDataWithUUID, allow_raw_pointers()) - .class_function("destroySpineSkeletonDataWithUUID", &SpineWasmUtil::destroySpineSkeletonDataWithUUID) - .class_function("destroySpineInstance", &SpineWasmUtil::destroySpineInstance, allow_raw_pointers()) - .class_function("getCurrentListenerID", &SpineWasmUtil::getCurrentListenerID) - .class_function("getCurrentEventType", &SpineWasmUtil::getCurrentEventType) - .class_function("getCurrentTrackEntry", &SpineWasmUtil::getCurrentTrackEntry, allow_raw_pointers()) - .class_function("getCurrentEvent", &SpineWasmUtil::getCurrentEvent, allow_raw_pointers()); + class_("SpineWasmUtil") + .class_function("spineWasmInit", &SpineWasmUtil::spineWasmInit) + .class_function("spineWasmDestroy", &SpineWasmUtil::spineWasmDestroy) + .class_function("queryStoreMemory", &SpineWasmUtil::queryStoreMemory) + .class_function("querySpineSkeletonDataByUUID", &SpineWasmUtil::querySpineSkeletonDataByUUID, allow_raw_pointers()) + .class_function("createSpineSkeletonDataWithJson", &SpineWasmUtil::createSpineSkeletonDataWithJson, allow_raw_pointers()) + .class_function("createSpineSkeletonDataWithBinary", &SpineWasmUtil::createSpineSkeletonDataWithBinary, allow_raw_pointers()) + .class_function("registerSpineSkeletonDataWithUUID", &SpineWasmUtil::registerSpineSkeletonDataWithUUID, allow_raw_pointers()) + .class_function("destroySpineSkeletonDataWithUUID", &SpineWasmUtil::destroySpineSkeletonDataWithUUID) + .class_function("destroySpineInstance", &SpineWasmUtil::destroySpineInstance, allow_raw_pointers()) + .class_function("getCurrentListenerID", &SpineWasmUtil::getCurrentListenerID) + .class_function("getCurrentEventType", &SpineWasmUtil::getCurrentEventType) + .class_function("getCurrentTrackEntry", &SpineWasmUtil::getCurrentTrackEntry, allow_raw_pointers()) + .class_function("getCurrentEvent", &SpineWasmUtil::getCurrentEvent, allow_raw_pointers()); }