mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	Performance improvements in raycaster
This commit is contained in:
		
							parent
							
								
									bb62f36df3
								
							
						
					
					
						commit
						578fcbc37c
					
				
					 2 changed files with 12 additions and 9 deletions
				
			
		|  | @ -333,20 +333,23 @@ EigenMesh3D::hit_result EigenMesh3D::filter_hits( | |||
|         bool entry; | ||||
|     }; | ||||
|     std::vector<HoleHit> hole_isects; | ||||
|     hole_isects.reserve(m_holes.size()); | ||||
|      | ||||
|     auto sf = s.cast<float>(); | ||||
|     auto dirf = dir.cast<float>(); | ||||
| 
 | ||||
|     // Collect hits on all holes, preserve information about entry/exit
 | ||||
|     for (const sla::DrainHole& hole : m_holes) { | ||||
|         std::array<std::pair<float, Vec3d>, 2> isects; | ||||
|         if (hole.get_intersections(s.cast<float>(), | ||||
|                                    dir.cast<float>(), isects)) { | ||||
|             hole_isects.emplace_back(isects[0].first, isects[0].second, true); | ||||
|             hole_isects.emplace_back(isects[1].first, isects[1].second, false); | ||||
|         if (hole.get_intersections(sf, dirf, isects)) { | ||||
|             if (isects[0].first > 0.f) hole_isects.emplace_back(isects[0].first, isects[0].second, true); | ||||
|             if (isects[1].first > 0.f) hole_isects.emplace_back(isects[1].first, isects[1].second, false); | ||||
|         } | ||||
|     } | ||||
|     // Remove hole hits behind the source
 | ||||
|     for (int i=0; i<int(hole_isects.size()); ++i) | ||||
|         if (hole_isects[i].t < 0.f) | ||||
|             hole_isects.erase(hole_isects.begin() + (i--)); | ||||
| //    // Remove hole hits behind the source
 | ||||
| //    for (int i=0; i<int(hole_isects.size()); ++i)
 | ||||
| //        if (hole_isects[i].t < 0.f)
 | ||||
| //            hole_isects.erase(hole_isects.begin() + (i--));
 | ||||
| 
 | ||||
|     // Holes can intersect each other, sort the hits by t
 | ||||
|     std::sort(hole_isects.begin(), hole_isects.end(), | ||||
|  |  | |||
|  | @ -68,7 +68,7 @@ public: | |||
|         inline const Vec3d& source() const { return m_source; } | ||||
|         inline Vec3d position() const { return m_source + m_dir * m_t; } | ||||
|         inline bool is_valid() const { return m_mesh != nullptr; } | ||||
|         inline bool is_hit() const { return m_t != infty(); } | ||||
|         inline bool is_hit() const { return !std::isinf(m_t); } | ||||
| 
 | ||||
|         // Hit_result can decay into a double as the hit distance.
 | ||||
|         inline operator double() const { return distance(); } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 tamasmeszaros
						tamasmeszaros