-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Easy first fixdefectSomething that is supposed to work, but doesn't. Less severe than a "bug"Something that is supposed to work, but doesn't. Less severe than a "bug"
Description
The following fields are part of the contentHashCode() computation:
hash = 79 * hash + this.frontStencilMask;
hash = 79 * hash + this.frontStencilReference;
hash = 79 * hash + this.backStencilMask;
hash = 79 * hash + this.backStencilReference;However, their corresponding setters do not set cachedHashCode = -1:
public void setFrontStencilMask(int frontStencilMask) {
this.frontStencilMask = frontStencilMask;
}
public void setBackStencilMask(int backStencilMask) {
this.backStencilMask = backStencilMask;
}
public void setFrontStencilReference(int frontStencilReference) {
this.frontStencilReference = frontStencilReference;
}
public void setBackStencilReference(int backStencilReference) {
this.backStencilReference = backStencilReference;
}Since these fields directly contribute to the hash, modifying them without invalidating the cached hash results in an inconsistent RenderState.
Expected Fix
Each setter should follow the same pattern used in correctly implemented methods such as setColorWrite:
public void setColorWrite(boolean colorWrite) {
applyColorWrite = true;
this.colorWrite = colorWrite;
cachedHashCode = -1;
}This ensures that contentHashCode() always reflects the actual state of the object.
Edit:
Additionally, RenderState.flipFaceCull() should be updated to call RenderState.setFaceCullMode(FaceCullMode) so that cull changes also invalidate the cached hash.
/**
* Toggles the current face culling mode between {@code Front} and {@code Back}.
* <p>
* This method inverts the culling direction: {@code Back → Front} and
* {@code Front → Back}. Other modes ({@code Off} and {@code FrontAndBack})
* are left unchanged.
* <p>
* Useful when geometry is discovered to have reversed normals and the
* culling orientation must be corrected at runtime.
*/
public void flipFaceCull() {
switch (cullMode) {
case Back:
cullMode = FaceCullMode.Front;
break;
case Front:
cullMode = FaceCullMode.Back;
break;
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Easy first fixdefectSomething that is supposed to work, but doesn't. Less severe than a "bug"Something that is supposed to work, but doesn't. Less severe than a "bug"
Type
Projects
Status
No status