diff --git a/native/cocos/bindings/manual/jsb_scene_manual.cpp b/native/cocos/bindings/manual/jsb_scene_manual.cpp index 3bf50cc8ae..72ef8d55d9 100644 --- a/native/cocos/bindings/manual/jsb_scene_manual.cpp +++ b/native/cocos/bindings/manual/jsb_scene_manual.cpp @@ -127,50 +127,6 @@ static bool js_scene_Model_setInstancedAttrBlock(se::State& s) // NOLINT(readabi } SE_BIND_FUNC(js_scene_Model_setInstancedAttrBlock) // NOLINT(readability-identifier-naming) -static bool js_scene_Node_initWithData(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = static_cast(s.nativeThisObject()); - CC_UNUSED bool ok = true; - const auto& args = s.args(); - size_t argc = args.size(); - do { - if (argc == 1) { - SE_PRECONDITION2(args[0].isObject() && args[0].toObject()->isTypedArray(), false, "js_scene_Node_initWithData: expected Typed Array!"); - - uint8_t* data{nullptr}; - size_t dataBytes = 0; - args[0].toObject()->getTypedArrayData(&data, &dataBytes); - cobj->initWithData(data); - return true; - } - } while (false); - SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); - return false; -} -SE_BIND_FUNC(js_scene_Node_initWithData) // NOLINT(readability-identifier-naming) - -static bool js_scene_Pass_initWithData(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = static_cast(s.nativeThisObject()); - CC_UNUSED bool ok = true; - const auto& args = s.args(); - size_t argc = args.size(); - do { - if (argc == 1) { - SE_PRECONDITION2(args[0].isObject() && args[0].toObject()->isTypedArray(), false, "js_scene_Pass_initWithData: expected Typed Array!"); - - uint8_t* data{nullptr}; - size_t dataBytes = 0; - args[0].toObject()->getTypedArrayData(&data, &dataBytes); - cobj->initWithData(data); - return true; - } - } while (false); - SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc); - return false; -} -SE_BIND_FUNC(js_scene_Pass_initWithData) // NOLINT(readability-identifier-naming) - static bool js_scene_SubModel_setSubMeshBuffers(se::State& s) // NOLINT(readability-identifier-naming) { auto* cobj = static_cast(s.nativeThisObject()); @@ -235,8 +191,6 @@ bool register_all_scene_manual(se::Object* obj) // NOLINT(readability-identifier } __jsb_cc_scene_Model_proto->defineFunction("setInstancedAttrBlock", _SE(js_scene_Model_setInstancedAttrBlock)); - __jsb_cc_scene_Node_proto->defineFunction("initWithData", _SE(js_scene_Node_initWithData)); - __jsb_cc_scene_Pass_proto->defineFunction("initWithData", _SE(js_scene_Pass_initWithData)); __jsb_cc_scene_SubModel_proto->defineFunction("setSubMeshBuffers", _SE(js_scene_SubModel_setSubMeshBuffers)); __jsb_cc_scene_Pass_proto->defineFunction("setRootBufferAndBlock", _SE(js_scene_Pass_setRootBufferAndBlock)); diff --git a/native/cocos/scene/Node.cpp b/native/cocos/scene/Node.cpp index 015a54207f..26e27b0f54 100644 --- a/native/cocos/scene/Node.cpp +++ b/native/cocos/scene/Node.cpp @@ -100,8 +100,10 @@ void Node::updateWorldRTMatrix() { Mat4::fromRT(_nodeLayout->worldRotation, _nodeLayout->worldPosition, &_rtMat); } -void Node::initWithData(uint8_t *data) { +void Node::initWithData(uint8_t *data, uint8_t *flagChunk, uint32_t offset) { _nodeLayout = reinterpret_cast(data); + _flagChunk = flagChunk; + _flagOffest = offset; } } // namespace scene diff --git a/native/cocos/scene/Node.h b/native/cocos/scene/Node.h index 02cb985856..9bcb31f55e 100644 --- a/native/cocos/scene/Node.h +++ b/native/cocos/scene/Node.h @@ -38,7 +38,6 @@ namespace scene { // This struct defines the memory layout shared between JS and C++. struct NodeLayout { uint32_t dirtyFlag{0}; - uint32_t flagsChanged{0}; uint32_t layer{0}; cc::Vec3 worldScale; cc::Vec3 worldPosition; @@ -58,7 +57,7 @@ public: Node &operator=(const Node &) = delete; Node &operator=(Node &&) = delete; - void initWithData(uint8_t *data); + void initWithData(uint8_t *, uint8_t *, uint32_t); void updateWorldTransform(); void updateWorldRTMatrix(); @@ -66,7 +65,7 @@ public: _parent = parent; } - inline void setFlagsChanged(uint32_t value) { _nodeLayout->flagsChanged = value; } + inline void setFlagsChanged(uint32_t value) { *(reinterpret_cast(_flagChunk) + _flagOffest) = value; } inline void setDirtyFlag(uint32_t value) { _nodeLayout->dirtyFlag = value; } inline void setLayer(uint32_t layer) { _nodeLayout->layer = layer; } inline void setWorldMatrix(const Mat4 &matrix) { _nodeLayout->worldMatrix.set(matrix); } @@ -82,7 +81,7 @@ public: inline void setLocalScale(const Vec3 &scale) { _nodeLayout->localScale.set(scale); } inline Node * getParent() const { return _parent; } - inline uint32_t getFlagsChanged() const { return _nodeLayout->flagsChanged; } + inline uint32_t getFlagsChanged() const { return *(reinterpret_cast(_flagChunk) + _flagOffest); } inline uint32_t getLayer() const { return _nodeLayout->layer; } inline uint32_t getDirtyFlag() const { return _nodeLayout->dirtyFlag; } inline const Vec3 & getPosition() const { return _nodeLayout->localPosition; } @@ -99,6 +98,8 @@ private: NodeLayout *_nodeLayout{nullptr}; Node * _parent{nullptr}; Mat4 _rtMat; + uint8_t * _flagChunk{nullptr}; + uint32_t _flagOffest{0}; }; } // namespace scene diff --git a/native/tools/tojs/scene.ini b/native/tools/tojs/scene.ini index bc6c51e7f2..8149a7c962 100644 --- a/native/tools/tojs/scene.ini +++ b/native/tools/tojs/scene.ini @@ -43,11 +43,11 @@ classes = Light Node DirectionalLight SpotLight SphereLight Model SubModel Pass skip = Model::[setInstancedAttrBlock getType getLocalBuffer getModelBounds getWorldBounds], SubModel::[getDescriptorSet getInputAssembler getSubMesh setSubMeshBuffers], Light::[getColor getColorTemperatureRGB getNode getType getUseColorTemperature], - Node::[getFlagsChanged getLayer getWorldMatrix getWorldPosition getWorldRotation getWorldScale initWithData setFlagsChanged setDirtyFlag setLayer setWorldMatrix setWorldPosition setWorldRotation setWorldScale setLocalPosition setLocalRotation setLocalScale getNodeLayout getWorldRT updateWorldTransform updateWorldRTMatrix getDirtyFlag getPosition getScale getRotation getParent], + Node::[getFlagsChanged getLayer getWorldMatrix getWorldPosition getWorldRotation getWorldScale setFlagsChanged setDirtyFlag setLayer setWorldMatrix setWorldPosition setWorldRotation setWorldScale setLocalPosition setLocalRotation setLocalScale getNodeLayout getWorldRT updateWorldTransform updateWorldRTMatrix getDirtyFlag getPosition getScale getRotation getParent], DirectionalLight::[getDirection getIlluminance], SpotLight::[getAABB getAngle getAspect getSpotAngle getDirection getFrustum getIlluminance getNeedUpdate getRange getPosition getSize], SphereLight::[getAABB getIlluminance getPosition getRange getSize], - Pass::[initWithData setRootBufferAndBlock], + Pass::[setRootBufferAndBlock], AABB::[getBoundary aabbAabb aabbFrustum aabbPlan merge transform transformExtentM4 setCenter getCenter setHalfExtents getHalfExtents set fromPoints], SkinningModel::[updateTransform updateUBOs uploadJointData updateWorldMatrix], Frustum::[update type],