fix block meshgen indices bug
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2025-03-26 17:47:33 -04:00
parent 922a284ca0
commit f048b26064
6 changed files with 62 additions and 52 deletions

View File

@ -1,3 +1,3 @@
#maven.buildNumber.plugin properties file
#Sat Jan 25 16:45:57 EST 2025
buildNumber=605
#Wed Mar 26 17:14:44 EDT 2025
buildNumber=606

View File

@ -1322,6 +1322,9 @@ Fix bugs with block chunks not being marked as non-homogenous after editing
(03/24/2025)
Fix entity swap button resetting position
(03/26/2025)
Fix block meshgen not incrementing indices correctly
# TODO
@ -1379,6 +1382,10 @@ Scripting enhancements
Code Generation
- Generate static "hasXComponent", "getXComponent" functions on sync'd components
Wrapper callback to debounce a function
- ie, wrap a given block of code with some special functional class
- the wrapper lets you specify how frequently the code can execute
Rearchitecting
- Main render is a ui element (that we can have multiple of)
- Shader injecting consts from the engine itself (ie max lights is dynamically injected, that way never have to worry about .glsl and .java not aligning)

View File

@ -37,7 +37,7 @@ public class ImGuiEntityActorTab {
CommonEntityType commonEntityData = CommonEntityUtils.getCommonData(detailViewEntity);
//procedural model
if(commonEntityData.getGraphicsTemplate().getProceduralModel() != null && ImGui.collapsingHeader("Procedural Model")){
if(commonEntityData != null && commonEntityData.getGraphicsTemplate().getProceduralModel() != null && ImGui.collapsingHeader("Procedural Model")){
ImGui.text("Procedural Model path: " + commonEntityData.getGraphicsTemplate().getProceduralModel());
if(ImGui.button("Regenerate")){
if(commonEntityData.getGraphicsTemplate().getProceduralModel().getTreeModel() != null){
@ -50,6 +50,8 @@ public class ImGuiEntityActorTab {
}
} else {
ImGui.text("Model path: " + actor.getModelPath());
Model loadedModel = Globals.assetManager.fetchModel(actor.getModelPath());
ImGui.text("Model is loaded: " + (loadedModel != null));
}
//mesh mask

View File

@ -75,14 +75,14 @@ public class BlockChunkEntity {
}
rVal.putData(EntityDataStrings.HAS_UNIQUE_MODEL, true);
} else {
if(notifyTarget != null){
notifyTarget.alertToGeneration();
}
if(toDelete != null){
ClientEntityUtils.destroyEntity(toDelete);
}
LoggerInterface.loggerEngine.DEBUG("Finished generating block polygons; however, entity has already been deleted.");
}
if(notifyTarget != null){
notifyTarget.alertToGeneration();
}
if(toDelete != null){
ClientEntityUtils.destroyEntity(toDelete);
}
} catch (Error e){
LoggerInterface.loggerEngine.ERROR(e);
} catch(Exception e){

View File

@ -119,8 +119,9 @@ public class BlockMeshgen {
* @param quad The quad
* @param depth The depth of the box
* @param blockType The type of block
* @param indexOffset The offset for the indices that will be added (ie, if there are already vertices in the verts list, pass in the size of the vert list)
*/
protected static void meshifyBox(List<Vector3f> verts, List<Vector3f> normals, List<Vector2f> uvs, List<Integer> indices, List<Integer> samplers, QuadMesh quad, int depth, int blockType){
protected static void meshifyBox(List<Vector3f> verts, List<Vector3f> normals, List<Vector2f> uvs, List<Integer> indices, List<Integer> samplers, QuadMesh quad, int depth, int blockType, int indexOffset){
//
//face 1
//
@ -131,12 +132,12 @@ public class BlockMeshgen {
verts.add(new Vector3f(quad.x, quad.y + quad.h, quad.z).mul(BlockChunkData.BLOCK_SIZE_MULTIPLIER));
verts.add(new Vector3f(quad.x + quad.w, quad.y + quad.h, quad.z).mul(BlockChunkData.BLOCK_SIZE_MULTIPLIER));
//indices
indices.add(0);
indices.add(2);
indices.add(3);
indices.add(0);
indices.add(3);
indices.add(1);
indices.add(indexOffset + 0);
indices.add(indexOffset + 2);
indices.add(indexOffset + 3);
indices.add(indexOffset + 0);
indices.add(indexOffset + 3);
indices.add(indexOffset + 1);
//normals
normals.add(new Vector3f(0,0,-1));
normals.add(new Vector3f(0,0,-1));
@ -158,12 +159,12 @@ public class BlockMeshgen {
verts.add(new Vector3f(quad.x, quad.y + quad.h, quad.z ).mul(BlockChunkData.BLOCK_SIZE_MULTIPLIER));
verts.add(new Vector3f(quad.x, quad.y + quad.h, quad.z + depth).mul(BlockChunkData.BLOCK_SIZE_MULTIPLIER));
//indices
indices.add(4);
indices.add(7);
indices.add(6);
indices.add(4);
indices.add(5);
indices.add(7);
indices.add(indexOffset + 4);
indices.add(indexOffset + 7);
indices.add(indexOffset + 6);
indices.add(indexOffset + 4);
indices.add(indexOffset + 5);
indices.add(indexOffset + 7);
//normals
normals.add(new Vector3f(-1,0,0));
normals.add(new Vector3f(-1,0,0));
@ -185,12 +186,12 @@ public class BlockMeshgen {
verts.add(new Vector3f(quad.x + quad.w, quad.y, quad.z ).mul(BlockChunkData.BLOCK_SIZE_MULTIPLIER));
verts.add(new Vector3f(quad.x + quad.w, quad.y, quad.z + depth).mul(BlockChunkData.BLOCK_SIZE_MULTIPLIER));
//indices
indices.add( 8);
indices.add(10);
indices.add(11);
indices.add( 9);
indices.add( 8);
indices.add(11);
indices.add(indexOffset + 8);
indices.add(indexOffset + 10);
indices.add(indexOffset + 11);
indices.add(indexOffset + 9);
indices.add(indexOffset + 8);
indices.add(indexOffset + 11);
//normals
normals.add(new Vector3f(0,-1,0));
normals.add(new Vector3f(0,-1,0));
@ -212,12 +213,12 @@ public class BlockMeshgen {
verts.add(new Vector3f(quad.x, quad.y + quad.h, quad.z + depth).mul(BlockChunkData.BLOCK_SIZE_MULTIPLIER));
verts.add(new Vector3f(quad.x + quad.w, quad.y + quad.h, quad.z + depth).mul(BlockChunkData.BLOCK_SIZE_MULTIPLIER));
//indices
indices.add(12);
indices.add(15);
indices.add(14);
indices.add(12);
indices.add(13);
indices.add(15);
indices.add(indexOffset + 12);
indices.add(indexOffset + 15);
indices.add(indexOffset + 14);
indices.add(indexOffset + 12);
indices.add(indexOffset + 13);
indices.add(indexOffset + 15);
//normals
normals.add(new Vector3f(0,0,1));
normals.add(new Vector3f(0,0,1));
@ -240,12 +241,12 @@ public class BlockMeshgen {
verts.add(new Vector3f(quad.x + quad.w, quad.y + quad.h, quad.z ).mul(BlockChunkData.BLOCK_SIZE_MULTIPLIER));
verts.add(new Vector3f(quad.x + quad.w, quad.y + quad.h, quad.z + depth).mul(BlockChunkData.BLOCK_SIZE_MULTIPLIER));
//indices
indices.add(16);
indices.add(18);
indices.add(19);
indices.add(16);
indices.add(19);
indices.add(17);
indices.add(indexOffset + 16);
indices.add(indexOffset + 18);
indices.add(indexOffset + 19);
indices.add(indexOffset + 16);
indices.add(indexOffset + 19);
indices.add(indexOffset + 17);
//normals
normals.add(new Vector3f(1,0,0));
normals.add(new Vector3f(1,0,0));
@ -267,13 +268,13 @@ public class BlockMeshgen {
verts.add(new Vector3f(quad.x, quad.y + quad.h, quad.z + depth).mul(BlockChunkData.BLOCK_SIZE_MULTIPLIER));
verts.add(new Vector3f(quad.x + quad.w, quad.y + quad.h, quad.z ).mul(BlockChunkData.BLOCK_SIZE_MULTIPLIER));
verts.add(new Vector3f(quad.x + quad.w, quad.y + quad.h, quad.z + depth).mul(BlockChunkData.BLOCK_SIZE_MULTIPLIER));
//indices
indices.add(20);
indices.add(23);
indices.add(22);
indices.add(20);
indices.add(21);
indices.add(23);
//indicesindexOffset +
indices.add(indexOffset + 20);
indices.add(indexOffset + 23);
indices.add(indexOffset + 22);
indices.add(indexOffset + 20);
indices.add(indexOffset + 21);
indices.add(indexOffset + 23);
//normals
normals.add(new Vector3f(0,1,0));
normals.add(new Vector3f(0,1,0));
@ -322,7 +323,7 @@ public class BlockMeshgen {
if(quad1.x == quad2.x && quad1.y == quad2.y && quad1.w == quad2.w && quad1.h == quad2.h && quad1.z + zEnd == quad2.z){
zEnd++;
} else {
BlockMeshgen.meshifyBox(verts,normals,uvs,indices,samplers,quad1,zEnd,quad1.type);
BlockMeshgen.meshifyBox(verts,normals,uvs,indices,samplers,quad1,zEnd,quad1.type,verts.size());
quad1 = quad2;
zEnd = 1;
break;
@ -331,7 +332,7 @@ public class BlockMeshgen {
i = i + zEnd;
}
if(quad1 != null){
BlockMeshgen.meshifyBox(verts,normals,uvs,indices,samplers,quad1,zEnd,quad1.type);
BlockMeshgen.meshifyBox(verts,normals,uvs,indices,samplers,quad1,zEnd,quad1.type,verts.size());
}
//

View File

@ -240,7 +240,7 @@ public class BlockMeshgenTests {
QuadMesh quad = new QuadMesh(0, 0, 0, 1, 1,1);
//call
BlockMeshgen.meshifyBox(verts, normals, uvs, indices, samplers, quad, 1, 1);
BlockMeshgen.meshifyBox(verts, normals, uvs, indices, samplers, quad, 1, 1, 0);
//error check result
@ -301,7 +301,7 @@ public class BlockMeshgenTests {
QuadMesh quad = new QuadMesh(0, 0, 0, 1, 1, 1);
//call
BlockMeshgen.meshifyBox(verts, normals, uvs, indices, samplers, quad, 1, 1);
BlockMeshgen.meshifyBox(verts, normals, uvs, indices, samplers, quad, 1, 1, 0);
//error check result
@ -360,7 +360,7 @@ public class BlockMeshgenTests {
QuadMesh quad = new QuadMesh(0, 0, 0, 1, 1, 1);
//call
BlockMeshgen.meshifyBox(verts, normals, uvs, indices, samplers, quad, 1, 1);
BlockMeshgen.meshifyBox(verts, normals, uvs, indices, samplers, quad, 1, 1, 0);
//error check result