Skip to content

Commit

Permalink
Apply formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user authored and mgsx-dev committed Nov 15, 2022
1 parent b6d788b commit 433466a
Show file tree
Hide file tree
Showing 15 changed files with 93 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ public ShortBuffer getBuffer () {
return buffer;
}

@Override
public ShortBuffer getBuffer (boolean forWriting) {
isDirty |= forWriting;
return buffer;
}

@Override
public ShortBuffer getBuffer (boolean forWriting) {
isDirty |= forWriting;
return buffer;
}

/** Binds this IndexBufferObject for rendering with glDrawElements. */
public void bind () {
if (bufferHandle == 0) throw new GdxRuntimeException("No buffer allocated!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,20 @@ public int getNumMaxVertices () {
return buffer.capacity() / (attributes.vertexSize / 4);
}

/** @deprecated use {@link #getBuffer(boolean)} instead */
/** @deprecated use {@link #getBuffer(boolean)} instead */
@Override
@Deprecated
@Deprecated
public FloatBuffer getBuffer () {
isDirty = true;
return buffer;
}

@Override
public FloatBuffer getBuffer (boolean forWriting) {
isDirty |= forWriting;
return buffer;
}

@Override
public FloatBuffer getBuffer (boolean forWriting) {
isDirty |= forWriting;
return buffer;
}

private void bufferChanged () {
if (isBound) {
Gdx.gl20.glBufferData(GL20.GL_ARRAY_BUFFER, buffer.limit(), buffer, usage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ public void set (final Object tag, final Mesh mesh, int offset, int count) {

if (posAttr == null) throw new com.badlogic.gdx.utils.GdxRuntimeException("Mesh doesn't have a position attribute");

set(tag, mesh.getVerticesBuffer(false), mesh.getVertexSize(), mesh.getNumVertices(), posAttr.offset, mesh.getIndicesBuffer(false), offset, count);
set(tag, mesh.getVerticesBuffer(false), mesh.getVertexSize(), mesh.getNumVertices(), posAttr.offset,
mesh.getIndicesBuffer(false), offset, count);
}

/** Convenience method to set this btIndexedMesh to the specified vertex and index data. The specified data must be indexed and
Expand Down
42 changes: 21 additions & 21 deletions gdx/src/com/badlogic/gdx/graphics/Mesh.java
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ public void render (ShaderProgram shader, int primitiveType, int offset, int cou

if (isVertexArray) {
if (indices.getNumIndices() > 0) {
ShortBuffer buffer = indices.getBuffer(false);
ShortBuffer buffer = indices.getBuffer(false);
int oldPosition = buffer.position();
int oldLimit = buffer.limit();
((Buffer)buffer).position(offset);
Expand Down Expand Up @@ -681,15 +681,15 @@ public VertexAttributes getVertexAttributes () {
return vertices.getAttributes();
}

/** @return the backing FloatBuffer holding the vertices. Does not have to be a direct buffer on Android!
* @deprecated use {@link #getVerticesBuffer(boolean)} instead */
@Deprecated
/** @return the backing FloatBuffer holding the vertices. Does not have to be a direct buffer on Android!
* @deprecated use {@link #getVerticesBuffer(boolean)} instead */
@Deprecated
public FloatBuffer getVerticesBuffer () {
return vertices.getBuffer(true);
}

public FloatBuffer getVerticesBuffer (boolean forWriting) {
return vertices.getBuffer(forWriting);
return vertices.getBuffer(true);
}

public FloatBuffer getVerticesBuffer (boolean forWriting) {
return vertices.getBuffer(forWriting);
}

/** Calculates the {@link BoundingBox} of the vertices contained in this mesh. In case no vertices are defined yet a
Expand All @@ -710,7 +710,7 @@ public void calculateBoundingBox (BoundingBox bbox) {
final int numVertices = getNumVertices();
if (numVertices == 0) throw new GdxRuntimeException("No vertices defined");

final FloatBuffer verts = vertices.getBuffer(false);
final FloatBuffer verts = vertices.getBuffer(false);
bbox.inf();
final VertexAttribute posAttrib = getVertexAttribute(Usage.Position);
final int offset = posAttrib.offset / 4;
Expand Down Expand Up @@ -780,8 +780,8 @@ public BoundingBox extendBoundingBox (final BoundingBox out, int offset, int cou
if (offset < 0 || count < 1 || offset + count > max)
throw new GdxRuntimeException("Invalid part specified ( offset=" + offset + ", count=" + count + ", max=" + max + " )");

final FloatBuffer verts = vertices.getBuffer(false);
final ShortBuffer index = indices.getBuffer(false);
final FloatBuffer verts = vertices.getBuffer(false);
final ShortBuffer index = indices.getBuffer(false);
final VertexAttribute posAttrib = getVertexAttribute(Usage.Position);
final int posoff = posAttrib.offset / 4;
final int vertexSize = vertices.getAttributes().vertexSize / 4;
Expand Down Expand Up @@ -855,8 +855,8 @@ public float calculateRadiusSquared (final float centerX, final float centerY, f
int numIndices = getNumIndices();
if (offset < 0 || count < 1 || offset + count > numIndices) throw new GdxRuntimeException("Not enough indices");

final FloatBuffer verts = vertices.getBuffer(false);
final ShortBuffer index = indices.getBuffer(false);
final FloatBuffer verts = vertices.getBuffer(false);
final ShortBuffer index = indices.getBuffer(false);
final VertexAttribute posAttrib = getVertexAttribute(Usage.Position);
final int posoff = posAttrib.offset / 4;
final int vertexSize = vertices.getAttributes().vertexSize / 4;
Expand Down Expand Up @@ -953,14 +953,14 @@ public float calculateRadius (final Vector3 center) {
return calculateRadius(center.x, center.y, center.z, 0, getNumIndices(), null);
}

/** @return the backing shortbuffer holding the indices. Does not have to be a direct buffer on Android!
* @deprecated use {@link #getIndicesBuffer(boolean)} instead */
/** @return the backing shortbuffer holding the indices. Does not have to be a direct buffer on Android!
* @deprecated use {@link #getIndicesBuffer(boolean)} instead */
public ShortBuffer getIndicesBuffer () {
return indices.getBuffer(true);
}

public ShortBuffer getIndicesBuffer (boolean forWriting) {
return indices.getBuffer(forWriting);
return indices.getBuffer(true);
}

public ShortBuffer getIndicesBuffer (boolean forWriting) {
return indices.getBuffer(forWriting);
}

private static void addManagedMesh (Application app, Mesh mesh) {
Expand Down
16 changes: 8 additions & 8 deletions gdx/src/com/badlogic/gdx/graphics/g2d/SpriteCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,22 +183,22 @@ public void beginCache () {
public void beginCache (int cacheID) {
if (drawing) throw new IllegalStateException("end must be called before beginCache");
if (currentCache != null) throw new IllegalStateException("endCache must be called before begin.");
Buffer verticesBuffer = (Buffer)mesh.getVerticesBuffer(true);
Buffer verticesBuffer = (Buffer)mesh.getVerticesBuffer(true);
if (cacheID == caches.size - 1) {
Cache oldCache = caches.removeIndex(cacheID);
verticesBuffer.limit(oldCache.offset);
verticesBuffer.limit(oldCache.offset);
beginCache();
return;
}
currentCache = caches.get(cacheID);
verticesBuffer.position(currentCache.offset);
verticesBuffer.position(currentCache.offset);
}

/** Ends the definition of a cache, returning the cache ID to be used with {@link #draw(int)}. */
public int endCache () {
if (currentCache == null) throw new IllegalStateException("beginCache must be called before endCache.");
Cache cache = currentCache;
int cacheCount = mesh.getVerticesBuffer(false).position() - cache.offset;
int cacheCount = mesh.getVerticesBuffer(false).position() - cache.offset;
if (cache.textures == null) {
// New cache.
cache.maxCount = cacheCount;
Expand All @@ -208,7 +208,7 @@ public int endCache () {
for (int i = 0, n = counts.size; i < n; i++)
cache.counts[i] = counts.get(i);

((Buffer) mesh.getVerticesBuffer(true)).flip();
((Buffer)mesh.getVerticesBuffer(true)).flip();
} else {
// Redefine existing cache.
if (cacheCount > cache.maxCount) {
Expand All @@ -227,7 +227,7 @@ public int endCache () {
for (int i = 0, n = cache.textureCount; i < n; i++)
cache.counts[i] = counts.get(i);

FloatBuffer vertices = mesh.getVerticesBuffer(true);
FloatBuffer vertices = mesh.getVerticesBuffer(true);
((Buffer)vertices).position(0);
Cache lastCache = caches.get(caches.size - 1);
((Buffer)vertices).limit(lastCache.offset + lastCache.maxCount);
Expand All @@ -243,7 +243,7 @@ public int endCache () {
/** Invalidates all cache IDs and resets the SpriteCache so new caches can be added. */
public void clear () {
caches.clear();
((Buffer) mesh.getVerticesBuffer(true)).clear().flip();
((Buffer)mesh.getVerticesBuffer(true)).clear().flip();
}

/** Adds the specified vertices to the cache. Each vertex should have 5 elements, one for each of the attributes: x, y, color,
Expand All @@ -261,7 +261,7 @@ public void add (Texture texture, float[] vertices, int offset, int length) {
} else
counts.incr(lastIndex, count);

mesh.getVerticesBuffer(true).put(vertices, offset, length);
mesh.getVerticesBuffer(true).put(vertices, offset, length);
}

/** Adds the specified texture to the cache. */
Expand Down
8 changes: 4 additions & 4 deletions gdx/src/com/badlogic/gdx/graphics/g3d/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
import com.badlogic.gdx.utils.ObjectMap;

import java.nio.Buffer;
import java.nio.ShortBuffer;
import java.nio.ShortBuffer;

/** A model represents a 3D assets. It stores a hierarchy of nodes. A node has a transform and optionally a graphical part in form
* of a {@link MeshPart} and {@link Material}. Mesh parts reference subsets of vertices in one of the meshes of the model.
Expand Down Expand Up @@ -248,7 +248,7 @@ protected void convertMesh (ModelMesh modelMesh) {
meshes.add(mesh);
disposables.add(mesh);

BufferUtils.copy(modelMesh.vertices, mesh.getVerticesBuffer(true), modelMesh.vertices.length, 0);
BufferUtils.copy(modelMesh.vertices, mesh.getVerticesBuffer(true), modelMesh.vertices.length, 0);
int offset = 0;
ShortBuffer indicesBuffer = mesh.getIndicesBuffer(true);
((Buffer)indicesBuffer).clear();
Expand All @@ -260,12 +260,12 @@ protected void convertMesh (ModelMesh modelMesh) {
meshPart.size = hasIndices ? part.indices.length : numVertices;
meshPart.mesh = mesh;
if (hasIndices) {
indicesBuffer.put(part.indices);
indicesBuffer.put(part.indices);
}
offset += meshPart.size;
meshParts.add(meshPart);
}
((Buffer)indicesBuffer).position(0);
((Buffer)indicesBuffer).position(0);
for (MeshPart part : meshParts)
part.update();
}
Expand Down
10 changes: 5 additions & 5 deletions gdx/src/com/badlogic/gdx/graphics/glutils/IndexArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ public ShortBuffer getBuffer () {
return buffer;
}

@Override
public ShortBuffer getBuffer (boolean forWriting) {
return buffer;
}

@Override
public ShortBuffer getBuffer (boolean forWriting) {
return buffer;
}

/** Binds this IndexArray for rendering with glDrawElements. */
public void bind () {
}
Expand Down
12 changes: 6 additions & 6 deletions gdx/src/com/badlogic/gdx/graphics/glutils/IndexBufferObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ public ShortBuffer getBuffer () {
return buffer;
}

@Override
public ShortBuffer getBuffer (boolean forWriting) {
isDirty |= forWriting;
return buffer;
}

@Override
public ShortBuffer getBuffer (boolean forWriting) {
isDirty |= forWriting;
return buffer;
}

/** Binds this IndexBufferObject for rendering with glDrawElements. */
public void bind () {
if (bufferHandle == 0) throw new GdxRuntimeException("No buffer allocated!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ public ShortBuffer getBuffer () {
return buffer;
}

@Override
public ShortBuffer getBuffer (boolean forWriting) {
isDirty |= forWriting;
return buffer;
}

@Override
public ShortBuffer getBuffer (boolean forWriting) {
isDirty |= forWriting;
return buffer;
}

/** Binds this IndexBufferObject for rendering with glDrawElements. */
public void bind () {
if (bufferHandle == 0) throw new GdxRuntimeException("IndexBufferObject cannot be used after it has been disposed.");
Expand Down
4 changes: 2 additions & 2 deletions gdx/src/com/badlogic/gdx/graphics/glutils/IndexData.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public interface IndexData extends Disposable {

/**
* <p>
* Returns the underlying ShortBuffer. If you modify the buffer contents they will be uploaded on the next call to {@link #bind()}.
* If you need immediate uploading use {@link #setIndices(short[], int, int)}.
* Returns the underlying ShortBuffer. If you modify the buffer contents they will be uploaded on the next call to
* {@link #bind()}. If you need immediate uploading use {@link #setIndices(short[], int, int)}.
* </p>
*
* @return the underlying short buffer.
Expand Down
14 changes: 7 additions & 7 deletions gdx/src/com/badlogic/gdx/graphics/glutils/VertexArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,19 @@ public void dispose () {
BufferUtils.disposeUnsafeByteBuffer(byteBuffer);
}

/** @deprecated use {@link #getBuffer(boolean)} instead */
/** @deprecated use {@link #getBuffer(boolean)} instead */
@Override
@Deprecated
@Deprecated
public FloatBuffer getBuffer () {
return buffer;
}

@Override
public FloatBuffer getBuffer (boolean forWriting) {
return buffer;
}

@Override
public FloatBuffer getBuffer (boolean forWriting) {
return buffer;
}

@Override
public int getNumVertices () {
return buffer.limit() * 4 / attributes.vertexSize;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,20 @@ public int getNumMaxVertices () {
return byteBuffer.capacity() / attributes.vertexSize;
}

/** @deprecated use {@link #getBuffer(boolean)} instead */
/** @deprecated use {@link #getBuffer(boolean)} instead */
@Override
@Deprecated
@Deprecated
public FloatBuffer getBuffer () {
isDirty = true;
return buffer;
}

@Override
public FloatBuffer getBuffer (boolean forWriting) {
isDirty |= forWriting;
return buffer;
}

@Override
public FloatBuffer getBuffer (boolean forWriting) {
isDirty |= forWriting;
return buffer;
}

/** Low level method to reset the buffer and attributes to the specified values. Use with care!
* @param data
* @param ownsBuffer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,20 @@ public int getNumMaxVertices () {
return byteBuffer.capacity() / attributes.vertexSize;
}

/** @deprecated use {@link #getBuffer(boolean)} instead */
/** @deprecated use {@link #getBuffer(boolean)} instead */
@Override
@Deprecated
@Deprecated
public FloatBuffer getBuffer () {
isDirty = true;
return buffer;
}

@Override
public FloatBuffer getBuffer (boolean forWriting) {
isDirty |= forWriting;
return buffer;
}

@Override
public FloatBuffer getBuffer (boolean forWriting) {
isDirty |= forWriting;
return buffer;
}

private void bufferChanged () {
if (isBound) {
Gdx.gl20.glBufferSubData(GL20.GL_ARRAY_BUFFER, 0, byteBuffer.limit(), byteBuffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public FloatBuffer getBuffer () {
isDirty = true;
return buffer;
}

@Override
public FloatBuffer getBuffer (boolean forWriting) {
isDirty |= forWriting;
Expand Down
Loading

0 comments on commit 433466a

Please sign in to comment.