Skip to content

Commit

Permalink
Merge pull request #787 from galacean/perf/particle-rotation-update
Browse files Browse the repository at this point in the history
perf: opt particle rotation calculate performance
  • Loading branch information
yiiqii authored Dec 13, 2024
2 parents 0a227b0 + b88cb17 commit 0a5b223
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions packages/effects-core/src/plugins/particle/particle-mesh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ export class ParticleMesh implements ParticleMeshData {

if (!this.rotationOverLifetime) {
aRotationMatrix.setZero();
} else if (this.rotationOverLifetime.asRotation) {
} else {
// Adjust rotation based on the specified lifetime components
if (this.rotationOverLifetime.x) {
if (this.rotationOverLifetime.x instanceof RandomValue) {
Expand All @@ -726,30 +726,31 @@ export class ParticleMesh implements ParticleMeshData {
rotation.z += this.rotationOverLifetime.z.getValue(life);
}
}
} else {
// Adjust rotation based on the specified lifetime components
if (this.rotationOverLifetime.x) {
if (this.rotationOverLifetime.x instanceof RandomValue) {
rotation.x += this.rotationOverLifetime.x.getIntegrateValue(0.0, life, aSeed) * duration;
} else {
rotation.x += this.rotationOverLifetime.x.getIntegrateValue(0.0, life, duration) * duration;
}
}
if (this.rotationOverLifetime.y) {
if (this.rotationOverLifetime.y instanceof RandomValue) {
rotation.y += this.rotationOverLifetime.y.getIntegrateValue(0.0, life, aSeed) * duration;
} else {
rotation.y += this.rotationOverLifetime.y.getIntegrateValue(0.0, life, duration) * duration;
}
}
if (this.rotationOverLifetime.z) {
if (this.rotationOverLifetime.z instanceof RandomValue) {
rotation.z += this.rotationOverLifetime.z.getIntegrateValue(0.0, life, aSeed) * duration;
} else {
rotation.z += this.rotationOverLifetime.z.getIntegrateValue(0.0, life, duration) * duration;
}
}
}
// else {
// // Adjust rotation based on the specified lifetime components
// if (this.rotationOverLifetime.x) {
// if (this.rotationOverLifetime.x instanceof RandomValue) {
// rotation.x += this.rotationOverLifetime.x.getIntegrateValue(0.0, life, aSeed) * duration;
// } else {
// rotation.x += this.rotationOverLifetime.x.getIntegrateValue(0.0, life, duration) * duration;
// }
// }
// if (this.rotationOverLifetime.y) {
// if (this.rotationOverLifetime.y instanceof RandomValue) {
// rotation.y += this.rotationOverLifetime.y.getIntegrateValue(0.0, life, aSeed) * duration;
// } else {
// rotation.y += this.rotationOverLifetime.y.getIntegrateValue(0.0, life, duration) * duration;
// }
// }
// if (this.rotationOverLifetime.z) {
// if (this.rotationOverLifetime.z instanceof RandomValue) {
// rotation.z += this.rotationOverLifetime.z.getIntegrateValue(0.0, life, aSeed) * duration;
// } else {
// rotation.z += this.rotationOverLifetime.z.getIntegrateValue(0.0, life, duration) * duration;
// }
// }
// }

// If the rotation vector is zero, return the identity matrix
if (rotation.dot(rotation) === 0.0) {
Expand Down

0 comments on commit 0a5b223

Please sign in to comment.