Update UIMeshRender model pre frame (#13738)

This commit is contained in:
ChiaNing
2022-12-08 15:45:11 +08:00
committed by GitHub
parent f2790113b0
commit ddeba2863c
4 changed files with 18 additions and 14 deletions
+8 -12
View File
@@ -70,8 +70,7 @@ export class UIMeshRenderer extends Component {
//nativeObj
private declare _UIModelNativeProxy: NativeUIModelProxy;
protected declare _renderEntity : RenderEntity;
private modelCount = 0;
protected declare _renderEntity: RenderEntity;
public _dirtyVersion = -1;
public _internalId = -1;
@@ -156,13 +155,13 @@ export class UIMeshRenderer extends Component {
const models = this._modelComponent._collectModels();
// @ts-expect-error: UIMeshRenderer do not attachToScene
this._modelComponent._detachFromScene(); // JSB
if (models.length !== this.modelCount) {
for (let i = this.modelCount; i < models.length; i++) {
this._uploadRenderData(i);
this._UIModelNativeProxy.updateModels(models[i]);
}
// clear models
this._UIModelNativeProxy.clearModels();
this._renderEntity.clearDynamicRenderDrawInfos();
for (let i = 0; i < models.length; i++) {
this._uploadRenderData(i);
this._UIModelNativeProxy.updateModels(models[i]);
}
this.modelCount = models.length;
this._UIModelNativeProxy.attachDrawInfo();
}
}
@@ -193,10 +192,7 @@ export class UIMeshRenderer extends Component {
public update () {
if (JSB) {
if (this._modelComponent) {
const models = this._modelComponent._collectModels();
if (models.length !== this.modelCount) {
this.markForUpdateRenderData();
}
this.markForUpdateRenderData();
}
}
this._fitUIRenderQueue();
+1
View File
@@ -99,6 +99,7 @@ export declare class NativeUIModelProxy {
updateModels(model);
attachDrawInfo();
attachNode(node);
clearModels();
}
export declare class NativeStencilManager {
@@ -125,6 +125,8 @@ void UIModelProxy::destroy() {
subMesh = nullptr;
}
_graphicsUseSubMeshes.clear();
_models.clear();
}
void UIModelProxy::clear() {
@@ -148,4 +150,8 @@ void UIModelProxy::attachNode(Node* node) {
_node = node;
}
void UIModelProxy::clearModels() {
_models.clear();
}
} // namespace cc
+3 -2
View File
@@ -44,16 +44,17 @@ public:
void updateModels(scene::Model* models);
void attachDrawInfo();
void attachNode(Node* node);
void clearModels();
protected:
CC_DISALLOW_COPY_MOVE_ASSIGN(UIModelProxy);
private:
Node* _node{nullptr};
ccstd::vector<scene::Model*> _models{};
IntrusivePtr<scene::Model> _model;
ccstd::vector<IntrusivePtr<RenderingSubMesh>> _graphicsUseSubMeshes{};
// For UIModel
IntrusivePtr<scene::Model> _model;
ccstd::vector<scene::Model*> _models{};
gfx::Device* _device{nullptr};
uint32_t _stride{32};