Skip to content
Snippets Groups Projects
Commit ce93ac14 authored by BATON Theau's avatar BATON Theau
Browse files

Correct linear curve GPU sided

parent 902f8338
Branches
No related tags found
No related merge requests found
...@@ -10,21 +10,32 @@ namespace ct::gpu { ...@@ -10,21 +10,32 @@ namespace ct::gpu {
: StreamedGenerator() {} : StreamedGenerator() {}
__host__ Point LinearGenerator::generate(const thrust::universal_vector<Point> & ctrlPoint, const float t) const { __host__ Point LinearGenerator::generate(const thrust::universal_vector<Point> & ctrlPoint, const float t) const {
if(ctrlPoint.empty()) {
return Point(0.0);
}
size_t max_size = ctrlPoint.size(); size_t max_size = ctrlPoint.size();
if(max_size == 1) {
return Point(ctrlPoint[0].x, ctrlPoint[0].y, ctrlPoint[0].z);
}
float range = 1.f/static_cast<float>(max_size); float range = 1.f/static_cast<float>(max_size);
size_t current = 0; size_t current = 0;
for(float i = 0.f; i <= t; i += range) { for(float i = 0.f; i < t; i += range) {
++current; ++current;
} }
if(current == max_size) { if(current == 0) {
--current; ++current;
}
if(current >= max_size) {
current = max_size-1;
} }
Point p1 = ctrlPoint[current]; Point p1 = ctrlPoint[current-1];
Point p2 = ctrlPoint[current+1]; Point p2 = ctrlPoint[current];
Point r, * d_r; Point r, * d_r;
cudaMalloc(&d_r, sizeof(Point)); cudaMalloc(&d_r, sizeof(Point));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment