cadop / dhart

A library for Navigation Graphs, Visibility, Raycasting and other features for Design Humans Analysis RoboTics (DHART).

Home Page:https://cadop.github.io/dhart/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

consider changing C_Interface to use floats

cadop opened this issue · comments

commented

Another idea I had was to simplify another data conversion on the c++ side. What is the rationale behind the conversions in lines 273 & 274?

C_INTERFACE CastOcclusionRays(EmbreeRayTracer* ert, const float* origins, const float* directions, int origin_size, int direction_size, float max_distance, bool* result_array)
{
auto origin_array = ConvertRawFloatArrayToPoints(origins, origin_size);
auto direction_array = ConvertRawFloatArrayToPoints(directions, direction_size);
const auto results = ert->Occlusions(origin_array, direction_array, max_distance, true);
std::copy(results.begin(), results.end(), result_array);
return OK;
}

In the end, we need float values anyway:

bool EmbreeRayTracer::Occluded_IMPL(float x, float y, float z, float dx, float dy, float dz, float distance, int mesh_id)
{
auto ray = ConstructRay(x, y, z, dx, dy, dz, distance);
rtcOccluded1(scene, &context, &ray);
return ray.tfar == -INFINITY;
}

If it's only to make looping over data more convenient, then it could be restructured to operating directly on a pointer to the float array we pass from c#. This could shave off another few ms per call.

Originally posted by @mariuszhermansdorfer in #33 (reply in thread)

commented

The steps in between these two functions seems to be the main motivation and reason to have this structure. Its not just about looping over points, but also checking the sizes of the sets to determine which method to use, and how to parallelize it using omp parallel.