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

feat(joml): migrate various pieces (no module impact) #4473

Merged
merged 12 commits into from
Feb 7, 2021
Merged
Show file tree
Hide file tree
Changes from 10 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
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
/*
* Copyright 2016 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.logic.characters;

import org.joml.Math;
Expand All @@ -29,10 +16,7 @@
import org.terasology.logic.characters.events.SwimStrokeEvent;
import org.terasology.logic.characters.events.VerticalCollisionEvent;
import org.terasology.logic.location.LocationComponent;
import org.terasology.math.JomlUtil;
import org.terasology.math.TeraMath;
import org.terasology.math.geom.ImmutableVector3f;
import org.terasology.math.geom.Quat4f;
import org.terasology.physics.engine.CharacterCollider;
import org.terasology.physics.engine.PhysicsEngine;
import org.terasology.physics.engine.SweepCallback;
Expand Down
22 changes: 0 additions & 22 deletions engine/src/main/java/org/terasology/logic/players/LocalPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
import org.terasology.logic.characters.events.ActivationRequest;
import org.terasology.logic.location.LocationComponent;
import org.terasology.math.Direction;
import org.terasology.math.JomlUtil;
import org.terasology.math.geom.Quat4f;
import org.terasology.network.ClientComponent;
import org.terasology.physics.HitResult;
import org.terasology.physics.Physics;
Expand Down Expand Up @@ -107,16 +105,6 @@ public Vector3f getPosition(Vector3f dest) {
return dest;
}

/**
* @return
* @deprecated This is scheduled for removal in an upcoming version method will be replaced with JOML implementation
* {@link #getRotation(Quaternionf)}.
*/
@Deprecated
public Quat4f getRotation() {
return JomlUtil.from(getRotation(new Quaternionf()));
}

/**
* the rotation of the local player
*
Expand Down Expand Up @@ -156,16 +144,6 @@ public Vector3f getViewPosition(Vector3f dest) {
return getPosition(dest);
}

/**
* @return
* @deprecated This is scheduled for removal in an upcoming version method will be replaced with JOML implementation
* {@link #getViewRotation(Quaternionf)}.
*/
@Deprecated
public Quat4f getViewRotation() {
return JomlUtil.from(getViewRotation(new Quaternionf()));
}

/**
* orientation of camera if one is present else use {@link #getPosition(Vector3f)}
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
/*
* Copyright 2013 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.persistence;

import org.joml.Vector3ic;
import org.terasology.math.geom.Vector3i;
import org.terasology.network.Client;
import org.terasology.world.chunks.Chunk;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,27 @@
/*
* Copyright 2013 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.rendering.assets.texture;

import org.terasology.joml.geom.Rectanglef;
import org.terasology.joml.geom.Rectanglei;
import org.joml.RoundingMode;
import org.joml.Vector2fc;
import org.joml.Vector2i;
import org.terasology.math.JomlUtil;
import org.terasology.joml.geom.Rectanglef;
import org.terasology.joml.geom.Rectanglei;
import org.terasology.math.TeraMath;
import org.terasology.math.geom.Rect2f;

/**
*/
public class BasicTextureRegion implements TextureRegion {
private Texture texture;
private Rectanglef region;
private Rectanglef region = new Rectanglef();

public BasicTextureRegion(Texture texture, Rect2f region) {
public BasicTextureRegion(Texture texture, Rectanglef region) {
this.texture = texture;
this.region = JomlUtil.from(region);
this.region.set(region);
}

public BasicTextureRegion(Texture texture, Vector2fc offset, Vector2fc size) {
this(texture, Rect2f.createFromMinAndSize(JomlUtil.from(offset), JomlUtil.from(size)));
this(texture, new Rectanglef().setMin(offset).setSize(size));
}

@Override
Expand Down Expand Up @@ -65,8 +51,7 @@ public Vector2i size() {

@Override
public Rectanglei getPixelRegion() {
return JomlUtil.rectangleiFromMinAndSize(
TeraMath.floorToInt(region.minX * texture.getWidth()),
TeraMath.floorToInt(region.minY * texture.getHeight()), getWidth(), getHeight());
Vector2i min = new Vector2i(region.minX * texture.getWidth(), region.minY * texture.getHeight(), RoundingMode.FLOOR);
return new Rectanglei(min).setSize(getWidth(), getHeight());
}
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
/*
* Copyright 2013 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.rendering.assets.texture.subtexture;

import org.terasology.joml.geom.Rectanglef;
import org.terasology.joml.geom.Rectanglei;
import org.joml.Vector2i;
import org.terasology.assets.Asset;
import org.terasology.assets.AssetType;
import org.terasology.assets.ResourceUrn;
import org.terasology.joml.geom.Rectanglef;
import org.terasology.joml.geom.Rectanglei;
import org.terasology.math.JomlUtil;
import org.terasology.math.TeraMath;
import org.terasology.math.geom.Rect2f;
import org.terasology.rendering.assets.texture.Texture;
import org.terasology.rendering.assets.texture.TextureRegionAsset;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,18 @@
/*
* Copyright 2013 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.rendering.primitives;

import com.google.common.base.Stopwatch;
import gnu.trove.iterator.TIntIterator;
import gnu.trove.list.TFloatList;
import org.joml.Vector3f;
import org.lwjgl.BufferUtils;
import org.terasology.engine.subsystem.lwjgl.GLBufferPool;
import org.terasology.math.Direction;
import org.terasology.math.TeraMath;
import org.terasology.math.geom.Vector3f;
import org.terasology.monitoring.PerformanceMonitor;
import org.terasology.rendering.RenderMath;
import org.terasology.world.ChunkView;
import org.terasology.world.block.Block;
import org.terasology.world.chunks.ChunkConstants;
import org.terasology.world.chunks.Chunks;

import java.util.concurrent.TimeUnit;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
/*
* Copyright 2013 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.rendering.world.selection;

import org.joml.Vector2f;
import org.joml.Vector3ic;
import org.joml.Vector4f;
import org.lwjgl.opengl.GL11;
import org.terasology.joml.geom.Rectanglef;
import org.terasology.math.JomlUtil;
import org.terasology.math.geom.Rect2f;
import org.terasology.math.geom.Vector3f;
import org.terasology.module.sandbox.API;
import org.terasology.registry.CoreRegistry;
Expand Down Expand Up @@ -56,26 +45,31 @@ public class BlockSelectionRenderer {
private Mesh overlayMesh2;
private Texture effectsTexture;
private Material defaultTextured;
private Rect2f textureRegion = Rect2f.createFromMinAndSize(0f, 0f, 1f, 1f);
private Rectanglef textureRegion = new Rectanglef(0, 0, 1, 1);

public BlockSelectionRenderer(Texture effectsTexture) {
this.effectsTexture = effectsTexture;
initialize();
}

private void initialize() {
Vector2f min = new Vector2f(textureRegion.minX(), textureRegion.minY());
Tessellator tessellator = new Tessellator();
TessellatorHelper.addBlockMesh(tessellator, new org.joml.Vector4f(1, 1, 1, 1f), JomlUtil.from(textureRegion.min()), JomlUtil.from(textureRegion.size()), 1.001f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
TessellatorHelper.addBlockMesh(tessellator, new Vector4f(1, 1, 1, 1f),
min , textureRegion.getSize(new Vector2f()),
1.001f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
overlayMesh = tessellator.generateMesh();
tessellator = new Tessellator();
TessellatorHelper.addBlockMesh(tessellator, new org.joml.Vector4f(1, 1, 1, .2f), JomlUtil.from(textureRegion.min()), JomlUtil.from(textureRegion.size()), 1.001f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
TessellatorHelper.addBlockMesh(tessellator, new Vector4f(1, 1, 1, .2f),
min, textureRegion.getSize(new Vector2f()), 1.001f, 1.0f, 1.0f, 0.0f,
0.0f, 0.0f);
overlayMesh2 = tessellator.generateMesh();
defaultTextured = Assets.getMaterial("engine:prog.defaultTextured").get();
}

public void setEffectsTexture(TextureRegionAsset textureRegionAsset) {
setEffectsTexture(textureRegionAsset.getTexture());
textureRegion = JomlUtil.from(textureRegionAsset.getRegion());
textureRegion.set(textureRegionAsset.getRegion());
// reinitialize to recreate the mesh's UV coordinates for this textureRegion
initialize();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
/*
* Copyright 2014 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.utilities.procedural;

import com.google.common.math.IntMath;
Expand All @@ -21,13 +8,10 @@
import org.joml.Vector3f;
import org.joml.Vector3i;
import org.terasology.math.TeraMath;
import org.terasology.math.geom.Rect2i;
import org.terasology.world.block.BlockArea;
import org.terasology.world.block.BlockAreac;
import org.terasology.world.block.BlockRegion;

/**
*/
public class SubSampledNoise extends AbstractNoise {

private Noise source;
Expand Down Expand Up @@ -67,18 +51,6 @@ public float noise(float x, float y) {
return TeraMath.biLerp(q00, q10, q01, q11, xMod / sampleRate, yMod / sampleRate);
}

/**
*
* @param region
* @return
* @deprecated This is scheduled for removal in an upcoming version method will be replaced with JOML implementation
* {@link #noise(BlockAreac)}.
*/
@Deprecated
public float[] noise(Rect2i region) {
return noise(new BlockArea(region.minX(), region.minY(), region.maxX(), region.maxY()));
}

public float[] noise(BlockAreac area) {
return noise(area, 1);
}
Expand Down Expand Up @@ -198,7 +170,6 @@ private float[] getSubset(float[] fullData, BlockRegion fullRegion, BlockRegion
}
}


private float[] mapExpand(float[] keyData, BlockRegion fullRegion) {
float[] fullData = new float[fullRegion.volume()];
int samplesX = fullRegion.getSizeX() / sampleRate + 1;
Expand Down
Loading