MCPcopy Create free account
hub / github.com/brenocq/implot3d / NDCRayToPlotRay

Function NDCRayToPlotRay

implot3d.cpp:2290–2309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2288}
2289
2290ImPlot3DRay 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

Callers 1

PixelsToPlotRayFunction · 0.85

Calls 3

SetupLockFunction · 0.85
NDCToPlotFunction · 0.85
NormalizedMethod · 0.80

Tested by

no test coverage detected