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
public static final int SAVABLE_VERSION = 2;
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 String name;
private MaterialDef def;
@ -98,7 +87,6 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
private boolean transparent = false;
private boolean receivesShadows = false;
private int sortingId = -1;
private transient ColorRGBA ambientLightColor = new ColorRGBA(0, 0, 0, 1);
public Material(MaterialDef def) {
if (def == null) {
@ -742,9 +730,11 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
lastTech = techDef;
}
if (tech == null) {
throw new UnsupportedOperationException("No default technique on material '" + def.getName() + "'\n"
+ " is supported by the video hardware. The caps "
+ lastTech.getRequiredCaps() + " are required.");
throw new UnsupportedOperationException(
String.format("No technique '%s' on material "
+ "'%s' is supported by the video hardware. "
+ "The capabilities %s are required.",
name, def.getName(), lastTech.getRequiredCaps()));
}
} else if (technique == tech) {
// attempting to switch to an already

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

@ -1005,12 +1005,12 @@ public class Camera implements Savable, Cloneable {
*
* 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:
* <code>BoundingVolume bv;<br/>
* Camera c;<br/>
* int planeState = bv.getPlaneState();<br/>
* bv.setPlaneState(0);<br/>
* c.contains(bv);<br/>
* bv.setPlaneState(plateState);<br/>
* <code>BoundingVolume bv;<br>
* Camera c;<br>
* int planeState = bv.getPlaneState();<br>
* bv.setPlaneState(0);<br>
* c.contains(bv);<br>
* bv.setPlaneState(plateState);<br>
* </code>
*
* @param bound the bound to check for culling

@ -74,20 +74,19 @@ import java.util.logging.Logger;
public class RenderManager {
private static final Logger logger = Logger.getLogger(RenderManager.class.getName());
private Renderer renderer;
private UniformBindingManager uniformBindingManager = new UniformBindingManager();
private ArrayList<ViewPort> preViewPorts = new ArrayList<ViewPort>();
private ArrayList<ViewPort> viewPorts = new ArrayList<ViewPort>();
private ArrayList<ViewPort> postViewPorts = new ArrayList<ViewPort>();
private final Renderer renderer;
private final UniformBindingManager uniformBindingManager = new UniformBindingManager();
private final ArrayList<ViewPort> preViewPorts = new ArrayList<>();
private final ArrayList<ViewPort> viewPorts = new ArrayList<>();
private final ArrayList<ViewPort> postViewPorts = new ArrayList<>();
private Camera prevCam = null;
private Material forcedMaterial = null;
private String forcedTechnique = null;
private RenderState forcedRenderState = null;
private final List<MatParamOverride> forcedOverrides = new ArrayList<>();
private int viewX, viewY, viewWidth, viewHeight;
private Matrix4f orthoMatrix = new Matrix4f();
private LightList filteredLightList = new LightList(null);
private String tmpTech;
private final Matrix4f orthoMatrix = new Matrix4f();
private final LightList filteredLightList = new LightList(null);
private boolean handleTranlucentBucket = true;
private AppProfiler prof;
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.
* 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 RenderState
* @see Material#selectTechnique(java.lang.String, com.jme3.renderer.RenderManager)
* @see Material#render(com.jme3.scene.Geometry, com.jme3.renderer.RenderManager)
*/
public void renderGeometry(Geometry g) {
if (g.isIgnoreTransform()) {
public void renderGeometry(Geometry geom) {
if (geom.isIgnoreTransform()) {
setWorldMatrix(Matrix4f.IDENTITY);
} else {
setWorldMatrix(g.getWorldMatrix());
setWorldMatrix(geom.getWorldMatrix());
}
// Perform light filtering if we have a light filter.
LightList lightList = g.getWorldLightList();
LightList lightList = geom.getWorldLightList();
if (lightFilter != null) {
filteredLightList.clear();
lightFilter.filterLights(g, filteredLightList);
lightFilter.filterLights(geom, filteredLightList);
lightList = filteredLightList;
}
Material material = geom.getMaterial();
//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
//else the geom is not rendered
if (forcedTechnique != null) {
MaterialDef matDef = g.getMaterial().getMaterialDef();
MaterialDef matDef = material.getMaterialDef();
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;
g.getMaterial().selectTechnique(forcedTechnique, this);
geom.getMaterial().selectTechnique(forcedTechnique, this);
//saving forcedRenderState for future calls
RenderState tmpRs = forcedRenderState;
if (g.getMaterial().getActiveTechnique().getDef().getForcedRenderState() != null) {
if (geom.getMaterial().getActiveTechnique().getDef().getForcedRenderState() != null) {
//forcing forced technique renderState
forcedRenderState = g.getMaterial().getActiveTechnique().getDef().getForcedRenderState();
forcedRenderState = geom.getMaterial().getActiveTechnique().getDef().getForcedRenderState();
}
// use geometry's material
g.getMaterial().render(g, lightList, this);
g.getMaterial().selectTechnique(tmpTech, this);
material.render(geom, lightList, this);
material.selectTechnique(previousTechniqueName, this);
//restoring forcedRenderState
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
} else if (forcedMaterial != null) {
// use forced material
forcedMaterial.render(g, lightList, this);
forcedMaterial.render(geom, lightList, this);
}
} else if (forcedMaterial != null) {
// use forced material
forcedMaterial.render(g, lightList, this);
forcedMaterial.render(geom, lightList, this);
} 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.
*/
@Deprecated
MiscAttrib,
Reserved0,
/**
* Specifies the index buffer, must contain integer data
* (ubyte, ushort, or uint).

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

Loading…
Cancel
Save