Skip to content

Commit

Permalink
added Mesh smoothing
Browse files Browse the repository at this point in the history
  • Loading branch information
i-make-robots committed Dec 17, 2023
1 parent df50f84 commit f2f83d9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/marginallyclever/ro3/Registry.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.marginallyclever.ro3.render.RenderPass;
import com.marginallyclever.ro3.render.renderpasses.DrawBackground;
import com.marginallyclever.ro3.render.renderpasses.DrawMeshes;
import com.marginallyclever.ro3.render.renderpasses.DrawPose;
import com.marginallyclever.ro3.render.renderpasses.DrawPoses;
import com.marginallyclever.ro3.texture.TextureFactory;

/**
Expand Down Expand Up @@ -34,6 +34,6 @@ public static void start() {

renderPasses.add(new DrawBackground());
renderPasses.add(new DrawMeshes());
renderPasses.add(new DrawPose());
renderPasses.add(new DrawPoses());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static void smoothModel(String inName,String outName,float vertexEpsilon,
* @param vertexEpsilon how close should points be to be considered one and the same. typically ~0.001
* @param normalEpsilon how close should normals be to be merged. 0...2 larger values more smoothing.
*/
private static void smoothNormals(Mesh model,float vertexEpsilon,float normalEpsilon) {
public static void smoothNormals(Mesh model,float vertexEpsilon,float normalEpsilon) {
float vertexEpsilonSquared = vertexEpsilon * vertexEpsilon;
float normalEpsilonSquared = normalEpsilon * normalEpsilon;

Expand All @@ -63,8 +63,7 @@ private static void smoothNormals(Mesh model,float vertexEpsilon,float normalEps
for(i=0;i<numFaces;++i) {
if(skip[i]) continue;

logger.info("Smoothing "+i);

logger.info("Smoothing "+i+"/"+numFaces);

// find vertices that are in the same position
float p1x = model.vertexArray.get(i*3+0);
Expand Down Expand Up @@ -129,7 +128,6 @@ private static void smoothNormals(Mesh model,float vertexEpsilon,float normalEps
}
model.setDirty(true);
}


private static float lengthDifferenceSquared(float p1x,float p1y,float p1z,float p2x,float p2y,float p2z) {
float dx = p2x-p1x;
Expand Down

0 comments on commit f2f83d9

Please sign in to comment.