code / comment cleanup

cleanup_build_scripts
Kirill Vainer 9 years ago
parent 876015ab47
commit b6729c46d4
  1. 20
      jme3-core/src/main/java/com/jme3/material/Material.java
  2. 4
      jme3-core/src/main/java/com/jme3/material/Technique.java
  3. 12
      jme3-core/src/main/java/com/jme3/renderer/Camera.java
  4. 54
      jme3-core/src/main/java/com/jme3/renderer/RenderManager.java
  5. 3
      jme3-core/src/main/java/com/jme3/scene/VertexBuffer.java
  6. 31
      jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java

@ -75,18 +75,7 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
// Version #2: Fixed issue with RenderState.apply*** flags not getting exported // Version #2: Fixed issue with RenderState.apply*** flags not getting exported
public static final int SAVABLE_VERSION = 2; public static final int SAVABLE_VERSION = 2;
private static final Logger logger = Logger.getLogger(Material.class.getName()); private static final Logger logger = Logger.getLogger(Material.class.getName());
private static final RenderState additiveLight = new RenderState();
private static final RenderState depthOnly = new RenderState();
static {
depthOnly.setDepthTest(true);
depthOnly.setDepthWrite(true);
depthOnly.setFaceCullMode(RenderState.FaceCullMode.Back);
depthOnly.setColorWrite(false);
additiveLight.setBlendMode(RenderState.BlendMode.AlphaAdditive);
additiveLight.setDepthWrite(false);
}
private AssetKey key; private AssetKey key;
private String name; private String name;
private MaterialDef def; private MaterialDef def;
@ -98,7 +87,6 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
private boolean transparent = false; private boolean transparent = false;
private boolean receivesShadows = false; private boolean receivesShadows = false;
private int sortingId = -1; private int sortingId = -1;
private transient ColorRGBA ambientLightColor = new ColorRGBA(0, 0, 0, 1);
public Material(MaterialDef def) { public Material(MaterialDef def) {
if (def == null) { if (def == null) {
@ -742,9 +730,11 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
lastTech = techDef; lastTech = techDef;
} }
if (tech == null) { if (tech == null) {
throw new UnsupportedOperationException("No default technique on material '" + def.getName() + "'\n" throw new UnsupportedOperationException(
+ " is supported by the video hardware. The caps " String.format("No technique '%s' on material "
+ lastTech.getRequiredCaps() + " are required."); + "'%s' is supported by the video hardware. "
+ "The capabilities %s are required.",
name, def.getName(), lastTech.getRequiredCaps()));
} }
} else if (technique == tech) { } else if (technique == tech) {
// attempting to switch to an already // attempting to switch to an already

@ -183,8 +183,8 @@ public final class Technique {
* @return nothing. * @return nothing.
* *
* @deprecated Preset defines are precompiled into * @deprecated Preset defines are precompiled into
* {@link TechniqueDef#getShaderPrologue()}, whereas * {@link TechniqueDef#getShaderPrologue()}, whereas dynamic defines are
* dynamic defines are available via {@link #getParamDefines()}. * available via {@link #getParamDefines()}.
*/ */
@Deprecated @Deprecated
public DefineList getAllDefines() { public DefineList getAllDefines() {

@ -1005,12 +1005,12 @@ public class Camera implements Savable, Cloneable {
* *
* NOTE: This method is used internally for culling, for public usage, * NOTE: This method is used internally for culling, for public usage,
* the plane state of the bounding volume must be saved and restored, e.g: * the plane state of the bounding volume must be saved and restored, e.g:
* <code>BoundingVolume bv;<br/> * <code>BoundingVolume bv;<br>
* Camera c;<br/> * Camera c;<br>
* int planeState = bv.getPlaneState();<br/> * int planeState = bv.getPlaneState();<br>
* bv.setPlaneState(0);<br/> * bv.setPlaneState(0);<br>
* c.contains(bv);<br/> * c.contains(bv);<br>
* bv.setPlaneState(plateState);<br/> * bv.setPlaneState(plateState);<br>
* </code> * </code>
* *
* @param bound the bound to check for culling * @param bound the bound to check for culling

@ -74,20 +74,19 @@ import java.util.logging.Logger;
public class RenderManager { public class RenderManager {
private static final Logger logger = Logger.getLogger(RenderManager.class.getName()); private static final Logger logger = Logger.getLogger(RenderManager.class.getName());
private Renderer renderer; private final Renderer renderer;
private UniformBindingManager uniformBindingManager = new UniformBindingManager(); private final UniformBindingManager uniformBindingManager = new UniformBindingManager();
private ArrayList<ViewPort> preViewPorts = new ArrayList<ViewPort>(); private final ArrayList<ViewPort> preViewPorts = new ArrayList<>();
private ArrayList<ViewPort> viewPorts = new ArrayList<ViewPort>(); private final ArrayList<ViewPort> viewPorts = new ArrayList<>();
private ArrayList<ViewPort> postViewPorts = new ArrayList<ViewPort>(); private final ArrayList<ViewPort> postViewPorts = new ArrayList<>();
private Camera prevCam = null; private Camera prevCam = null;
private Material forcedMaterial = null; private Material forcedMaterial = null;
private String forcedTechnique = null; private String forcedTechnique = null;
private RenderState forcedRenderState = null; private RenderState forcedRenderState = null;
private final List<MatParamOverride> forcedOverrides = new ArrayList<>(); private final List<MatParamOverride> forcedOverrides = new ArrayList<>();
private int viewX, viewY, viewWidth, viewHeight; private int viewX, viewY, viewWidth, viewHeight;
private Matrix4f orthoMatrix = new Matrix4f(); private final Matrix4f orthoMatrix = new Matrix4f();
private LightList filteredLightList = new LightList(null); private final LightList filteredLightList = new LightList(null);
private String tmpTech;
private boolean handleTranlucentBucket = true; private boolean handleTranlucentBucket = true;
private AppProfiler prof; private AppProfiler prof;
private LightFilter lightFilter = new DefaultLightFilter(); private LightFilter lightFilter = new DefaultLightFilter();
@ -552,49 +551,54 @@ public class RenderManager {
* for rendering the material, and the material's own render state is ignored. * for rendering the material, and the material's own render state is ignored.
* Otherwise, the material's render state is used as intended. * Otherwise, the material's render state is used as intended.
* *
* @param g The geometry to render * @param geom The geometry to render
* *
* @see Technique * @see Technique
* @see RenderState * @see RenderState
* @see Material#selectTechnique(java.lang.String, com.jme3.renderer.RenderManager) * @see Material#selectTechnique(java.lang.String, com.jme3.renderer.RenderManager)
* @see Material#render(com.jme3.scene.Geometry, com.jme3.renderer.RenderManager) * @see Material#render(com.jme3.scene.Geometry, com.jme3.renderer.RenderManager)
*/ */
public void renderGeometry(Geometry g) { public void renderGeometry(Geometry geom) {
if (g.isIgnoreTransform()) { if (geom.isIgnoreTransform()) {
setWorldMatrix(Matrix4f.IDENTITY); setWorldMatrix(Matrix4f.IDENTITY);
} else { } else {
setWorldMatrix(g.getWorldMatrix()); setWorldMatrix(geom.getWorldMatrix());
} }
// Perform light filtering if we have a light filter. // Perform light filtering if we have a light filter.
LightList lightList = g.getWorldLightList(); LightList lightList = geom.getWorldLightList();
if (lightFilter != null) { if (lightFilter != null) {
filteredLightList.clear(); filteredLightList.clear();
lightFilter.filterLights(g, filteredLightList); lightFilter.filterLights(geom, filteredLightList);
lightList = filteredLightList; lightList = filteredLightList;
} }
Material material = geom.getMaterial();
//if forcedTechnique we try to force it for render, //if forcedTechnique we try to force it for render,
//if it does not exists in the mat def, we check for forcedMaterial and render the geom if not null //if it does not exists in the mat def, we check for forcedMaterial and render the geom if not null
//else the geom is not rendered //else the geom is not rendered
if (forcedTechnique != null) { if (forcedTechnique != null) {
MaterialDef matDef = g.getMaterial().getMaterialDef(); MaterialDef matDef = material.getMaterialDef();
if (matDef.getTechniqueDefs(forcedTechnique) != null) { if (matDef.getTechniqueDefs(forcedTechnique) != null) {
tmpTech = g.getMaterial().getActiveTechnique() != null
? g.getMaterial().getActiveTechnique().getDef().getName() Technique activeTechnique = material.getActiveTechnique();
String previousTechniqueName = activeTechnique != null
? activeTechnique.getDef().getName()
: TechniqueDef.DEFAULT_TECHNIQUE_NAME; : TechniqueDef.DEFAULT_TECHNIQUE_NAME;
g.getMaterial().selectTechnique(forcedTechnique, this);
geom.getMaterial().selectTechnique(forcedTechnique, this);
//saving forcedRenderState for future calls //saving forcedRenderState for future calls
RenderState tmpRs = forcedRenderState; RenderState tmpRs = forcedRenderState;
if (g.getMaterial().getActiveTechnique().getDef().getForcedRenderState() != null) { if (geom.getMaterial().getActiveTechnique().getDef().getForcedRenderState() != null) {
//forcing forced technique renderState //forcing forced technique renderState
forcedRenderState = g.getMaterial().getActiveTechnique().getDef().getForcedRenderState(); forcedRenderState = geom.getMaterial().getActiveTechnique().getDef().getForcedRenderState();
} }
// use geometry's material // use geometry's material
g.getMaterial().render(g, lightList, this); material.render(geom, lightList, this);
g.getMaterial().selectTechnique(tmpTech, this); material.selectTechnique(previousTechniqueName, this);
//restoring forcedRenderState //restoring forcedRenderState
forcedRenderState = tmpRs; forcedRenderState = tmpRs;
@ -603,13 +607,13 @@ public class RenderManager {
//If forcedTechnique does not exists, and forcedMaterial is not set, the geom MUST NOT be rendered //If forcedTechnique does not exists, and forcedMaterial is not set, the geom MUST NOT be rendered
} else if (forcedMaterial != null) { } else if (forcedMaterial != null) {
// use forced material // use forced material
forcedMaterial.render(g, lightList, this); forcedMaterial.render(geom, lightList, this);
} }
} else if (forcedMaterial != null) { } else if (forcedMaterial != null) {
// use forced material // use forced material
forcedMaterial.render(g, lightList, this); forcedMaterial.render(geom, lightList, this);
} else { } else {
g.getMaterial().render(g, lightList, this); material.render(geom, lightList, this);
} }
} }

@ -108,8 +108,7 @@ public class VertexBuffer extends NativeObject implements Savable, Cloneable {
* Do not use. * Do not use.
*/ */
@Deprecated @Deprecated
MiscAttrib, Reserved0,
/** /**
* Specifies the index buffer, must contain integer data * Specifies the index buffer, must contain integer data
* (ubyte, ushort, or uint). * (ubyte, ushort, or uint).

@ -79,14 +79,14 @@ public class J3MLoader implements AssetLoader {
private RenderState renderState; private RenderState renderState;
private ArrayList<String> presetDefines = new ArrayList<String>(); private ArrayList<String> presetDefines = new ArrayList<String>();
private EnumMap<Shader.ShaderType, String> shaderLanguage; private EnumMap<Shader.ShaderType, String> shaderLanguages;
private EnumMap<Shader.ShaderType, String> shaderName; private EnumMap<Shader.ShaderType, String> shaderNames;
private static final String whitespacePattern = "\\p{javaWhitespace}+"; private static final String whitespacePattern = "\\p{javaWhitespace}+";
public J3MLoader() { public J3MLoader() {
shaderLanguage = new EnumMap<Shader.ShaderType, String>(Shader.ShaderType.class); shaderLanguages = new EnumMap<>(Shader.ShaderType.class);
shaderName = new EnumMap<Shader.ShaderType, String>(Shader.ShaderType.class); shaderNames = new EnumMap<>(Shader.ShaderType.class);
} }
@ -109,8 +109,8 @@ public class J3MLoader implements AssetLoader {
} }
private void readShaderDefinition(Shader.ShaderType shaderType, String name, String language) { private void readShaderDefinition(Shader.ShaderType shaderType, String name, String language) {
shaderName.put(shaderType, name); shaderNames.put(shaderType, name);
shaderLanguage.put(shaderType, language); shaderLanguages.put(shaderType, language);
} }
// LightMode <MODE> // LightMode <MODE>
@ -120,10 +120,6 @@ public class J3MLoader implements AssetLoader {
throw new IOException("LightMode statement syntax incorrect"); throw new IOException("LightMode statement syntax incorrect");
} }
LightMode lm = LightMode.valueOf(split[1]); LightMode lm = LightMode.valueOf(split[1]);
if (lm == LightMode.FixedPipeline) {
throw new UnsupportedOperationException("OpenGL1 is not supported");
}
technique.setLightMode(lm); technique.setLightMode(lm);
} }
@ -453,8 +449,7 @@ public class J3MLoader implements AssetLoader {
}else if (split[0].equals("Blend")){ }else if (split[0].equals("Blend")){
renderState.setBlendMode(BlendMode.valueOf(split[1])); renderState.setBlendMode(BlendMode.valueOf(split[1]));
}else if (split[0].equals("AlphaTestFalloff")){ }else if (split[0].equals("AlphaTestFalloff")){
renderState.setAlphaTest(true); // Ignore for backwards compatbility
renderState.setAlphaFallOff(Float.parseFloat(split[1]));
}else if (split[0].equals("PolyOffset")){ }else if (split[0].equals("PolyOffset")){
float factor = Float.parseFloat(split[1]); float factor = Float.parseFloat(split[1]);
float units = Float.parseFloat(split[2]); float units = Float.parseFloat(split[2]);
@ -462,7 +457,7 @@ public class J3MLoader implements AssetLoader {
}else if (split[0].equals("ColorWrite")){ }else if (split[0].equals("ColorWrite")){
renderState.setColorWrite(parseBoolean(split[1])); renderState.setColorWrite(parseBoolean(split[1]));
}else if (split[0].equals("PointSprite")){ }else if (split[0].equals("PointSprite")){
renderState.setPointSprite(parseBoolean(split[1])); // Ignore for backwards compatbility
}else if (split[0].equals("DepthFunc")){ }else if (split[0].equals("DepthFunc")){
renderState.setDepthFunc(RenderState.TestFunction.valueOf(split[1])); renderState.setDepthFunc(RenderState.TestFunction.valueOf(split[1]));
}else if (split[0].equals("AlphaFunc")){ }else if (split[0].equals("AlphaFunc")){
@ -622,8 +617,8 @@ public class J3MLoader implements AssetLoader {
technique.setShaderFile(technique.hashCode() + "", technique.hashCode() + "", "GLSL100", "GLSL100"); technique.setShaderFile(technique.hashCode() + "", technique.hashCode() + "", "GLSL100", "GLSL100");
} }
if (shaderName.containsKey(Shader.ShaderType.Vertex) && shaderName.containsKey(Shader.ShaderType.Fragment)) { if (shaderNames.containsKey(Shader.ShaderType.Vertex) && shaderNames.containsKey(Shader.ShaderType.Fragment)) {
technique.setShaderFile(shaderName, shaderLanguage); technique.setShaderFile(shaderNames, shaderLanguages);
} }
technique.setShaderPrologue(createShaderPrologue(presetDefines)); technique.setShaderPrologue(createShaderPrologue(presetDefines));
@ -644,8 +639,8 @@ public class J3MLoader implements AssetLoader {
materialDef.addTechniqueDef(technique); materialDef.addTechniqueDef(technique);
technique = null; technique = null;
shaderLanguage.clear(); shaderLanguages.clear();
shaderName.clear(); shaderNames.clear();
presetDefines.clear(); presetDefines.clear();
} }
@ -767,7 +762,7 @@ public class J3MLoader implements AssetLoader {
protected void initNodesLoader() { protected void initNodesLoader() {
if (!isUseNodes) { if (!isUseNodes) {
isUseNodes = shaderName.get(Shader.ShaderType.Vertex) == null && shaderName.get(Shader.ShaderType.Fragment) == null; isUseNodes = shaderNames.get(Shader.ShaderType.Vertex) == null && shaderNames.get(Shader.ShaderType.Fragment) == null;
if (isUseNodes) { if (isUseNodes) {
if (nodesLoaderDelegate == null) { if (nodesLoaderDelegate == null) {
nodesLoaderDelegate = new ShaderNodeLoaderDelegate(); nodesLoaderDelegate = new ShaderNodeLoaderDelegate();

Loading…
Cancel
Save