Skip to content

Conversation

capdevon
Copy link
Contributor

@capdevon capdevon commented May 29, 2025

These changes result in a cleaner, more robust, and easier-to-understand BoundingSphereDebug implementation.

  • Refactored the BoundingSphereDebug class for improved clarity and maintainability.
  • Simplified geometry generation for the bounding sphere debug mesh.
  • Added explicit generation and coloring of three axis-aligned circles (XY: blue, XZ: green, YZ: yellow) to visually represent the bounding sphere.
  • Introduced a helper method to handle circle vertex and color data creation.
  • Improved documentation and code comments for better understanding.
  • Implemented serialization support by adding write() and read() methods for the radialSamples property.
  • Updated copyright year in the file header.
  • Removed unused or redundant class fields and code.

@yaRnMcDonuts yaRnMcDonuts added this to the v3.9.0 milestone May 29, 2025
Optimize code for geometry data generation
@capdevon capdevon changed the title Refactor: Optimize BoundingSphereDebug Class Refactor: BoundingSphereDebug optimization + javadoc Jun 13, 2025
Copy link
Contributor

@codex128 codex128 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple minor things that could be change to improve the code. I'm fine with this being merged now, though.

private void setIndexData() {

// allocate connectivity
int nbSegments = (radialSamples) * 3; // 3 circles
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable can be inlined.

// Each circle has radialSamples + 1 vertices (to close the loop)
// We have 3 circles, so (radialSamples + 1) * 3 vertices in total.
FloatBuffer posBuf = BufferUtils.createVector3Buffer(numVertices * 3);
FloatBuffer colBuf = BufferUtils.createVector3Buffer(numVertices * 4);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is technically correct, but is confusing since colBuf is for storing colors with 4 components. I suggest changing this to BufferUtils.createFloatBuffer(numVertices * 4 * 3).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants