From 45e7c5626da37a1b7459b06a4a24df039462eae9 Mon Sep 17 00:00:00 2001 From: Wyatt Gillette Date: Tue, 24 Jun 2025 16:04:11 +0200 Subject: [PATCH] Update VarType.java --- .../main/java/com/jme3/shader/VarType.java | 58 +++++++++++++++++-- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/shader/VarType.java b/jme3-core/src/main/java/com/jme3/shader/VarType.java index ebf7edc64c..1a864f9b1a 100644 --- a/jme3-core/src/main/java/com/jme3/shader/VarType.java +++ b/jme3-core/src/main/java/com/jme3/shader/VarType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2024 jMonkeyEngine + * Copyright (c) 2009-2025 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,6 +45,9 @@ import com.jme3.texture.TextureCubeMap; import com.jme3.texture.TextureImage; +/** + * Enum representing various GLSL variable types and their corresponding Java types. + */ public enum VarType { Float("float", float.class, Float.class), @@ -59,7 +62,7 @@ public enum VarType { Vector4Array(true, false, "vec4", Vector4f[].class), Int("int", int.class, Integer.class), - Boolean("bool", Boolean.class, boolean.class), + Boolean("bool", boolean.class, Boolean.class), Matrix3(true, false, "mat3", Matrix3f.class), Matrix4(true, false, "mat4", Matrix4f.class), @@ -83,8 +86,14 @@ public enum VarType { private boolean textureType = false; private boolean imageType = false; private final String glslType; - private Class[] javaTypes; + private final Class[] javaTypes; + /** + * Constructs a VarType with the specified GLSL type and corresponding Java types. + * + * @param glslType the GLSL type name(s) + * @param javaTypes the Java classes mapped to this GLSL type + */ VarType(String glslType, Class... javaTypes) { this.glslType = glslType; if (javaTypes != null) { @@ -94,6 +103,14 @@ public enum VarType { } } + /** + * Constructs a VarType with additional flags for multi-data and texture types. + * + * @param multiData true if this type uses multiple data elements (e.g. arrays, matrices) + * @param textureType true if this type represents a texture sampler + * @param glslType the GLSL type name(s) + * @param javaTypes the Java classes mapped to this GLSL type + */ VarType(boolean multiData, boolean textureType, String glslType, Class... javaTypes) { this.usesMultiData = multiData; this.textureType = textureType; @@ -104,7 +121,16 @@ public enum VarType { this.javaTypes = new Class[0]; } } - + + /** + * Constructs a VarType with flags for multi-data, texture, and image types. + * + * @param multiData true if this type uses multiple data elements + * @param textureType true if this type represents a texture sampler + * @param imageType true if this type represents an image + * @param glslType the GLSL type name(s) + * @param javaTypes the Java classes mapped to this GLSL type + */ VarType(boolean multiData, boolean textureType, boolean imageType, String glslType, Class... javaTypes) { this(multiData, textureType, glslType, javaTypes); this.imageType = imageType; @@ -127,25 +153,45 @@ public boolean isOfType(Object o) { /** * Get the java types mapped to this VarType - * + * * @return an array of classes mapped to this VarType */ public Class[] getJavaType() { return javaTypes; } + /** + * Returns whether this VarType represents a texture sampler type. + * + * @return true if this is a texture type, false otherwise + */ public boolean isTextureType() { return textureType; } - + + /** + * Returns whether this VarType represents an image type. + * + * @return true if this is an image type, false otherwise + */ public boolean isImageType() { return imageType; } + /** + * Returns whether this VarType uses multiple data elements (e.g. arrays or matrices). + * + * @return true if this type uses multiple data elements, false otherwise + */ public boolean usesMultiData() { return usesMultiData; } + /** + * Returns the GLSL type name(s) associated with this VarType. + * + * @return the GLSL type string (e.g. "float", "vec3", "sampler2D") + */ public String getGlslType() { return glslType; }