mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 02:40:05 +00:00 
			
		
		
		
	Refactoring map and ImGui functions from hover text
This commit is contained in:
		
							parent
							
								
									5bb5093579
								
							
						
					
					
						commit
						2c3de1a28f
					
				
					 7 changed files with 192 additions and 89 deletions
				
			
		|  | @ -43,6 +43,36 @@ glm::vec2 GetMapScale(const QMapLibreGL::CustomLayerRenderParameters& params) | |||
|    return glm::vec2 {xScale, yScale}; | ||||
| } | ||||
| 
 | ||||
| bool IsPointInPolygon(const std::vector<glm::vec2>& vertices, | ||||
|                       const glm::vec2&              point) | ||||
| { | ||||
|    bool inPolygon = true; | ||||
| 
 | ||||
|    // For each vertex, assume counterclockwise order
 | ||||
|    for (std::size_t i = 0; i < vertices.size(); ++i) | ||||
|    { | ||||
|       const auto& p1 = vertices[i]; | ||||
|       const auto& p2 = | ||||
|          (i == vertices.size() - 1) ? vertices[0] : vertices[i + 1]; | ||||
| 
 | ||||
|       // Test which side of edge point lies on
 | ||||
|       const float a = -(p2.y - p1.y); | ||||
|       const float b = p2.x - p1.x; | ||||
|       const float c = -(a * p1.x + b * p1.y); | ||||
|       const float d = a * point.x + b * point.y + c; | ||||
| 
 | ||||
|       // If d < 0, the point is on the right-hand side, and outside of the
 | ||||
|       // polygon
 | ||||
|       if (d < 0) | ||||
|       { | ||||
|          inPolygon = false; | ||||
|          break; | ||||
|       } | ||||
|    } | ||||
| 
 | ||||
|    return inPolygon; | ||||
| } | ||||
| 
 | ||||
| glm::vec2 LatLongToScreenCoordinate(const QMapLibreGL::Coordinate& coordinate) | ||||
| { | ||||
|    static constexpr double RAD2DEG_D = 180.0 / M_PI; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat