yuandong513
commited on
Commit
•
c3f86e3
1
Parent(s):
d5bdc55
Upload zbuff.cpp
Browse files- lib/zbuff.cpp +28 -0
lib/zbuff.cpp
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#include <iostream>
|
2 |
+
#include <cstdint>
|
3 |
+
|
4 |
+
extern "C" {
|
5 |
+
void zbuff_check(int32_t * src_x, int32_t * src_y, float* depth, int data_size, bool* valid_mask, float * buffs, float * zbuffs, int height, int width) {
|
6 |
+
|
7 |
+
// std::cout<<width<<std::endl;
|
8 |
+
for (int i = 0; i < data_size; i++) {
|
9 |
+
if (0 == valid_mask[i] ) {
|
10 |
+
continue;
|
11 |
+
}
|
12 |
+
int x = src_x[i];
|
13 |
+
int y = src_y[i];
|
14 |
+
float z = depth[i];
|
15 |
+
if (-1 == buffs[y*width+x] ) {
|
16 |
+
buffs[y*width+x] = i;
|
17 |
+
zbuffs[y*width+x] = z;
|
18 |
+
}
|
19 |
+
else{
|
20 |
+
|
21 |
+
if (zbuffs[y*width+x] > z){
|
22 |
+
buffs[y*width+x] = i;
|
23 |
+
zbuffs[y*width+x] = z;
|
24 |
+
}
|
25 |
+
}
|
26 |
+
}
|
27 |
+
}
|
28 |
+
}
|