@@ -34,26 +34,27 @@ public void updateFrustum(Matrix4f projMatrix, Matrix4f viewMatrix) {
3434 }
3535
3636 public void filter (Map <? extends Mesh , List <GameItem >> mapMesh ) {
37- for (Map .Entry <? extends Mesh , List <GameItem >> entry : mapMesh .entrySet ()) {
38- List <GameItem > gameItems = entry .getValue ();
37+ for (Map .Entry <? extends Mesh , List <GameItem >> entry : mapMesh .entrySet ()) {
38+ List <GameItem > gameItems = entry .getValue ();
3939 filter (gameItems , entry .getKey ().getBoundingRadius ());
4040 }
4141 }
42-
43- public void filter (List <GameItem > gameItems , float meshBoundingRadious ) {
44- float boundingRadious ;
45- for (GameItem gameItem : gameItems ) {
46- boundingRadious = gameItem .getScale () * meshBoundingRadious ;
47- gameItem .setInsideFrustum (insideFrustum (gameItem , boundingRadious ));
42+
43+ public void filter (List <GameItem > gameItems , float meshBoundingRadius ) {
44+ float boundingRadius ;
45+ Vector3f pos ;
46+ for (GameItem gameItem : gameItems ) {
47+ boundingRadius = gameItem .getScale () * meshBoundingRadius ;
48+ pos = gameItem .getPosition ();
49+ gameItem .setInsideFrustum (insideFrustum (pos .x , pos .y , pos .z , boundingRadius ));
4850 }
4951 }
50-
51- public boolean insideFrustum (GameItem gameItem , float boundingRadious ) {
52+
53+ public boolean insideFrustum (float x0 , float y0 , float z0 , float boundingRadius ) {
5254 boolean result = true ;
53- for (int i =0 ; i <NUM_PLANES ; i ++) {
54- Vector3f pos = gameItem .getPosition ();
55+ for (int i = 0 ; i < NUM_PLANES ; i ++) {
5556 Vector4f plane = frustumPlanes [i ];
56- if ( plane .x * pos . x + plane .y * pos . y + plane .z * pos . z + plane .w <= -boundingRadious ) {
57+ if ( plane .x * x0 + plane .y * y0 + plane .z * x0 + plane .w <= -boundingRadius ) {
5758 result = false ;
5859 return result ;
5960 }
0 commit comments