Skip to content

Commit de02323

Browse files
author
kevyuu
committed
Fix bug prone constant
1 parent 489e2f2 commit de02323

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/nbl/asset/utils/CGeometryCreator.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ core::smart_refctd_ptr<ICPUPolygonGeometry> CGeometryCreator::createCube(const h
187187
snorm_normal_t* normals;
188188

189189
using uv_element_t = uint8_t;
190-
constexpr auto MaxUvVal = std::numeric_limits<uv_element_t>::max();
190+
constexpr auto UnityUV = std::numeric_limits<uv_element_t>::max();
191191
hlsl::vector<uv_element_t,2>* uvs;
192192
{
193193
{
@@ -267,9 +267,9 @@ core::smart_refctd_ptr<ICPUPolygonGeometry> CGeometryCreator::createCube(const h
267267
};
268268
const hlsl::vector<uv_element_t, 2> uv[4] =
269269
{
270-
hlsl::vector<uv_element_t,2>( 0, MaxUvVal),
271-
hlsl::vector<uv_element_t,2>(MaxUvVal, MaxUvVal),
272-
hlsl::vector<uv_element_t,2>(MaxUvVal, 0),
270+
hlsl::vector<uv_element_t,2>( 0, UnityUV),
271+
hlsl::vector<uv_element_t,2>(UnityUV, UnityUV),
272+
hlsl::vector<uv_element_t,2>(UnityUV, 0),
273273
hlsl::vector<uv_element_t,2>( 0, 0)
274274
};
275275

@@ -378,14 +378,15 @@ core::smart_refctd_ptr<ICPUPolygonGeometry> CGeometryCreator::createSphere(float
378378
}
379379

380380
constexpr auto NormalCacheFormat = EF_R8G8B8_SNORM;
381-
constexpr auto NormalFormat = EF_R8G8B8A8_SNORM;
382381

383382
// Create vertex attributes with NONE usage because we have no clue how they'll be used
384383
hlsl::float32_t3* positions;
385384

386385
snorm_normal_t* normals;
387386

388387
using uv_element_t = uint16_t;
388+
constexpr auto UnityUV = std::numeric_limits<uv_element_t>::max();
389+
389390
hlsl::vector<uv_element_t, 2>* uvs;
390391
{
391392
{
@@ -474,14 +475,14 @@ core::smart_refctd_ptr<ICPUPolygonGeometry> CGeometryCreator::createSphere(float
474475

475476
// the vertex at the top of the sphere
476477
positions[vertex_i] = { 0.f, radius, 0.f };
477-
uvs[vertex_i] = { 0, 63};
478+
uvs[vertex_i] = { 0, UnityUV / 2};
478479
const auto quantizedTopNormal = quantNormalCache->quantize<NormalCacheFormat>(hlsl::float32_t3(0.f, 1.f, 0.f));
479480
memcpy(normals + vertex_i, &quantizedTopNormal, sizeof(quantizedTopNormal));
480481

481482
// the vertex at the bottom of the sphere
482483
vertex_i++;
483484
positions[vertex_i] = { 0.f, -radius, 0.f };
484-
uvs[vertex_i] = { 63, 127};
485+
uvs[vertex_i] = { UnityUV / 2, UnityUV};
485486
const auto quantizedBottomNormal = quantNormalCache->quantize<NormalCacheFormat>(hlsl::float32_t3(0.f, -1.f, 0.f));
486487
memcpy(normals + vertex_i, &quantizedBottomNormal, sizeof(quantizedBottomNormal));
487488
}
@@ -529,7 +530,6 @@ core::smart_refctd_ptr<ICPUPolygonGeometry> CGeometryCreator::createCylinder(
529530
}
530531

531532
constexpr auto NormalCacheFormat = EF_R8G8B8_SNORM;
532-
constexpr auto NormalFormat = EF_R8G8B8A8_SNORM;
533533

534534
// Create vertex attributes with NONE usage because we have no clue how they'll be used
535535
hlsl::float32_t3* positions;
@@ -628,7 +628,7 @@ core::smart_refctd_ptr<ICPUPolygonGeometry> CGeometryCreator::createCone(
628628

629629
// Create vertex attributes with NONE usage because we have no clue how they'll be used
630630
hlsl::float32_t3* positions;
631-
hlsl::vector<int8_t, 4>* normals;
631+
snorm_normal_t* normals;
632632
{
633633
{
634634
shapes::AABB<4, float32_t> aabb;
@@ -860,7 +860,7 @@ core::smart_refctd_ptr<ICPUPolygonGeometry> CGeometryCreator::createDisk(const f
860860
*(uvs++) = uint16_t2(t*UnityUV+0.5f,0);
861861
}
862862
}
863-
std::fill_n(normals,vertexCount,hlsl::vector<int8_t,4>(0,0,127,0));
863+
std::fill_n(normals,vertexCount, snorm_positive_z);
864864

865865
CPolygonGeometryManipulator::recomputeContentHashes(retval.get());
866866
return retval;

0 commit comments

Comments
 (0)