mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-29 08:26:37 +01:00
Merge branch 'dev' into vanilla-opt
# Conflicts: # src/main/java/com/jozufozu/flywheel/backend/instancing/Instancer.java
This commit is contained in:
commit
a42073f59a
2 changed files with 20 additions and 9 deletions
|
@ -4,7 +4,7 @@ import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer;
|
||||||
|
|
||||||
public abstract class InstanceData {
|
public abstract class InstanceData {
|
||||||
|
|
||||||
protected final Instancer<?> owner;
|
Instancer<?> owner;
|
||||||
|
|
||||||
boolean dirty;
|
boolean dirty;
|
||||||
boolean removed;
|
boolean removed;
|
||||||
|
|
|
@ -60,15 +60,14 @@ public class Instancer<D extends InstanceData> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public D createInstance() {
|
public D createInstance() {
|
||||||
D instanceData = factory.create(this);
|
return _add(factory.create(this));
|
||||||
instanceData.dirty = true;
|
}
|
||||||
anyToUpdate = true;
|
|
||||||
|
|
||||||
synchronized (data) {
|
public void stealInstance(D inOther) {
|
||||||
data.add(instanceData);
|
if (inOther.owner == this) return;
|
||||||
}
|
|
||||||
|
|
||||||
return instanceData;
|
inOther.owner.anyToRemove = true;
|
||||||
|
_add(inOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
|
@ -125,6 +124,18 @@ public class Instancer<D extends InstanceData> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private D _add(D instanceData) {
|
||||||
|
instanceData.owner = this;
|
||||||
|
|
||||||
|
instanceData.dirty = true;
|
||||||
|
anyToUpdate = true;
|
||||||
|
synchronized (data) {
|
||||||
|
data.add(instanceData);
|
||||||
|
}
|
||||||
|
|
||||||
|
return instanceData;
|
||||||
|
}
|
||||||
|
|
||||||
protected void renderSetup() {
|
protected void renderSetup() {
|
||||||
if (anyToRemove) {
|
if (anyToRemove) {
|
||||||
removeDeletedInstances();
|
removeDeletedInstances();
|
||||||
|
@ -235,7 +246,7 @@ public class Instancer<D extends InstanceData> {
|
||||||
final BitSet removeSet = new BitSet(oldSize);
|
final BitSet removeSet = new BitSet(oldSize);
|
||||||
for (int i = 0; i < oldSize; i++) {
|
for (int i = 0; i < oldSize; i++) {
|
||||||
final D element = this.data.get(i);
|
final D element = this.data.get(i);
|
||||||
if (element.removed) {
|
if (element.removed || element.owner != this) {
|
||||||
removeSet.set(i);
|
removeSet.set(i);
|
||||||
removeCount++;
|
removeCount++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue