Skip to content

Commit 912016e

Browse files
committed
small fixes
1 parent f2a3648 commit 912016e

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

62_CAD/Hatch.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ complex<float_t> solveLaguerreRoot(polynomial<complex<float_t>> p, complex<float
8484
complex_t aSign0 = G + det;
8585
complex_t aSign1 = G - det;
8686
a = complex_t(n, 0.0) / (abs(aSign0) > abs(aSign1) ? aSign0 : aSign1);
87-
//if (isnan(a) || isinf(a)) return nbl::core::nan<double>();
87+
//if (core::isnan(a) || isinf(a)) return nbl::core::nan<double>();
8888
x -= a;
8989
k++;
9090
// Repeat until a is small enough or if the maximum number of iterations has been reached.
@@ -203,7 +203,7 @@ bool Hatch::Segment::isStraightLineConstantMajor() const
203203
p1 = originalBezier->P1[major],
204204
p2 = originalBezier->P2[major];
205205
//assert(p0 <= p1 && p1 <= p2); (PRECISION ISSUES ARISE ONCE MORE)
206-
return abs(p1 - p0) <= exp2(-24) && abs(p2 - p0) <= exp(-24);
206+
return abs(p1 - p0) <= core::exp2(-24) && abs(p2 - p0) <= exp(-24);
207207
}
208208

209209
std::array<double, 2> Hatch::Segment::intersect(const Segment& other) const
@@ -290,7 +290,7 @@ std::array<double, 2> Hatch::Segment::intersect(const Segment& other) const
290290
for (uint32_t i = 0; i < intersections.size(); i++)
291291
{
292292
auto t = intersections[i];
293-
if (isnan(t) || other.t_start >= t || t >= other.t_end)
293+
if (core::isnan(t) || other.t_start >= t || t >= other.t_end)
294294
continue;
295295

296296
auto intersection = otherBezier.evaluate(t);
@@ -730,7 +730,7 @@ Hatch::Hatch(std::span<CPolyline> lines, const MajorAxis majorAxis, int32_t& deb
730730
const Segment& item = activeCandidates[i];
731731
auto curveMinEnd = intersectOrtho(*item.originalBezier, newMajor, major);
732732
auto splitCurveMin = *item.originalBezier;
733-
splitCurveMin.splitCurveFromMinToMax(item.t_start, isnan(curveMinEnd) ? 1.0 : curveMinEnd);
733+
splitCurveMin.splitCurveFromMinToMax(item.t_start, core::isnan(curveMinEnd) ? 1.0 : curveMinEnd);
734734

735735
drawDebugBezier(splitCurveMin, (i == candidatesSize - 1) ? float32_t4(0.0, 0.0, 1.0, 1.0) : float32_t4(1.0, 0.0, 0.0, 1.0));
736736
if (i == candidatesSize - 1)
@@ -756,9 +756,9 @@ Hatch::Hatch(std::span<CPolyline> lines, const MajorAxis majorAxis, int32_t& deb
756756
auto curveMaxEnd = intersectOrtho(*right.originalBezier, newMajor, major);
757757

758758
auto splitCurveMin = *left.originalBezier;
759-
splitCurveMin.splitFromMinToMax(left.t_start, isnan(curveMinEnd) ? 1.0 : curveMinEnd);
759+
splitCurveMin.splitFromMinToMax(left.t_start, core::isnan(curveMinEnd) ? 1.0 : curveMinEnd);
760760
auto splitCurveMax = *right.originalBezier;
761-
splitCurveMax.splitFromMinToMax(right.t_start, isnan(curveMaxEnd) ? 1.0 : curveMaxEnd);
761+
splitCurveMax.splitFromMinToMax(right.t_start, core::isnan(curveMaxEnd) ? 1.0 : curveMaxEnd);
762762

763763
assert(splitCurveMin.evaluate(0.0)[major] <= splitCurveMin.evaluate(1.0)[major]);
764764
assert(splitCurveMax.evaluate(0.0)[major] <= splitCurveMax.evaluate(1.0)[major]);
@@ -893,7 +893,7 @@ std::array<double, 4> Hatch::bezierBezierIntersections(const QuadraticBezier& lh
893893
}
894894

895895
// TODO: why did we do this?
896-
// if (t[0] == t[1] || isnan(t[0]) || isnan(t[1]))
896+
// if (t[0] == t[1] || core::isnan(t[0]) || core::isnan(t[1]))
897897
// t[0] = (t[0] != 0.0) ? 0.0 : 1.0;
898898

899899
return t;
@@ -957,7 +957,7 @@ std::pair<float64_t2, float64_t2> Hatch::getBezierBoundingBoxMinor(const Quadrat
957957
for (uint32_t i = 0; i < searchTSize; i++)
958958
{
959959
double t = searchT[i];
960-
if (t < 0.0 || t > 1.0 || isnan(t))
960+
if (t < 0.0 || t > 1.0 || core::isnan(t))
961961
continue;
962962
float64_t2 value = bezier.evaluate(t);
963963
min = float64_t2(std::min(min.x, value.x), std::min(min.y, value.y));

62_CAD/curves.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
#include <nbl/builtin/hlsl/shapes/util.hlsl>
55
#include <nbl/builtin/hlsl/math/equations/quadratic.hlsl>
66

7+
using namespace nbl;
8+
using namespace nbl::core;
9+
using namespace nbl::video;
710
using namespace nbl::hlsl;
811

912
namespace curves
@@ -63,7 +66,7 @@ float64_t2 ExplicitCurve::computeTangent(float64_t x) const
6366
{
6467
const float64_t deriv = derivative(x);
6568
float64_t2 v = float64_t2(1.0, deriv);
66-
if (isinf(deriv))
69+
if (core::isinf(deriv))
6770
v = float64_t2(0.0, 1.0);
6871
return v;
6972
}
@@ -414,7 +417,7 @@ static void fixBezierMidPoint(shapes::QuadraticBezier<double>& bezier)
414417
const float64_t2 localChord = bezier.P2 - bezier.P0;
415418
const float64_t localX = dot(normalize(localChord), bezier.P1 - bezier.P0);
416419
const bool outside = localX<0 || localX>length(localChord);
417-
if (outside || isnan(bezier.P1.x) || isnan(bezier.P1.y))
420+
if (outside || core::isnan(bezier.P1.x) || core::isnan(bezier.P1.y))
418421
{
419422
// _NBL_DEBUG_BREAK_IF(true); // this shouldn't happen but we fix it just in case anyways
420423
bezier.P1 = bezier.P0 * 0.4 + bezier.P2 * 0.6;
@@ -542,9 +545,9 @@ void Subdivision::adaptive_impl(const ParametricCurve& curve, float64_t min, flo
542545
{
543546
const float64_t2 curvePositionAtSplit = curve.computePosition(split);
544547
float64_t bezierYAtSplit = bezier.calcYatX(curvePositionAtSplit.x);
545-
//_NBL_DEBUG_BREAK_IF(isnan(bezierYAtSplit));
548+
//_NBL_DEBUG_BREAK_IF(core::isnan(bezierYAtSplit));
546549
// TODO: maybe a better error comaprison is find the normal at split and intersect with the bezier
547-
if (isnan(bezierYAtSplit) || abs(curvePositionAtSplit.y - bezierYAtSplit) > targetMaxError)
550+
if (core::isnan(bezierYAtSplit) || abs(curvePositionAtSplit.y - bezierYAtSplit) > targetMaxError)
548551
shouldSubdivide = true;
549552
}
550553
}

62_CAD/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ class CSwapchainResources : public ISimpleManagedSurface::ISwapchainResources
190190
m_renderpass = renderpass;
191191
}
192192

193-
inline IGPUFramebuffer* getFrambuffer(const uint8_t imageIx)
193+
inline IGPUFramebuffer* getFramebuffer(const uint8_t imageIx)
194194
{
195195
if (imageIx<m_framebuffers.size())
196196
return m_framebuffers[imageIx].get();
@@ -919,7 +919,7 @@ class ComputerAidedDesign final : public examples::SimpleWindowedApplication, pu
919919
const IGPUCommandBuffer::SClearColorValue clearValue = { .float32 = {0.f,0.f,0.f,0.f} };
920920
beginInfo = {
921921
.renderpass = renderpassInitial.get(),
922-
.framebuffer = scRes->getFrambuffer(m_currentImageAcquire.imageIndex),
922+
.framebuffer = scRes->getFramebuffer(m_currentImageAcquire.imageIndex),
923923
.colorClearValues = &clearValue,
924924
.depthStencilClearValues = nullptr,
925925
.renderArea = currentRenderArea
@@ -1092,7 +1092,7 @@ class ComputerAidedDesign final : public examples::SimpleWindowedApplication, pu
10921092
const IGPUCommandBuffer::SClearColorValue clearValue = { .float32 = {0.f,0.f,0.f,0.f} };
10931093
beginInfo = {
10941094
.renderpass = (inBetweenSubmit) ? renderpassInBetween.get():renderpassFinal.get(),
1095-
.framebuffer = scRes->getFrambuffer(m_currentImageAcquire.imageIndex),
1095+
.framebuffer = scRes->getFramebuffer(m_currentImageAcquire.imageIndex),
10961096
.colorClearValues = &clearValue,
10971097
.depthStencilClearValues = nullptr,
10981098
.renderArea = currentRenderArea

0 commit comments

Comments
 (0)