Skip to content

Commit e105554

Browse files
committed
improved scene rendering; improved vulkan tooling; switched vulkan buffers from eager to lazy initialization
1 parent d4cf1bb commit e105554

139 files changed

Lines changed: 2790 additions & 3876 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

jme3-core/src/main/java/com/jme3/app/BasicProfilerState.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ protected void refreshBackground() {
166166
0, 0, 0, 0.5f,
167167
0, 0, 0, 0.5f
168168
});
169-
pos.unmap();
170-
color.unmap();
169+
pos.close();
170+
color.close();
171171

172172
MappableBuffer indices = mesh.setIndexBufferIfAbsent(() -> getEngine().createBuffer(
173173
MemorySize.shorts(6 * 3), BufferUsage.Index, GlVertexBuffer.Usage.Static));
@@ -180,7 +180,7 @@ protected void refreshBackground() {
180180
8, 10, 11
181181
});
182182
indices.unmap();
183-
indices.push();
183+
indices.stage();
184184

185185
}
186186

jme3-core/src/main/java/com/jme3/backend/Engine.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
12
package com.jme3.backend;
23

34
import com.jme3.material.Material;
45
import com.jme3.math.Vector2f;
56
import com.jme3.math.Vector3f;
7+
import com.jme3.renderer.ViewPortArea;
68
import com.jme3.scene.GlVertexBuffer;
79
import com.jme3.scene.Mesh;
810
import com.jme3.texture.Texture;
@@ -11,6 +13,7 @@
1113
import com.jme3.vulkan.buffers.BufferGenerator;
1214
import com.jme3.vulkan.buffers.BufferUsage;
1315
import com.jme3.vulkan.buffers.MappableBuffer;
16+
import com.jme3.vulkan.commands.RenderSetting;
1417
import com.jme3.vulkan.material.uniforms.Uniform;
1518
import com.jme3.vulkan.mesh.InputRate;
1619
import com.jme3.vulkan.mesh.attribute.Attribute;

jme3-core/src/main/java/com/jme3/backend/OpenGLEngine.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@
1414
import com.jme3.vulkan.buffers.GlNativeBuffer;
1515
import com.jme3.vulkan.buffers.MappableBuffer;
1616
import com.jme3.vulkan.memory.MemorySize;
17-
import com.jme3.vulkan.render.GeometryBatch;
18-
import com.jme3.vulkan.render.GlGeometryBatch;
17+
import com.jme3.vulkan.render.batching.GeometryBatch;
18+
import com.jme3.vulkan.render.batching.GlGeometryBatch;
1919
import com.jme3.vulkan.render.RenderEngine;
2020
import com.jme3.vulkan.util.Flag;
2121
import com.jme3.vulkan.util.ScenePropertyStack;
22-
import com.jme3.vulkan.util.SceneStack;
22+
import com.jme3.vulkan.util.SceneIterationListener;
2323

2424
public class OpenGLEngine implements RenderEngine {
2525

2626
private final GLRenderer renderer = new GLRenderer();
2727
private GlGeometryBatch opaque, sky, transparent, gui, translucent;
28-
private final SceneStack<RenderQueue.Bucket> bucket = new ScenePropertyStack<>(
28+
private final SceneIterationListener<RenderQueue.Bucket> bucket = new ScenePropertyStack<>(
2929
RenderQueue.Bucket.Opaque, RenderQueue.Bucket.Inherit,
3030
s -> RenderQueue.Bucket.valueOf(s.getLocalQueueBucket()));
3131

@@ -36,7 +36,7 @@ public void render(ViewPort vp) {
3636
transparent.setCamera(vp.getCamera());
3737
gui.setCamera(new GuiCamera(vp.getCamera(), vp.getViewWidth(), vp.getViewHeight()));
3838
translucent.setCamera(vp.getCamera());
39-
SceneStack<Camera.FrustumIntersect> cull = vp.getCamera().createCullStack();
39+
SceneIterationListener<Camera.FrustumIntersect> cull = vp.getCamera().createCullStack();
4040
for (Spatial scene : vp.getScenes()) for (Spatial.GraphIterator it = scene.iterator(cull, bucket); it.hasNext();) {
4141
Spatial child = it.next();
4242
child.runControlRender(this, vp);

jme3-core/src/main/java/com/jme3/backend/SimpleVulkanEngine.java

Lines changed: 91 additions & 214 deletions
Large diffs are not rendered by default.

jme3-core/src/main/java/com/jme3/bounding/BoundingBox.java

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
import com.jme3.scene.Mesh;
4444
import com.jme3.scene.Spatial;
4545
import com.jme3.util.TempVars;
46+
import com.jme3.vulkan.mesh.attribute.Attribute;
4647
import com.jme3.vulkan.mesh.attribute.Position;
47-
import com.jme3.vulkan.util.FloatBufferModifier;
4848

4949
import java.io.IOException;
5050
import java.nio.FloatBuffer;
@@ -132,11 +132,34 @@ public Type getType() {
132132
*/
133133
@Override
134134
public void computeFromPoints(FloatBuffer points) {
135-
containAABB(new FloatBufferModifier(points, 3));
135+
if (points.remaining() < 3) {
136+
return;
137+
}
138+
float minX = Float.POSITIVE_INFINITY,
139+
minY = Float.POSITIVE_INFINITY,
140+
minZ = Float.POSITIVE_INFINITY;
141+
float maxX = Float.NEGATIVE_INFINITY,
142+
maxY = Float.NEGATIVE_INFINITY,
143+
maxZ = Float.NEGATIVE_INFINITY;
144+
for (int i = points.position(); i < points.limit(); i += 3) {
145+
float x = points.get(i);
146+
float y = points.get(i + 1);
147+
float z = points.get(i + 2);
148+
minX = Math.min(minX, x);
149+
minY = Math.min(minY, y);
150+
minZ = Math.min(minZ, z);
151+
maxX = Math.max(maxX, x);
152+
maxY = Math.max(maxY, y);
153+
maxZ = Math.max(maxZ, z);
154+
}
155+
center.set(minX + maxX, minY + maxY, minZ + maxZ).multLocal(0.5f);
156+
xExtent = maxX - center.x;
157+
yExtent = maxY - center.y;
158+
zExtent = maxZ - center.z;
136159
}
137160

138161
@Override
139-
public void computeFromPoints(VertexReader points) {
162+
public void computeFromPoints(Attribute<Vector3f> points) {
140163
containAABB(points);
141164
}
142165

@@ -203,6 +226,7 @@ public void computeFromTris(Triangle[] tris, int start, int end) {
203226
vars.release();
204227
}
205228

229+
@Deprecated
206230
public void computeFromTris(int[] indices, Mesh mesh, int start, int end) {
207231
if (end - start <= 0) {
208232
return;
@@ -219,7 +243,8 @@ public void computeFromTris(int[] indices, Mesh mesh, int start, int end) {
219243
Vector3f point;
220244

221245
for (int i = start; i < end; i++) {
222-
mesh.getTriangle(indices[i], triangle);
246+
// build error here
247+
//mesh.getTriangle(indices[i], triangle);
223248
point = triangle.get(0);
224249
checkMinMax(min, max, point);
225250
point = triangle.get(1);
@@ -267,17 +292,11 @@ public static void checkMinMax(Vector3f min, Vector3f max, Vector3f point) {
267292
* @param points
268293
* the list of points.
269294
*/
270-
public void containAABB(VertexReader points) {
295+
public void containAABB(Attribute<Vector3f> points) {
271296
if (points == null) {
272297
return;
273298
}
274299

275-
//points.rewind();
276-
if (points.limit() == 0) // we need at least a 3 float vector
277-
{
278-
return;
279-
}
280-
281300
TempVars vars = TempVars.get();
282301

283302
float minX = Float.POSITIVE_INFINITY,
@@ -287,17 +306,13 @@ public void containAABB(VertexReader points) {
287306
maxY = Float.NEGATIVE_INFINITY,
288307
maxZ = Float.NEGATIVE_INFINITY;
289308

290-
for (int i = 0, l = points.limit(); i < l; i++) {
291-
// vars.vect1.x = tmpArray[j];
292-
// vars.vect1.y = tmpArray[j + 1];
293-
// vars.vect1.z = tmpArray[j + 2];
294-
points.getVector3(i, 0, vars.vect1);
295-
minX = Math.min(minX, vars.vect1.x);
296-
minY = Math.min(minY, vars.vect1.y);
297-
minZ = Math.min(minZ, vars.vect1.z);
298-
maxX = Math.max(maxX, vars.vect1.x);
299-
maxY = Math.max(maxY, vars.vect1.y);
300-
maxZ = Math.max(maxZ, vars.vect1.z);
309+
for (Vector3f p : points.read(vars.vect1)) {
310+
minX = Math.min(minX, p.x);
311+
minY = Math.min(minY, p.y);
312+
minZ = Math.min(minZ, p.z);
313+
maxX = Math.max(maxX, p.x);
314+
maxY = Math.max(maxY, p.y);
315+
maxZ = Math.max(maxZ, p.z);
301316
}
302317

303318
vars.release();

0 commit comments

Comments
 (0)