Commits

Cliff Biffle committed a2f6df4

Renamed KVSinglePlaneDepthMap -> KVDoubleBufferDepthMap. Note that this is currently a lie: I wanted to commit the rename before I rearrange its innards.

Comments (0)

Files changed (6)

 #import "KVPointCloudRenderer.h"
 #import "KVQuadRenderer.h"
 #import "KVTriStripRenderer.h"
-#import "KVSinglePlaneDepthMap.h"
+#import "KVDoubleBufferDepthMap.h"
 #import "KVAveragingDepthMap.h"
 #import "trackball.h"
 #import "utility.h"
 }
 
 - (IBAction) selectStaticDepthMap: sender {
-  self.depthMap = [[[KVSinglePlaneDepthMap alloc] init] autorelease];
+  self.depthMap = [[[KVDoubleBufferDepthMap alloc] init] autorelease];
 }
 
 - (IBAction) selectAveragingDepthMap: sender {

KVDoubleBufferDepthMap.h

+/*
+ * Copyright 2010 Cliff L. Biffle.  All Rights Reserved.
+ * Use of this source code is governed by the Apache License 2.0,
+ * which can be found in the LICENSE file.
+ */
+
+#import <Cocoa/Cocoa.h>
+#import "types.h"
+#import "KVDepthMap.h"
+
+@interface KVDoubleBufferDepthMap : NSObject <KVDepthMap> {
+ @private
+  GLfloat linearizationTable[2048];
+  linear_depth_t zs;
+  colors_t colors;
+}
+
+@end

KVDoubleBufferDepthMap.m

+/*
+ * Copyright 2010 Cliff L. Biffle.  All Rights Reserved.
+ * Use of this source code is governed by the Apache License 2.0,
+ * which can be found in the LICENSE file.
+ */
+
+#import "KVDoubleBufferDepthMap.h"
+#import "KVRenderer.h"
+
+@interface KVDoubleBufferDepthMap ()
+- (void) buildLinearizationTable;
+@end
+
+@implementation KVDoubleBufferDepthMap
+
+- init {
+  if ((self = [super init])) {
+    [self buildLinearizationTable];
+  }
+  return self;
+}
+
+#pragma mark --- KVDepthMap implementation
+
+- (void) updateDepth: (const depth_t *)rawDepthSamples {
+  linear_depth_t *out = &zs;  // Avoid ivar indirection during loop.
+  
+  for (int y = 0; y < 480; y++) {
+    for (int x = 0; x < 640; x++) {
+      out->z[y][x] = linearizationTable[rawDepthSamples->samples[y][x]];
+    }
+  }
+}
+
+- (void) updateColor: (const colors_t *)pixels {
+  memcpy(&colors, pixels, sizeof(colors_t));
+}
+
+- (void) drawInCurrentOpenGLContextWithRenderer: (id <KVRenderer>) renderer {
+  NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate];
+  [renderer drawInCurrentOpenGLContext: &zs colors: &colors];
+  NSTimeInterval end = [NSDate timeIntervalSinceReferenceDate];
+  
+  NSLog(@"Render (%@, lights=%d, texture=%d) took %.03fµs",
+        [[renderer class] description],
+        renderer.lit,
+        renderer.textured,
+        (end - start) * 1000000.);
+}
+
+#pragma mark --- Internals
+
+// The Kinect produces 11-bit depth samples.  Z-resolution decreases
+// with distance, following a curve that looks suspiciously like the
+// one used for perspective projection.  The ROS folks at CCNY derived
+// the equation below, for converting Kinect depth samples to meters.
+// This method memoizes the function over the entire 2048-element
+// domain.  This implies replacing a couple of floating-point constant
+// loads, an addition, and a division with an indirection to very hot
+// memory.  On my machine this eliminates 60% of time spent calculating
+// linear depths.
+- (void) buildLinearizationTable {
+  for (uint16_t depth = 0; depth < 2048; depth++) {
+    linearizationTable[depth] = -325.616F / ((GLfloat) depth + -1084.61F);
+    
+    // Simplification: when the Kinect reports "no data" for a point
+    // (typically because the IR projector is occluded) the result is
+    // a "very close" reading of nearly zero meters.  All my renderers
+    // filter out such readings, so we coerce it to exactly 0.F here
+    // to simplify that.
+    if (linearizationTable[depth] < 0.1F) {
+      linearizationTable[depth] = 0.F;
+    }
+  }
+}
+
+@end

KVSinglePlaneDepthMap.h

-/*
- * Copyright 2010 Cliff L. Biffle.  All Rights Reserved.
- * Use of this source code is governed by the Apache License 2.0,
- * which can be found in the LICENSE file.
- */
-
-#import <Cocoa/Cocoa.h>
-#import "types.h"
-#import "KVDepthMap.h"
-
-@interface KVSinglePlaneDepthMap : NSObject <KVDepthMap> {
- @private
-  GLfloat linearizationTable[2048];
-  linear_depth_t zs;
-  colors_t colors;
-}
-
-@end

KVSinglePlaneDepthMap.m

-/*
- * Copyright 2010 Cliff L. Biffle.  All Rights Reserved.
- * Use of this source code is governed by the Apache License 2.0,
- * which can be found in the LICENSE file.
- */
-
-#import "KVSinglePlaneDepthMap.h"
-#import "KVRenderer.h"
-
-@interface KVSinglePlaneDepthMap ()
-- (void) buildLinearizationTable;
-@end
-
-@implementation KVSinglePlaneDepthMap
-
-- init {
-  if ((self = [super init])) {
-    [self buildLinearizationTable];
-  }
-  return self;
-}
-
-#pragma mark --- KVDepthMap implementation
-
-- (void) updateDepth: (const depth_t *)rawDepthSamples {
-  linear_depth_t *out = &zs;  // Avoid ivar indirection during loop.
-  
-  for (int y = 0; y < 480; y++) {
-    for (int x = 0; x < 640; x++) {
-      out->z[y][x] = linearizationTable[rawDepthSamples->samples[y][x]];
-    }
-  }
-}
-
-- (void) updateColor: (const colors_t *)pixels {
-  memcpy(&colors, pixels, sizeof(colors_t));
-}
-
-- (void) drawInCurrentOpenGLContextWithRenderer: (id <KVRenderer>) renderer {
-  NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate];
-  [renderer drawInCurrentOpenGLContext: &zs colors: &colors];
-  NSTimeInterval end = [NSDate timeIntervalSinceReferenceDate];
-  
-  NSLog(@"Render (%@, lights=%d, texture=%d) took %.03fµs",
-        [[renderer class] description],
-        renderer.lit,
-        renderer.textured,
-        (end - start) * 1000000.);
-}
-
-#pragma mark --- Internals
-
-// The Kinect produces 11-bit depth samples.  Z-resolution decreases
-// with distance, following a curve that looks suspiciously like the
-// one used for perspective projection.  The ROS folks at CCNY derived
-// the equation below, for converting Kinect depth samples to meters.
-// This method memoizes the function over the entire 2048-element
-// domain.  This implies replacing a couple of floating-point constant
-// loads, an addition, and a division with an indirection to very hot
-// memory.  On my machine this eliminates 60% of time spent calculating
-// linear depths.
-- (void) buildLinearizationTable {
-  for (uint16_t depth = 0; depth < 2048; depth++) {
-    linearizationTable[depth] = -325.616F / ((GLfloat) depth + -1084.61F);
-    
-    // Simplification: when the Kinect reports "no data" for a point
-    // (typically because the IR projector is occluded) the result is
-    // a "very close" reading of nearly zero meters.  All my renderers
-    // filter out such readings, so we coerce it to exactly 0.F here
-    // to simplify that.
-    if (linearizationTable[depth] < 0.1F) {
-      linearizationTable[depth] = 0.F;
-    }
-  }
-}
-
-@end

KinectViewer.xcodeproj/project.pbxproj

 		C708F46512A03E8500656901 /* KVTriStripRenderer.m in Sources */ = {isa = PBXBuildFile; fileRef = C708F46312A03E8500656901 /* KVTriStripRenderer.m */; };
 		C708F46A12A03E8F00656901 /* KVPointCloudRenderer.m in Sources */ = {isa = PBXBuildFile; fileRef = C708F46712A03E8F00656901 /* KVPointCloudRenderer.m */; };
 		C708F46B12A03E8F00656901 /* KVQuadRenderer.m in Sources */ = {isa = PBXBuildFile; fileRef = C708F46912A03E8F00656901 /* KVQuadRenderer.m */; };
-		C708F55912A0728800656901 /* KVSinglePlaneDepthMap.m in Sources */ = {isa = PBXBuildFile; fileRef = C708F55812A0728800656901 /* KVSinglePlaneDepthMap.m */; };
+		C708F55912A0728800656901 /* KVDoubleBufferDepthMap.m in Sources */ = {isa = PBXBuildFile; fileRef = C708F55812A0728800656901 /* KVDoubleBufferDepthMap.m */; };
 		C708F5E412A0779500656901 /* KVAveragingDepthMap.m in Sources */ = {isa = PBXBuildFile; fileRef = C708F5E312A0779500656901 /* KVAveragingDepthMap.m */; };
 		C70E62AF129C5055004A44B3 /* KVDepthView.m in Sources */ = {isa = PBXBuildFile; fileRef = C70E62AE129C5055004A44B3 /* KVDepthView.m */; };
 		C70E62FB129C572E004A44B3 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C70E62FA129C572E004A44B3 /* OpenGL.framework */; };
 		C708F46812A03E8F00656901 /* KVQuadRenderer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KVQuadRenderer.h; sourceTree = "<group>"; };
 		C708F46912A03E8F00656901 /* KVQuadRenderer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KVQuadRenderer.m; sourceTree = "<group>"; };
 		C708F55412A0726800656901 /* KVDepthMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KVDepthMap.h; sourceTree = "<group>"; };
-		C708F55712A0728800656901 /* KVSinglePlaneDepthMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KVSinglePlaneDepthMap.h; sourceTree = "<group>"; };
-		C708F55812A0728800656901 /* KVSinglePlaneDepthMap.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KVSinglePlaneDepthMap.m; sourceTree = "<group>"; };
+		C708F55712A0728800656901 /* KVDoubleBufferDepthMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KVDoubleBufferDepthMap.h; sourceTree = "<group>"; };
+		C708F55812A0728800656901 /* KVDoubleBufferDepthMap.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KVDoubleBufferDepthMap.m; sourceTree = "<group>"; };
 		C708F5E212A0779500656901 /* KVAveragingDepthMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KVAveragingDepthMap.h; sourceTree = "<group>"; };
 		C708F5E312A0779500656901 /* KVAveragingDepthMap.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KVAveragingDepthMap.m; sourceTree = "<group>"; };
 		C70E62AD129C5055004A44B3 /* KVDepthView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KVDepthView.h; sourceTree = "<group>"; };
 			isa = PBXGroup;
 			children = (
 				C708F55412A0726800656901 /* KVDepthMap.h */,
-				C708F55712A0728800656901 /* KVSinglePlaneDepthMap.h */,
-				C708F55812A0728800656901 /* KVSinglePlaneDepthMap.m */,
+				C708F55712A0728800656901 /* KVDoubleBufferDepthMap.h */,
+				C708F55812A0728800656901 /* KVDoubleBufferDepthMap.m */,
 				C708F5E212A0779500656901 /* KVAveragingDepthMap.h */,
 				C708F5E312A0779500656901 /* KVAveragingDepthMap.m */,
 			);
 				C708F46512A03E8500656901 /* KVTriStripRenderer.m in Sources */,
 				C708F46A12A03E8F00656901 /* KVPointCloudRenderer.m in Sources */,
 				C708F46B12A03E8F00656901 /* KVQuadRenderer.m in Sources */,
-				C708F55912A0728800656901 /* KVSinglePlaneDepthMap.m in Sources */,
+				C708F55912A0728800656901 /* KVDoubleBufferDepthMap.m in Sources */,
 				C708F5E412A0779500656901 /* KVAveragingDepthMap.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
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.