| 2288 | } |
| 2289 | |
| 2290 | ImPlot3DRay NDCRayToPlotRay(const ImPlot3DRay& ray) { |
| 2291 | ImPlot3DContext& gp = *GImPlot3D; |
| 2292 | IM_ASSERT_USER_ERROR(gp.CurrentPlot != nullptr, "NDCRayToPlotRay() needs to be called between BeginPlot() and EndPlot()!"); |
| 2293 | SetupLock(); |
| 2294 | |
| 2295 | // Convert NDC origin and a point along the ray to plot coordinates |
| 2296 | ImPlot3DPoint plot_origin = NDCToPlot(ray.Origin); |
| 2297 | ImPlot3DPoint ndc_point_along_ray = ray.Origin + ray.Direction; |
| 2298 | ImPlot3DPoint plot_point_along_ray = NDCToPlot(ndc_point_along_ray); |
| 2299 | |
| 2300 | // Compute the direction in plot coordinates |
| 2301 | ImPlot3DPoint plot_direction = (plot_point_along_ray - plot_origin).Normalized(); |
| 2302 | |
| 2303 | // Create the ray in plot coordinates |
| 2304 | ImPlot3DRay plot_ray; |
| 2305 | plot_ray.Origin = plot_origin; |
| 2306 | plot_ray.Direction = plot_direction; |
| 2307 | |
| 2308 | return plot_ray; |
| 2309 | } |
| 2310 | |
| 2311 | //----------------------------------------------------------------------------- |
| 2312 | // [SECTION] Setup Utils |
no test coverage detected