mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
Update UIMeshRender model pre frame (#13738)
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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};
|
||||
|
||||
Reference in New Issue
Block a user