Commits

Cliff Biffle  committed 7ad17ec

Depth field linearization now takes a function specifying how to combine the new data with the old.

  • Participants
  • Parent commits 7472722

Comments (0)

Files changed (1)

File KVDepthView.m

 - (void) updateProjection;
 - (void) updateModelView;
 
-- (void) computeLinearDepthField: (NSMutableData *)output;
+- (void) computeLinearDepthField: (NSMutableData *)output andFoldUsing: (GLfloat (^)(GLfloat,GLfloat))fold;
 - (void) drawDepthFieldAsPoints: (NSData *)field;
 - (void) drawDepthFieldAsCards: (NSData *)field;
 - (void) drawDepthFieldAsMesh: (NSData *)field;
 
 - (void) depthFieldUpdated: (KFKinect *)kinect {
   if (!self.frozen) {
-    [self computeLinearDepthField: linearDepthField];
+    [self computeLinearDepthField: linearDepthField andFoldUsing: ^(GLfloat _, GLfloat y){ return y; }];
     [self setNeedsDisplay: YES];
   }
 }
   glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
 }
 
-- (void) computeLinearDepthField: (NSMutableData *)output {
+- (void) computeLinearDepthField: (NSMutableData *)output
+                    andFoldUsing: (GLfloat (^)(GLfloat,GLfloat))fold; {
   const uint16_t *depths = [rawDepthField bytes];
   GLfloat *linear = [output mutableBytes];
   
     for (int x = 0; x < 640; x++) {
       GLfloat d1 = depthTable[depths[y * 640 + x]];
       if (d1 < 0.1F) d1 = 0.F;
-      linear[y * 640 + x] = d1;
+      linear[y * 640 + x] = fold(linear[y * 640 + x], d1);
     }
   }
 }