Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forceSharedVertices with skinmesh support #13114

Merged
merged 2 commits into from
Oct 14, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions packages/dev/core/src/Meshes/mesh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3342,6 +3342,10 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
const currentIndices = vertex_data.indices;
const currentPositions = vertex_data.positions;
const currentColors = vertex_data.colors;
const currentMatrixIndices = vertex_data.matricesIndices;
const currentMatrixWeights = vertex_data.matricesWeights;
const currentMatrixIndicesExtra = vertex_data.matricesIndicesExtra;
const currentMatrixWeightsExtra = vertex_data.matricesWeightsExtra;

if (currentIndices === void 0 || currentPositions === void 0 || currentIndices === null || currentPositions === null) {
Logger.Warn("VertexData contains empty entries");
Expand All @@ -3350,6 +3354,10 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
const indices: Array<number> = new Array();
const uvs: Array<number> = new Array();
const colors: Array<number> = new Array();
const matrixIndices: Array<number> = new Array();
const matrixWeights: Array<number> = new Array();
const matrixIndicesExtra: Array<number> = new Array();
const matrixWeightsExtra: Array<number> = new Array();
let pstring: Array<string> = new Array(); //lists facet vertex positions (a,b,c) as string "a|b|c"

let indexPtr: number = 0; // pointer to next available index value
Expand Down Expand Up @@ -3395,6 +3403,26 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
uvs.push(currentUVs[2 * facet[j] + k]);
}
}
if (currentMatrixIndices !== null && currentMatrixIndices !== void 0) {
for (let k = 0; k < 4; k++) {
matrixIndices.push(currentMatrixIndices[4 * facet[j] + k]);
}
}
if (currentMatrixWeights !== null && currentMatrixWeights !== void 0) {
for (let k = 0; k < 4; k++) {
matrixWeights.push(currentMatrixWeights[4 * facet[j] + k]);
}
}
if (currentMatrixIndicesExtra !== null && currentMatrixIndicesExtra !== void 0) {
for (let k = 0; k < 4; k++) {
matrixIndices.push(currentMatrixIndicesExtra[4 * facet[j] + k]);
CedricGuillemet marked this conversation as resolved.
Show resolved Hide resolved
}
}
if (currentMatrixWeightsExtra !== null && currentMatrixWeightsExtra !== void 0) {
for (let k = 0; k < 4; k++) {
matrixWeightsExtra.push(currentMatrixWeightsExtra[4 * facet[j] + k]);
}
}
}
// add new index pointer to indices array
indices.push(ptr);
Expand All @@ -3415,6 +3443,18 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
if (currentColors !== null && currentColors !== void 0) {
vertex_data.colors = colors;
}
if (currentMatrixIndices !== null && currentMatrixIndices !== void 0) {
vertex_data.matricesIndices = matrixIndices;
}
if (currentMatrixWeights !== null && currentMatrixWeights !== void 0) {
vertex_data.matricesWeights = matrixWeights;
}
if (currentMatrixIndicesExtra !== null && currentMatrixIndicesExtra !== void 0) {
vertex_data.matricesIndicesExtra = matrixIndicesExtra;
}
if (currentMatrixWeights !== null && currentMatrixWeights !== void 0) {
vertex_data.matricesWeightsExtra = matrixWeightsExtra;
}

vertex_data.applyToMesh(this, this.isVertexBufferUpdatable(VertexBuffer.PositionKind));
}
Expand Down