Cliff Biffle avatar Cliff Biffle committed 024470e

Depth folds now take the coordinates as input, so they can be context-aware.

Comments (0)

Files changed (1)

 - (void) updateProjection;
 - (void) updateModelView;
 
-- (void) computeLinearDepthField: (NSMutableData *)output andFoldUsing: (GLfloat (^)(GLfloat,GLfloat))fold;
+- (void) computeLinearDepthField: (NSMutableData *)output 
+                    andFoldUsing: (GLfloat (^)(int,int,GLfloat,GLfloat))fold;
 - (void) drawDepthFieldAsPoints: (NSData *)field;
 - (void) drawDepthFieldAsCards: (NSData *)field;
 - (void) drawDepthFieldAsMesh: (NSData *)field;
 - (void) depthFieldUpdated: (KFKinect *)kinect {
   if (!self.frozen) {
     if (separateForeground) {
-      [self computeLinearDepthField: backgroundDepthField andFoldUsing: ^(GLfloat x, GLfloat y){ return fmaxf(x,y); }]; 
-      [self computeLinearDepthField: foregroundDepthField andFoldUsing: ^(GLfloat _, GLfloat y){ return y; }];
+      [self computeLinearDepthField: backgroundDepthField
+                       andFoldUsing: ^(int x, int y, GLfloat a, GLfloat b){ return fmaxf(a, b); }]; 
+      [self computeLinearDepthField: foregroundDepthField 
+                       andFoldUsing: ^(int x, int y, GLfloat _, GLfloat b){ return b; }];
     } else {
-      [self computeLinearDepthField: backgroundDepthField andFoldUsing: ^(GLfloat _, GLfloat y){ return y; }];
+      [self computeLinearDepthField: backgroundDepthField 
+                       andFoldUsing: ^(int x, int y, GLfloat _, GLfloat b){ return b; }];
     }
     [self setNeedsDisplay: YES];
   }
 }
 
 - (void) computeLinearDepthField: (NSMutableData *)output
-                    andFoldUsing: (GLfloat (^)(GLfloat,GLfloat))fold; {
+                    andFoldUsing: (GLfloat (^)(int,int,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] = fold(linear[y * 640 + x], d1);
+      linear[y * 640 + x] = fold(x, y, linear[y * 640 + x], d1);
     }
   }
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.