312 ocean_assert(parameters.
isValid());
313 ocean_assert(treePoints !=
nullptr);
315 if (numberPointIndices == 0)
320 ocean_assert(reusablePointIndicesInput !=
nullptr && reusablePointIndicesOutput !=
nullptr);
328 const Vector3& firstPoint = treePoints[reusablePointIndicesInput[0]];
330 bool allPointsIdentical =
true;
332 for (
size_t n = 1; n < numberPointIndices; ++n)
334 const Index32& index = reusablePointIndicesInput[n];
337 if (firstPoint != point)
339 allPointsIdentical =
false;
344 isLeafNode = allPointsIdentical;
353 for (
size_t n = 0; n < numberPointIndices; ++n)
355 const Index32& index = reusablePointIndicesInput[n];
366 for (
size_t n = 0; n < numberPointIndices; ++n)
368 const Index32& index = reusablePointIndicesInput[n];
383 for (
size_t n = 0; n < numberPointIndices; ++n)
385 const Index32& index = reusablePointIndicesInput[n];
398 for (
size_t n = 0; n < numberPointIndices; ++n)
400 const Index32& index = reusablePointIndicesInput[n];
411 size_t lowLowLow = 0;
412 size_t lowLowHigh = 0;
413 size_t lowHighLow = 0;
414 size_t lowHighHigh = 0;
416 size_t highLowLow = 0;
417 size_t highLowHigh = 0;
418 size_t highHighLow = 0;
419 size_t highHighHigh = 0;
421 for (
size_t n = 0; n < numberPointIndices; ++n)
423 const Index32& index = reusablePointIndicesInput[n];
426 if (point.
x() < center.
x())
428 if (point.
y() < center.
y())
430 if (point.
z() < center.
z())
441 if (point.
z() < center.
z())
453 if (point.
y() < center.
y())
455 if (point.
z() < center.
z())
466 if (point.
z() < center.
z())
480 Index32* lowLowLowPointer = reusablePointIndicesOutput;
481 Index32* lowLowHighPointer = lowLowLowPointer + lowLowLow;
482 Index32* lowHighLowPointer = lowLowHighPointer + lowLowHigh;
483 Index32* lowHighHighPointer = lowHighLowPointer + lowHighLow;
485 Index32* highLowLowPointer = lowHighHighPointer + lowHighHigh;
486 Index32* highLowHighPointer = highLowLowPointer + highLowLow;
487 Index32* highHighLowPointer = highLowHighPointer + highLowHigh;
488 Index32* highHighHighPointer = highHighLowPointer + highHighLow;
490 ocean_assert(highHighHighPointer + highHighHigh == reusablePointIndicesOutput + numberPointIndices);
492 for (
size_t n = 0; n < numberPointIndices; ++n)
494 const Index32& index = reusablePointIndicesInput[n];
497 if (point.
x() < center.
x())
499 if (point.
y() < center.
y())
501 if (point.
z() < center.
z())
503 *lowLowLowPointer++ = index;
507 *lowLowHighPointer++ = index;
512 if (point.
z() < center.
z())
514 *lowHighLowPointer++ = index;
518 *lowHighHighPointer++ = index;
524 if (point.
y() < center.
y())
526 if (point.
z() < center.
z())
528 *highLowLowPointer++ = index;
532 *highLowHighPointer++ = index;
537 if (point.
z() < center.
z())
539 *highHighLowPointer++ = index;
543 *highHighHighPointer++ = index;
549 ocean_assert(lowLowLowPointer == reusablePointIndicesOutput + lowLowLow);
550 ocean_assert(lowLowHighPointer == lowLowLowPointer + lowLowHigh);
551 ocean_assert(lowHighLowPointer == lowLowHighPointer + lowHighLow);
552 ocean_assert(lowHighHighPointer == lowHighLowPointer + lowHighHigh);
554 ocean_assert(highLowLowPointer == lowHighHighPointer + highLowLow);
555 ocean_assert(highLowHighPointer == highLowLowPointer + highLowHigh);
556 ocean_assert(highHighLowPointer == highLowHighPointer + highHighLow);
557 ocean_assert(highHighHighPointer == highHighLowPointer + highHighHigh);
562 childNodes_[1] =
new OctreeT<T>(parameters, treePoints, reusablePointIndicesOutput += lowLowLow, reusablePointIndicesInput += lowLowLow, lowLowHigh,
BoundingBox());
563 childNodes_[2] =
new OctreeT<T>(parameters, treePoints, reusablePointIndicesOutput += lowLowHigh, reusablePointIndicesInput += lowLowHigh, lowHighLow,
BoundingBox());
564 childNodes_[3] =
new OctreeT<T>(parameters, treePoints, reusablePointIndicesOutput += lowHighLow, reusablePointIndicesInput += lowHighLow, lowHighHigh,
BoundingBox());
566 childNodes_[4] =
new OctreeT<T>(parameters, treePoints, reusablePointIndicesOutput += lowHighHigh, reusablePointIndicesInput += lowHighHigh, highLowLow,
BoundingBox());
567 childNodes_[5] =
new OctreeT<T>(parameters, treePoints, reusablePointIndicesOutput += highLowLow, reusablePointIndicesInput += highLowLow, highLowHigh,
BoundingBox());
568 childNodes_[6] =
new OctreeT<T>(parameters, treePoints, reusablePointIndicesOutput += highLowHigh, reusablePointIndicesInput += highLowHigh, highHighLow,
BoundingBox());
569 childNodes_[7] =
new OctreeT<T>(parameters, treePoints, reusablePointIndicesOutput += highHighLow, reusablePointIndicesInput += highHighLow, highHighHigh,
BoundingBox());
583 childNodes_[0] =
new OctreeT<T>(parameters, treePoints, reusablePointIndicesOutput, reusablePointIndicesInput, lowLowLow, boxLowLowLow);
584 childNodes_[1] =
new OctreeT<T>(parameters, treePoints, reusablePointIndicesOutput += lowLowLow, reusablePointIndicesInput += lowLowLow, lowLowHigh, boxLowLowHigh);
585 childNodes_[2] =
new OctreeT<T>(parameters, treePoints, reusablePointIndicesOutput += lowLowHigh, reusablePointIndicesInput += lowLowHigh, lowHighLow, boxLowHighLow);
586 childNodes_[3] =
new OctreeT<T>(parameters, treePoints, reusablePointIndicesOutput += lowHighLow, reusablePointIndicesInput += lowHighLow, lowHighHigh, boxLowHighHigh);
588 childNodes_[4] =
new OctreeT<T>(parameters, treePoints, reusablePointIndicesOutput += lowHighHigh, reusablePointIndicesInput += lowHighHigh, highLowLow, boxHighLowLow);
589 childNodes_[5] =
new OctreeT<T>(parameters, treePoints, reusablePointIndicesOutput += highLowLow, reusablePointIndicesInput += highLowLow, highLowHigh, boxHighLowHigh);
590 childNodes_[6] =
new OctreeT<T>(parameters, treePoints, reusablePointIndicesOutput += highLowHigh, reusablePointIndicesInput += highLowHigh, highHighLow, boxHighHighLow);
591 childNodes_[7] =
new OctreeT<T>(parameters, treePoints, reusablePointIndicesOutput += highHighLow, reusablePointIndicesInput += highHighLow, highHighHigh, boxHighHighHigh);