[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41417] branches/soc-2011-tomato: Camera tracking integration

Sergey Sharybin g.ulairi at gmail.com
Mon Oct 31 17:03:26 CET 2011


Revision: 41417
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41417
Author:   nazgul
Date:     2011-10-31 16:03:24 +0000 (Mon, 31 Oct 2011)
Log Message:
-----------
Camera tracking integration
===========================

Split property used to define tracking camera focal length into two separated properties,
so now you can specify focal length in needed units directly without taking into account
units used for displaying.

Modified Paths:
--------------
    branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c

Modified: branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py	2011-10-31 14:27:32 UTC (rev 41416)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py	2011-10-31 16:03:24 UTC (rev 41417)
@@ -355,7 +355,10 @@
 
         row = layout.row(align=True)
         sub = row.split(percentage=0.65)
-        sub.prop(clip.tracking.camera, "focal_length")
+        if clip.tracking.camera.units == 'MILLIMETERS':
+            sub.prop(clip.tracking.camera, "focal_length")
+        else:
+            sub.prop(clip.tracking.camera, "focal_length_pixels")
         sub.prop(clip.tracking.camera, "units", text="")
 
         col = layout.column(align=True)

Modified: branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c
===================================================================
--- branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c	2011-10-31 14:27:32 UTC (rev 41416)
+++ branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c	2011-10-31 16:03:24 UTC (rev 41417)
@@ -132,29 +132,25 @@
 	return track->markersnr;
 }
 
-static float rna_trackingCamera_focal_get(PointerRNA *ptr)
+static float rna_trackingCamera_focal_mm_get(PointerRNA *ptr)
 {
 	MovieClip *clip= (MovieClip*)ptr->id.data;
 	MovieTrackingCamera *camera= &clip->tracking.camera;
 	float val= camera->focal;
 
-	if(camera->units==CAMERA_UNITS_MM) {
-		if(clip->lastsize[0])
-			val= val*camera->sensor_width/(float)clip->lastsize[0];
-	}
+	if(clip->lastsize[0])
+		val= val*camera->sensor_width/(float)clip->lastsize[0];
 
 	return val;
 }
 
-static void rna_trackingCamera_focal_set(PointerRNA *ptr, float value)
+static void rna_trackingCamera_focal_mm_set(PointerRNA *ptr, float value)
 {
 	MovieClip *clip= (MovieClip*)ptr->id.data;
 	MovieTrackingCamera *camera= &clip->tracking.camera;
 
-	if(camera->units==CAMERA_UNITS_MM) {
-		if(clip->lastsize[0])
-			value= clip->lastsize[0]*value/camera->sensor_width;
-	}
+	if(clip->lastsize[0])
+		value= clip->lastsize[0]*value/camera->sensor_width;
 
 	camera->focal= value;
 }
@@ -336,10 +332,17 @@
 	prop= RNA_def_property(srna, "focal_length", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "focal");
 	RNA_def_property_range(prop, 0.0f, 5000.0f);
+	RNA_def_property_float_funcs(prop, "rna_trackingCamera_focal_mm_get", "rna_trackingCamera_focal_mm_set", NULL);
 	RNA_def_property_ui_text(prop, "Focal Length", "Camera's focal length");
-	RNA_def_property_float_funcs(prop, "rna_trackingCamera_focal_get", "rna_trackingCamera_focal_set", NULL);
 	RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
 
+	/* Focal Length in pixels */
+	prop= RNA_def_property(srna, "focal_length_pixels", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "focal");
+	RNA_def_property_range(prop, 0.0f, 5000.0f);
+	RNA_def_property_ui_text(prop, "Focal Length", "Camera's focal length");
+	RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
+
 	/* Units */
 	prop= RNA_def_property(srna, "units", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_sdna(prop, NULL, "units");




More information about the Bf-blender-cvs mailing list