-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVertexPool.java
More file actions
36 lines (33 loc) · 1.16 KB
/
VertexPool.java
File metadata and controls
36 lines (33 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.util.ArrayList;
//the whole point of this class is to store vertices so
//they can be shared within continous masses, saving memory
public class VertexPool {
//THIS DOES NOT WORK FOR VERTICES THAT MOVE IN WORLD SPACE I THINK
//NEED TO FIND WORKAROUND LATER
public ArrayList<Vector3> sharedVertices = new ArrayList<>();
public VertexPool(){
}
public VertexPool(ArrayList<Vector3> t){
for (Vector3 v: t){
sharedVertices.add(v.clone());
}
}
// Retrieve or create a shared vertex
public Vector3 getSharedVertex(Vector3 Location) {
// If the vertex exists, return it
//i REALLY hope this works because otherwise this whole project is cooked freaky style :(
if (sharedVertices.contains(Location)) {
int index = sharedVertices.indexOf(Location);
return sharedVertices.get(index);
}
sharedVertices.add(Location);
return Location;
}
//delete function
public void clear() {
sharedVertices.clear();
}
public VertexPool clone(){
return new VertexPool(sharedVertices);
}
}