Skip to content

Commit

Permalink
Made extension loaders non-static to avoid concurrency issues (#1886)
Browse files Browse the repository at this point in the history
Now each GltfLoader instantiated via ThreadLocal will have its own instances of extension loaders.
  • Loading branch information
Ali-RS authored Dec 28, 2022
1 parent 9c3d363 commit 1e237f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ public class CustomContentManager {
private GltfModelKey key;
private GltfLoader gltfLoader;

private static Map<String, ExtensionLoader> defaultExtensionLoaders = new HashMap<>();
private final Map<String, ExtensionLoader> defaultExtensionLoaders = new HashMap<>();

static {
public CustomContentManager() {
defaultExtensionLoaders.put("KHR_materials_pbrSpecularGlossiness", new PBRSpecGlossExtensionLoader());
defaultExtensionLoaders.put("KHR_lights_punctual", new LightsPunctualExtensionLoader());
defaultExtensionLoaders.put("KHR_materials_unlit", new UnlitExtensionLoader());
defaultExtensionLoaders.put("KHR_texture_transform", new TextureTransformExtensionLoader());
defaultExtensionLoaders.put("KHR_texture_transform", new TextureTransformExtensionLoader());
}

void init(GltfLoader gltfLoader) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class GltfLoader implements AssetLoader {
private static final Logger logger = Logger.getLogger(GltfLoader.class.getName());

// Data cache for already parsed JME objects
private Map<String, Object[]> dataCache = new HashMap<>();
private final Map<String, Object[]> dataCache = new HashMap<>();
private JsonArray scenes;
private JsonArray nodes;
private JsonArray meshes;
Expand All @@ -85,12 +85,12 @@ public class GltfLoader implements AssetLoader {
private JsonObject docRoot;
private Node rootNode;

private FloatArrayPopulator floatArrayPopulator = new FloatArrayPopulator();
private Vector3fArrayPopulator vector3fArrayPopulator = new Vector3fArrayPopulator();
private QuaternionArrayPopulator quaternionArrayPopulator = new QuaternionArrayPopulator();
private Matrix4fArrayPopulator matrix4fArrayPopulator = new Matrix4fArrayPopulator();
private Map<String, MaterialAdapter> defaultMaterialAdapters = new HashMap<>();
private CustomContentManager customContentManager = new CustomContentManager();
private final FloatArrayPopulator floatArrayPopulator = new FloatArrayPopulator();
private final Vector3fArrayPopulator vector3fArrayPopulator = new Vector3fArrayPopulator();
private final QuaternionArrayPopulator quaternionArrayPopulator = new QuaternionArrayPopulator();
private final Matrix4fArrayPopulator matrix4fArrayPopulator = new Matrix4fArrayPopulator();
private final Map<String, MaterialAdapter> defaultMaterialAdapters = new HashMap<>();
private final CustomContentManager customContentManager = new CustomContentManager();
private boolean useNormalsFlag = false;

Map<SkinData, List<Spatial>> skinnedSpatials = new HashMap<>();
Expand Down

0 comments on commit 1e237f3

Please sign in to comment.