Fixed the overlapping triangle but not detected
This commit is contained in:
		
							parent
							
								
									77c3d36134
								
							
						
					
					
						commit
						86b3b1733b
					
				@ -370,12 +370,15 @@ geo.MeshStreamer.prototype.nextElements = function(_camera, force) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            if (!force) {
 | 
					            if (!force) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                var display = false;
 | 
				
			||||||
 | 
					                var outcodes = [];
 | 
				
			||||||
                var exitToContinue = false;
 | 
					                var exitToContinue = false;
 | 
				
			||||||
                threeVertices = [vertex1, vertex2, vertex3];
 | 
					                threeVertices = [vertex1, vertex2, vertex3];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                for (i = 0; i < threeVertices.length; i++) {
 | 
					                for (i = 0; i < threeVertices.length; i++) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    var vertex = threeVertices[i];
 | 
					                    var vertex = threeVertices[i];
 | 
				
			||||||
 | 
					                    var currentOutcode = "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    for (var j = 0; j < planes.length;  j++) {
 | 
					                    for (var j = 0; j < planes.length;  j++) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -387,22 +390,32 @@ geo.MeshStreamer.prototype.nextElements = function(_camera, force) {
 | 
				
			|||||||
                            plane.normal.z * vertex.z +
 | 
					                            plane.normal.z * vertex.z +
 | 
				
			||||||
                            plane.constant;
 | 
					                            plane.constant;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        if (distance < 0)
 | 
					                        // if (distance < 0) {
 | 
				
			||||||
                        {
 | 
					                        //     exitToContinue = true;
 | 
				
			||||||
                            exitToContinue = true;
 | 
					                        //     break;
 | 
				
			||||||
                            break;
 | 
					                        // }
 | 
				
			||||||
                        }
 | 
					
 | 
				
			||||||
 | 
					                        currentOutcode += distance > 0 ? '0' : '1';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (exitToContinue)
 | 
					                    outcodes.push(parseInt(currentOutcode,2));
 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (exitToContinue)
 | 
					                // http://vterrain.org/LOD/culling.html
 | 
				
			||||||
 | 
					                // I have no idea what i'm doing
 | 
				
			||||||
 | 
					                // http://i.kinja-img.com/gawker-media/image/upload/japbcvpavbzau9dbuaxf.jpg
 | 
				
			||||||
 | 
					                // But it seems to work
 | 
				
			||||||
 | 
					                if ( (outcodes[0] | outcodes[1]) === 0 && (outcodes[1] | outcodes[2]) === 0 ) {
 | 
				
			||||||
 | 
					                    // all points in
 | 
				
			||||||
 | 
					                } else if ( (outcodes[0] === outcodes[1]) && (outcodes[0] === outcodes[2]) ) {
 | 
				
			||||||
 | 
					                    // all points out
 | 
				
			||||||
                    continue;
 | 
					                    continue;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else {
 | 
				
			||||||
 | 
					                    // part of the triangle is inside the viewing volume
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (!this.vertices[currentFace.a]) {
 | 
					            if (!this.vertices[currentFace.a]) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user