GitBrincie212 / Apel-Mod

Apel is a library that brings particle animations to the table with flexible behaviour and a clean developer interface. It promises also lots of predefined shapes & paths to help the developer on their particle scene
Other
2 stars 1 forks source link

Use the new vertex to validate triangles #43

Closed DarthSharkie closed 2 months ago

DarthSharkie commented 2 months ago

Fixes #41

The validation used to use the three vertices already existing within the instance, not the new vertex provided. Therefore, start using the new vertex and perform the check prior to anything else. There's no reason to set a local variable if an exception will be thrown.

Note that the invariant of a valid triangle is easily broken because getVertex1() and others return a reference to a Vector3f that may be modified in-place, and there's no way to detect or raise an exception if that happens unless the getters return copies and the setters make defensive copies. The tradeoff is performance, especially on per-frame interceptors, if both the getter and setter are making copies. The alternative is to ditch the check altogether and just let users render the lines that fully connect the three vertices.