Skip to content
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

Cleanup strange code #2241

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jme3-core/src/main/java/com/jme3/input/FlyByCamera.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public float getZoomSpeed() {
*/
public void setEnabled(boolean enable){
if (enabled && !enable){
if (inputManager!= null && (!dragToRotate || (dragToRotate && canRotate))){
if (inputManager != null && (!dragToRotate || canRotate)){
inputManager.setCursorVisible(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1309,8 +1309,6 @@ private boolean isValidNumber(Vector4f c) {
}

protected void updateUniform(Shader shader, Uniform uniform) {
int shaderId = shader.getId();

assert uniform.getName() != null;
assert shader.getId() > 0;

Expand Down
3 changes: 0 additions & 3 deletions jme3-core/src/main/java/com/jme3/util/ListSort.java
Original file line number Diff line number Diff line change
Expand Up @@ -874,9 +874,6 @@ public void innerMergeHigh(Comparator<T> comp, T[] tempArray, T[] arr, int idxA)
if (lengthA == 0 || lengthB == 1) {
return;
}
if (lengthB == 1) {
return;
}
while (true) {
// Number of wins by run A
int aWins = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,10 @@ public int processBinarySavable(Savable object) throws IOException {
return -1;
}
Class<? extends Savable> clazz = object.getClass();
BinaryClassObject bco = classes.get(object.getClass().getName());
BinaryClassObject bco = classes.get(clazz.getName());
// is this class been looked at before? in tagTable?
if (bco == null) {
bco = createClassObject(object.getClass());
bco = createClassObject(clazz);
}

// is object in contentTable?
Expand Down
12 changes: 0 additions & 12 deletions jme3-core/src/plugins/java/com/jme3/texture/plugins/HDRLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,6 @@ public static void convertRGBEtoFloat2(byte[] rgbe, float[] rgbf){
rgbf[2] = (B / 256.0f) * e;
}

public static void convertRGBEtoFloat3(byte[] rgbe, float[] rgbf){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method cannot be deleted, in order to maintain backwards compatibility.

int R = rgbe[0] & 0xFF,
G = rgbe[1] & 0xFF,
B = rgbe[2] & 0xFF,
E = rgbe[3] & 0xFF;

float e = (float) Math.pow(2f, E - (128 + 8) );
rgbf[0] = R * e;
rgbf[1] = G * e;
rgbf[2] = B * e;
}

private void writeRGBE(byte[] rgbe){
if (writeRGBE){
dataStore.put(rgbe);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ protected void createShape() {
bulletMesh.numTriangles = numTriangles;
bulletMesh.vertexStride = vertexStride;
bulletMesh.triangleIndexStride = triangleIndexStride;
bulletMesh.triangleIndexBase = triangleIndexBase;
bulletMesh.vertexBase = vertexBase;
bulletMesh.triangleIndexBase = triangleIndexBase;
TriangleIndexVertexArray tiv = new TriangleIndexVertexArray(numTriangles, triangleIndexBase, triangleIndexStride, numVertices, vertexBase, vertexStride);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ protected void createShape() {
bulletMesh.numTriangles = numTriangles;
bulletMesh.vertexStride = vertexStride;
bulletMesh.triangleIndexStride = triangleIndexStride;
bulletMesh.triangleIndexBase = triangleIndexBase;
bulletMesh.vertexBase = vertexBase;
bulletMesh.triangleIndexBase = triangleIndexBase;
TriangleIndexVertexArray tiv = new TriangleIndexVertexArray(numTriangles, triangleIndexBase, triangleIndexStride, numVertices, vertexBase, vertexStride);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,7 @@ protected void removeConnecting( Endpoint p )

protected void connectionClosed( Endpoint p )
{
if( p.isConnected() ) {
log.log( Level.FINE, "Connection closed:{0}.", p );
} else {
log.log( Level.FINE, "Connection closed:{0}.", p );
}
log.log( Level.FINE, "Connection closed:{0}.", p );

// Try to find the endpoint in all ways that it might
// exist. Note: by this point the raw network channel is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,11 @@ public class SerializerRegistrationsMessage extends AbstractMessage {
// their JME versions are out of date.
ignore.add(Boolean.class);
ignore.add(Float.class);
ignore.add(Boolean.class);
ignore.add(Byte.class);
ignore.add(Character.class);
ignore.add(Short.class);
ignore.add(Integer.class);
ignore.add(Long.class);
ignore.add(Float.class);
ignore.add(Double.class);
ignore.add(String.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,6 @@ protected Texture toJmeObject() {
public void fromElement(FbxElement element) {
super.fromElement(element);
if (getSubclassName().equals("")) {
for (FbxElement e : element.children) {
if (e.id.equals("Type")) {
e.properties.get(0);
}
/*else if (e.id.equals("FileName")) {
filename = (String) e.properties.get(0);
}*/
}

for (FbxElement prop : element.getFbxProperties()) {
String propName = (String) prop.properties.get(0);
if (propName.equals("AlphaSource")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ private List<Geometry> createGeometries() throws IOException {
indexMap = new ArrayList<>(vCount);
reverseVertexMap = new ArrayList<>(vCount);
for(int i = 0; i < vCount; ++i) {
vertexMap.set(i, i);
indexMap.set(i, i);
vertexMap.add(i, i);
indexMap.add(i, i);
Copy link
Contributor

@codex128 codex128 Apr 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be reverted back to set. add inserts elements, which I don't think is correct here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The set method does replace one element of the collection with another. However, if an element with the given index does not exist, the method will generate an IndexOutOfBoundExeption error. In the above code, the collection is created before the loop, so it will always be empty.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically add(index,v) is still wrong, the only reason it works is that it is executed in sequence from 0 to n, so i suggest to change it to

vertexMap.add(i);
indexMap.add(i);

without the index

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the vCount initializes the capacity, that is indeed the initial size of the internal array, however set will still fail because size() is not == capacity in arraylist . Kinda weird, but that's how it is, it would need a for(0..capacity) vertexMap.add(null) for set to work as expected

List<Integer> l = new ArrayList<>(1);
l.add(i);
reverseVertexMap.add(l);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,10 @@ public void render() {
dev.updatePose();
dev.getPositionAndOrientation(hmdPos, hmdRot);

if (obs != null) {
// update hmdPos based on obs rotation
finalRotation.set(objRot);
finalRotation.mult(hmdPos, hmdPos);
finalRotation.multLocal(hmdRot);
}
// update hmdPos based on obs rotation
finalRotation.set(objRot);
finalRotation.mult(hmdPos, hmdPos);
finalRotation.multLocal(hmdRot);

finalizeCamera(dev.getHMDVectorPoseLeftEye(), objPos, getLeftCamera());
finalizeCamera(dev.getHMDVectorPoseRightEye(), objPos, getRightCamera());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,10 @@ public void update(float tpf) {

// update the HMD's position & orientation
hardware.getPositionAndOrientation(hmdPos, hmdRot);
if (obs != null) {
// update hmdPos based on obs rotation
finalRotation.set(objRot);
finalRotation.mult(hmdPos, hmdPos);
finalRotation.multLocal(hmdRot);
}
// update hmdPos based on obs rotation
finalRotation.set(objRot);
finalRotation.mult(hmdPos, hmdPos);
finalRotation.multLocal(hmdRot);

// Update both eye cameras
finalizeCamera(hardware.getHMDVectorPoseLeftEye(), objPos, leftCamera);
Expand Down
Loading