16 lines
		
	
	
		
			317 B
		
	
	
	
		
			Go
		
	
	
	
	
	
		
		
			
		
	
	
			16 lines
		
	
	
		
			317 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| 
								 | 
							
								package shape
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import "zworld/plugins/math/vec3"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								type Sphere struct {
							 | 
						||
| 
								 | 
							
									Center vec3.T
							 | 
						||
| 
								 | 
							
									Radius float32
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								func (s *Sphere) IntersectsSphere(other *Sphere) bool {
							 | 
						||
| 
								 | 
							
									sepAxis := s.Center.Sub(other.Center)
							 | 
						||
| 
								 | 
							
									radiiSum := s.Radius + other.Radius
							 | 
						||
| 
								 | 
							
									intersects := sepAxis.LengthSqr() < (radiiSum * radiiSum)
							 | 
						||
| 
								 | 
							
									return intersects
							 | 
						||
| 
								 | 
							
								}
							 |