Skip to content

Commit

Permalink
Revert "Revert "remove useless code (#15682)" (#15683)"
Browse files Browse the repository at this point in the history
This reverts commit b318b39.
  • Loading branch information
SantyWang committed Jul 12, 2023
1 parent b318b39 commit 6322c43
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 39 deletions.
2 changes: 0 additions & 2 deletions cocos/2d/assembler/label/ttf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ export const ttf: IAssembler = {
Color.toArray(vData, WHITE, offset);
offset += 9;
}
renderData.vertexRow = 2;
renderData.vertexCol = 2;
renderData.chunk.setIndexBuffer(QUAD_INDICES);
return renderData;
},
Expand Down
2 changes: 0 additions & 2 deletions cocos/2d/assembler/sprite/bar-filled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,6 @@ export const barFilled: IAssembler = {
// 0-4 for local vertex
renderData.dataLength = 4;
renderData.resize(4, 6);
renderData.vertexRow = 2;
renderData.vertexCol = 2;
renderData.chunk.setIndexBuffer(QUAD_INDICES);

// not need
Expand Down
45 changes: 18 additions & 27 deletions cocos/2d/assembler/sprite/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ export const simple: IAssembler = {
const renderData = sprite.requestRenderData();
renderData.dataLength = 4;
renderData.resize(4, 6);
renderData.vertexRow = 2;
renderData.vertexCol = 2;
renderData.chunk.setIndexBuffer(QUAD_INDICES);
return renderData;
},
Expand Down Expand Up @@ -106,36 +104,29 @@ export const simple: IAssembler = {
}

// quick version
const bid = chunk.bufferId;
const vidOrigin = chunk.vertexOffset;
const meshBuffer = chunk.meshBuffer;
const ib = chunk.meshBuffer.iData;
let indexOffset = meshBuffer.indexOffset;

// rect count = vertex count - 1
for (let curRow = 0; curRow < renderData.vertexRow - 1; curRow++) {
for (let curCol = 0; curCol < renderData.vertexCol - 1; curCol++) {
// vid is the index of the left bottom vertex in each rect.
const vid = vidOrigin + curRow * renderData.vertexCol + curCol;

// left bottom
ib[indexOffset++] = vid;
// right bottom
ib[indexOffset++] = vid + 1;
// left top
ib[indexOffset++] = vid + renderData.vertexCol;

// right bottom
ib[indexOffset++] = vid + 1;
// right top
ib[indexOffset++] = vid + 1 + renderData.vertexCol;
// left top
ib[indexOffset++] = vid + renderData.vertexCol;

// IndexOffset should add 6 when vertices of a rect are visited.
meshBuffer.indexOffset += 6;
}
}
const vid = vidOrigin;

// left bottom
ib[indexOffset++] = vid;
// right bottom
ib[indexOffset++] = vid + 1;
// left top
ib[indexOffset++] = vid + 2;

// right bottom
ib[indexOffset++] = vid + 1;
// right top
ib[indexOffset++] = vid + 3;
// left top
ib[indexOffset++] = vid + 2;

// IndexOffset should add 6 when vertices of a rect are visited.
meshBuffer.indexOffset += 6;
// slow version
// renderer.switchBufferAccessor().appendIndices(chunk);
},
Expand Down
8 changes: 3 additions & 5 deletions cocos/2d/assembler/sprite/sliced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ export const sliced: IAssembler = {
// 0-4 for local vertex
renderData.dataLength = 16;
renderData.resize(16, 54);
renderData.vertexRow = 4;
renderData.vertexCol = 4;
this.QUAD_INDICES = new Uint16Array(54);
this.createQuadIndices(4, 4);
renderData.chunk.setIndexBuffer(this.QUAD_INDICES);

Check failure on line 52 in cocos/2d/assembler/sprite/sliced.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `ArrayLike<number>`
Expand Down Expand Up @@ -140,9 +138,9 @@ export const sliced: IAssembler = {
tempRenderData[3].x = width - appX;
tempRenderData[3].y = height - appY;

for (let curRow = 0; curRow < renderData.vertexRow; curRow++) {
for (let curCol = 0; curCol < renderData.vertexCol; curCol++) {
const curIndex = curRow * renderData.vertexCol + curCol;
for (let curRow = 0; curRow < 4; curRow++) {
for (let curCol = 0; curCol < 4; curCol++) {
const curIndex = curRow * 4 + curCol;
if (curIndex < renderData.dataLength
&& curRow < tempRenderData.length
&& curCol < tempRenderData.length) {
Expand Down
3 changes: 0 additions & 3 deletions cocos/2d/renderer/render-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,6 @@ export class RenderData extends BaseRenderData {
protected _accessor: StaticVBAccessor = null!;

Check failure on line 311 in cocos/2d/renderer/render-data.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Default parameters should be last
get accessor () { return this._accessor; }

public vertexRow = 1;
public vertexCol = 1;

public constructor (vertexFormat = vfmtPosUvColor, accessor?: StaticVBAccessor) {
super(vertexFormat);
if (!accessor) {
Expand Down

0 comments on commit 6322c43

Please sign in to comment.