@@ -366,25 +366,6 @@ void loadPrimitive(
366366 primitiveInfo.hasNormals = normalView.status () == AccessorViewStatus::Valid;
367367 }
368368
369- // // Check if we need to upgrade to a large index type to accommodate the
370- // // larger number of vertices we need for flat normals.
371- // if (computeFlatNormals && indexFormat == IndexFormat::UInt16 &&
372- // indexCount >= std::numeric_limits<uint16_t>::max()) {
373- // loadPrimitive<uint32_t>(
374- // meshData,
375- // primitiveInfo,
376- // options,
377- // gltf,
378- // node,
379- // mesh,
380- // primitive,
381- // transform,
382- // indicesView,
383- // IndexFormat::UInt32,
384- // positionView);
385- // return;
386- // }
387-
388369 meshData.SetIndexBufferParams (indexCount, indexFormat);
389370 const Unity::Collections::NativeArray1<TIndex>& dest =
390371 meshData.GetIndexData <TIndex>();
@@ -551,10 +532,7 @@ void loadPrimitive(
551532 attributes.Item (i, descriptor[i]);
552533 }
553534
554- int32_t vertexCount = /* computeFlatNormals
555- ? indexCount
556- : */
557- static_cast <int32_t >(positionView.size ());
535+ int32_t vertexCount = static_cast <int32_t >(positionView.size ());
558536 meshData.SetVertexBufferParams (vertexCount, attributes);
559537
560538 NativeArray1<uint8_t > nativeVertexBuffer =
@@ -584,31 +562,6 @@ void loadPrimitive(
584562 }
585563 stride += numTexCoords * sizeof (Vector2);
586564
587- /* if (computeFlatNormals) {
588- ::computeFlatNormals(
589- pWritePos + normalByteOffset,
590- stride,
591- indices,
592- indexCount,
593- positionView);
594- for (int64_t i = 0; i < vertexCount; ++i) {
595- TIndex vertexIndex = indices[i];
596- *reinterpret_cast<Vector3*>(pWritePos) = positionView[vertexIndex];
597- // skip position and normal
598- pWritePos += 2 * sizeof(Vector3);
599- // Skip the slot allocated for vertex colors, we will fill them in
600- // bulk later.
601- if (hasVertexColors) {
602- pWritePos += sizeof(uint32_t);
603- }
604- for (uint32_t texCoordIndex = 0; texCoordIndex < numTexCoords;
605- ++texCoordIndex) {
606- *reinterpret_cast<Vector2*>(pWritePos) =
607- texCoordViews[texCoordIndex][vertexIndex];
608- pWritePos += sizeof(Vector2);
609- }
610- }
611- } else*/ {
612565 for (int64_t i = 0 ; i < vertexCount; ++i) {
613566 *reinterpret_cast <Vector3*>(pWritePos) = positionView[i];
614567 pWritePos += sizeof (Vector3);
@@ -631,7 +584,6 @@ void loadPrimitive(
631584 pWritePos += sizeof (Vector2);
632585 }
633586 }
634- }
635587
636588 // Fill in vertex colors separately, if they exist.
637589 if (hasVertexColors) {
@@ -647,14 +599,7 @@ void loadPrimitive(
647599 false ,
648600 indices});
649601 }
650- /*
651- if (computeFlatNormals) {
652- // rewrite indices
653- for (TIndex i = 0; i < indexCount; i++) {
654- indices[i] = i;
655- }
656- }
657- */
602+
658603 meshData.subMeshCount (1 );
659604
660605 // TODO: use sub-meshes for glTF primitives, instead of a separate mesh
0 commit comments