-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve GLTF support #2069
base: master
Are you sure you want to change the base?
Improve GLTF support #2069
Conversation
… the first instance of a spatial from poisoning the cache.
…nto packages named after their fully qualified name
final float volume = jsonObject.getAsJsonPrimitive("volume").getAsFloat(); | ||
final float pitch = jsonObject.getAsJsonPrimitive("pitch").getAsFloat(); | ||
final float attenuation = jsonObject.getAsJsonPrimitive("attenuation").getAsFloat(); // unused | ||
final float distanceMax = jsonObject.getAsJsonPrimitive("distance_max").getAsFloat(); | ||
final float distanceReference = jsonObject.getAsJsonPrimitive("distance_reference").getAsFloat(); | ||
final float volume_min = jsonObject.getAsJsonPrimitive("volume_min").getAsFloat(); // unused | ||
final float volume_max = jsonObject.getAsJsonPrimitive("volume_max").getAsFloat(); // unused | ||
final float angleOuterCone = jsonObject.getAsJsonPrimitive("angle_outer_cone").getAsFloat(); | ||
final float angleInnerCone = jsonObject.getAsJsonPrimitive("angle_inner_cone").getAsFloat(); | ||
final float outerConeVolume = jsonObject.getAsJsonPrimitive("outer_cone_volume").getAsFloat(); // unused | ||
final String soundPath = jsonObject.getAsJsonPrimitive("sound_path").getAsString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Properties are named in camel case in the rest of the Gltf extensions so I would suggest keeping the same naming convention here as well, please. (i.e. distance_max
-> distanceMax
,...)
@@ -63,7 +61,7 @@ public abstract class MaterialAdapter { | |||
|
|||
protected abstract MatParam adaptMatParam(MatParam param); | |||
|
|||
protected void init(AssetManager assetManager) { | |||
public void init(AssetManager assetManager) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why method access modifier is changed to "public" here?
/* | ||
* $Id$ | ||
* | ||
* Copyright (c) 2019, Simsilica, LLC | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in | ||
* the documentation and/or other materials provided with the | ||
* distribution. | ||
* | ||
* 3. Neither the name of the copyright holder nor the names of its | ||
* contributors may be used to endorse or promote products derived | ||
* from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | ||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
* OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move the copyright notice to the top.
public Object handleExtras( | ||
GltfLoader loader, | ||
String parentName, | ||
JsonElement parent, | ||
JsonElement extras, | ||
Object input | ||
) { | ||
log.fine( | ||
"handleExtras(" + | ||
loader + | ||
", " + | ||
parentName + | ||
", " + | ||
parent + | ||
", " + | ||
extras + | ||
", " + | ||
input + | ||
")" | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the code-formatting here and some other places, I like to place them in one line until the line length exceeds the max length, only then I would move them to the new line but this is just my own preference, not sure about others though!
Edit:
FYI, this is how the original code is formatted, which sounds nicer to me.
(4 lines vs. 20 lines)
@riccardobl thanks for your contribution Please update the copyright date to 2023 on the modified classes. |
} else if (jp.isString()) { | ||
return jp.getAsString(); | ||
} | ||
log.fine("Unhandled primitive:" + jp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems this should be a "warning"?
} else if (el instanceof JsonPrimitive) { | ||
return toAttribute(el.getAsJsonPrimitive(), nested); | ||
} | ||
log.fine("Unhandled extras element:" + el); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems this should be a "warning"?
In general, a PR should do one thing. The scope of a PR should be narrow, addressing a single refactor, issue, or feature. See Creating Good Pull Requests. According to the description, this PR includes 3 new features, a bug fix, and major refactoring. I request that the changes be split up into multiple PRs. This will make the changes easier to understand and review. |
You are right, but since i am submitting these PRs in between projects i am doing with the engine, i have limited time and working on multiple PRs that rely on each other is very time consuming. |
Another thing: package names use only lowercase letters and digits (no underscores). See the Google Java Style Guide section 5.2.1. |
Are you suggesting your PRs deserve special treatment because you work on other projects and have limited time? |
I would make an exception in this case to match their registered extension name in gltf (https://github.com/KhronosGroup/glTF/blob/main/extensions/README.md) but i don't have a strong opinion in this regard
I am suggesting that if you want the perfect PRs we can leave them open indefinitely until i have time to follow all the rules, or we can accept my bad PRs to get features and bug fixes merged quickly as long as the code works. I am always working on a fork, so i don't have any urge to get my code merged, and besides, last time i checked i had push rights to the repo. |
Regarding package names, even though I do like your approach but yeah that seems to be not a standard Java package naming(?). Also as most of those extensions turn out to be a single class file anyway, I would recommend having a Next, we can have a |
Regarding PR complexity, looks like |
* An extension for the GLTF loader that loads speaker nodes. | ||
* (This extension requires the jme-extras addon for blender) | ||
*/ | ||
public class SpeakerExtensionLoader implements ExtensionLoader { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am fine with SpeakerExtensionLoader
naming, however, I think something like AudioNodeExtensionLoader
or AudioExtensionLoader
would be nicer, as in JME, I believe we do not use the term "Speaker".
I think we can even omit Just my two cents! |
The goal is to do what's best for the project in the long term. Code added to the project requires maintenance, so we want PRs to be in as good shape as possible before they're integrated, while the burden of maintenance falls on the submittor, not the community. If this PR is urgent for some reason, please document that reason.
As do many other people. Why even bring that up? This is a discussion of proposed changes to the codebase, not a discussion of Riccardo. Let's keep the discussion as impersonal as possible. |
Does the size of the PR reflects on the quality of the code?
Pretend the PR wasn't submitted and consider the single commits as if they were pushed to the master, you will see that every change has its own commit and the fact they are grouped on a single PR by the github interface doesn't make it less true. |
No. |
This is the initial work to improve and extend the gltf support in jme.
This pr:
Currently testing: