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

optimize performance when normal and tangent are not necessary #4781

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
* [Abhishek Potnis](https://github.com/abhishekvp)
* [Brad Hover](https://github.com/tekhaus)
* [Hüseyin Ateş](https://github.com/ateshuseyin)
* [Peter Lu](https://github.com/pasu)
21 changes: 12 additions & 9 deletions Source/Core/RectangleGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,13 @@ define([
var binormal = binormalScratch;
var tangent = tangentScratch;
var normal = normalScratch;
for (var i = 0; i < length; i += 3) {
var p = Cartesian3.fromArray(positions, i, positionScratch);
var attrIndex1 = attrIndex + 1;
var attrIndex2 = attrIndex + 2;

if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.binormal) {
if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.binormal) {
for (var i = 0; i < length; i += 3) {
var p = Cartesian3.fromArray(positions, i, positionScratch);
var attrIndex1 = attrIndex + 1;
var attrIndex2 = attrIndex + 2;

normal = ellipsoid.geodeticSurfaceNormal(p, normal);
if (vertexFormat.tangent || vertexFormat.binormal) {
Cartesian3.cross(Cartesian3.UNIT_Z, normal, tangent);
Expand All @@ -140,8 +141,9 @@ define([
binormals[attrIndex1] = binormal.y;
binormals[attrIndex2] = binormal.z;
}

attrIndex += 3;
}
attrIndex += 3;
}
return createAttributes(vertexFormat, {
positions : positions,
Expand All @@ -168,10 +170,11 @@ define([
var binormal = binormalScratch;
var tangent = tangentScratch;
var normal = normalScratch;
for (var i = 0; i < length; i += 6) {
var p = Cartesian3.fromArray(positions, i, positionScratch);
if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.binormal) {
for (var i = 0; i < length; i += 6) {
var p = Cartesian3.fromArray(positions, i, positionScratch);

if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.binormal) {
var p1 = Cartesian3.fromArray(positions, (i + 6) % length, v1Scratch);
if (recomputeNormal) {
var p2 = Cartesian3.fromArray(positions, (i + 3) % length, v2Scratch);
Expand Down