[Bf-blender-cvs] [46eef60] master: Cleanup: Internal degrees removal.

Bastien Montagne noreply at git.blender.org
Tue Dec 3 20:47:14 CET 2013


Commit: 46eef60d93fd0d52ed4b94750f7a3248db5594ee
Author: Bastien Montagne
Date:   Tue Dec 3 20:09:25 2013 +0100
http://developer.blender.org/rB46eef60d93fd0d52ed4b94750f7a3248db5594ee

Cleanup: Internal degrees removal.

This patch changes most of the reamining degrees usage in internal code into radians.
I let a few which I know off asside, for reasons explained below - and I'm not sure to have found out all of them.

WARNING: this introduces forward incompatibility, which means files saved from this version won't open 100% correctly
         in previous versions (a few angle properties would use radians values as degrees...).

Details:
- Data:
-- Lamp.spotsize: Game engine exposed this setting in degrees, to not break the API here I kept it as such
                  (using getter/setter functions), still using radians internally.
-- Mesh.smoothresh: Didn't touch to this one, as we will hopefully replace it completely by loop normals currently in dev.

- Modifiers:
-- EdgeSplitModifierData.split_angle, BevelModifierData.bevel_angle: Done.

- Postprocessing:
-- WipeVars.angle (sequencer's effect), NodeBokehImage.angle, NodeBoxMask.rotation, NodeEllipseMask.rotation: Done.

- BGE:
-- bConstraintActuator: Orientation type done (the minloc[0] & maxloc[0] cases). Did not touch to 'limit location' type,
                        it can also limit rotation, but it exposes through RNA the same limit_min/limit_max, which hence
                        can be either distance or angle values, depending on the mode. Will leave this to BGE team.
-- bSoundActuator.cone_outer_angle_3d, bSoundActuator.cone_inner_angle_3d: Done (note I kept degrees in BGE itself,
                                                                           as it seems this is the expected value here...).
-- bRadarSensor.angle: Done.

Reviewers: brecht, campbellbarton, sergey, gaiaclary, dfelinto, moguri, jbakker, lukastoenne, howardt

Reviewed By: brecht, campbellbarton, sergey, gaiaclary, moguri, jbakker, lukastoenne, howardt
Thanks to all!

Differential Revision: http://developer.blender.org/D59

===================================================================

M	source/blender/blenkernel/BKE_blender.h
M	source/blender/blenkernel/intern/camera.c
M	source/blender/blenkernel/intern/lamp.c
M	source/blender/blenkernel/intern/sca.c
M	source/blender/blenkernel/intern/seqeffects.c
M	source/blender/blenloader/intern/versioning_260.c
M	source/blender/collada/DocumentImporter.cpp
M	source/blender/collada/LightExporter.cpp
M	source/blender/compositor/nodes/COM_DefocusNode.cpp
M	source/blender/compositor/operations/COM_BokehImageOperation.cpp
M	source/blender/compositor/operations/COM_BoxMaskOperation.cpp
M	source/blender/compositor/operations/COM_EllipseMaskOperation.cpp
M	source/blender/editors/space_node/drawnode.c
M	source/blender/editors/space_view3d/drawobject.c
M	source/blender/gpu/intern/gpu_draw.c
M	source/blender/gpu/intern/gpu_material.c
M	source/blender/makesrna/intern/rna_actuator.c
M	source/blender/makesrna/intern/rna_lamp.c
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/makesrna/intern/rna_nodetree.c
M	source/blender/makesrna/intern/rna_sensor.c
M	source/blender/makesrna/intern/rna_sequencer.c
M	source/blender/modifiers/intern/MOD_bevel.c
M	source/blender/modifiers/intern/MOD_edgesplit.c
M	source/blender/render/intern/source/convertblender.c
M	source/gameengine/Converter/KX_ConvertActuators.cpp
M	source/gameengine/Converter/KX_ConvertSensors.cpp
M	source/gameengine/Ketsji/KX_Light.cpp
M	source/gameengine/Ketsji/KX_Light.h

===================================================================

diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index a4a6b60..989a599 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -42,7 +42,7 @@ extern "C" {
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         269
-#define BLENDER_SUBVERSION      3
+#define BLENDER_SUBVERSION      4
 /* 262 was the last editmesh release but it has compatibility code for bmesh data */
 #define BLENDER_MINVERSION      262
 #define BLENDER_MINSUBVERSION   0
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index ab952fb..aee8ede 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -227,7 +227,7 @@ void BKE_camera_params_from_object(CameraParams *params, Object *ob)
 	else if (ob->type == OB_LAMP) {
 		/* lamp object */
 		Lamp *la = ob->data;
-		float fac = cosf((float)M_PI * la->spotsize / 360.0f);
+		float fac = cosf(la->spotsize * 0.5f);
 		float phi = acos(fac);
 
 		params->lens = 16.0f * fac / sinf(phi);
diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c
index 2bd521a..904dbec 100644
--- a/source/blender/blenkernel/intern/lamp.c
+++ b/source/blender/blenkernel/intern/lamp.c
@@ -63,7 +63,7 @@ Lamp *BKE_lamp_add(Main *bmain, const char *name)
 	la->r = la->g = la->b = la->k = 1.0f;
 	la->haint = la->energy = 1.0f;
 	la->dist = 25.0f;
-	la->spotsize = 45.0f;
+	la->spotsize = DEG2RADF(45.0f);
 	la->spotblend = 0.15f;
 	la->att2 = 1.0f;
 	la->mode = LA_SHAD_BUF;
diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c
index 7c374fd..b0b64ca 100644
--- a/source/blender/blenkernel/intern/sca.c
+++ b/source/blender/blenkernel/intern/sca.c
@@ -44,6 +44,7 @@
 #include "DNA_object_types.h"
 
 #include "BLI_blenlib.h"
+#include "BLI_math.h"
 #include "BKE_global.h"
 #include "BKE_main.h"
 #include "BKE_library.h"
@@ -405,8 +406,8 @@ void init_actuator(bActuator *act)
 		sa->sound3D.rolloff_factor = 1.0f;
 		sa->sound3D.reference_distance = 1.0f;
 		sa->sound3D.max_gain = 1.0f;
-		sa->sound3D.cone_inner_angle = 360.0f;
-		sa->sound3D.cone_outer_angle = 360.0f;
+		sa->sound3D.cone_inner_angle = DEG2RADF(360.0f);
+		sa->sound3D.cone_outer_angle = DEG2RADF(360.0f);
 		sa->sound3D.max_distance = FLT_MAX;
 		break;
 	case ACT_OBJECT:
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index 7b3f18c..1507e17 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -1246,8 +1246,8 @@ typedef struct WipeZone {
 
 static void precalc_wipe_zone(WipeZone *wipezone, WipeVars *wipe, int xo, int yo)
 {
-	wipezone->flip = (wipe->angle < 0);
-	wipezone->angle = tanf(DEG2RADF(fabsf(wipe->angle)));
+	wipezone->flip = (wipe->angle < 0.0f);
+	wipezone->angle = tanf(fabsf(wipe->angle));
 	wipezone->xo = xo;
 	wipezone->yo = yo;
 	wipezone->width = (int)(wipe->edgeWidth * ((xo + yo) / 2.0f));
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c
index 14eb8ff..e023e8e 100644
--- a/source/blender/blenloader/intern/versioning_260.c
+++ b/source/blender/blenloader/intern/versioning_260.c
@@ -2530,7 +2530,88 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
 		}
 	}
 
-	{
+	if (!MAIN_VERSION_ATLEAST(main, 269, 4)) {
+		/* Internal degrees to radians conversions... */
+		{
+			Scene *scene;
+			Object *ob;
+			Lamp *lamp;
+
+			for (lamp = main->lamp.first; lamp; lamp = lamp->id.next)
+				lamp->spotsize = DEG2RADF(lamp->spotsize);
+
+			for (ob = main->object.first; ob; ob = ob->id.next) {
+				ModifierData *md;
+				bSensor *bs;
+				bActuator *ba;
+
+				for (md = ob->modifiers.first; md; md = md->next) {
+					if (md->type == eModifierType_EdgeSplit) {
+						EdgeSplitModifierData *emd = (EdgeSplitModifierData *)md;
+						emd->split_angle = DEG2RADF(emd->split_angle);
+					}
+					else if (md->type == eModifierType_Bevel) {
+						BevelModifierData *bmd = (BevelModifierData *)md;
+						bmd->bevel_angle = DEG2RADF(bmd->bevel_angle);
+					}
+				}
+
+				for (bs = ob->sensors.first; bs; bs = bs->next) {
+					if (bs->type == SENS_RADAR) {
+						bRadarSensor *brs = bs->data;
+						brs->angle = DEG2RADF(brs->angle);
+					}
+				}
+
+				for (ba = ob->actuators.first; ba; ba = ba->next) {
+					if (ba->type == ACT_CONSTRAINT) {
+						bConstraintActuator *bca = ba->data;
+						if (bca->type == ACT_CONST_TYPE_ORI) {
+							bca->minloc[0] = DEG2RADF(bca->minloc[0]);
+							bca->maxloc[0] = DEG2RADF(bca->maxloc[0]);
+						}
+					}
+					else if (ba->type == ACT_SOUND) {
+						bSoundActuator *bsa = ba->data;
+						bsa->sound3D.cone_outer_angle = DEG2RADF(bsa->sound3D.cone_outer_angle);
+						bsa->sound3D.cone_inner_angle = DEG2RADF(bsa->sound3D.cone_inner_angle);
+					}
+				}
+			}
+
+			for (scene = main->scene.first; scene; scene = scene->id.next) {
+				Sequence *seq;
+				SEQ_BEGIN (scene->ed, seq)
+				{
+					if (seq->type == SEQ_TYPE_WIPE) {
+						WipeVars *wv = seq->effectdata;
+						wv->angle = DEG2RADF(wv->angle);
+					}
+				}
+				SEQ_END
+			}
+
+			FOREACH_NODETREE(main, ntree, id) {
+				if (ntree->type == NTREE_COMPOSIT) {
+					bNode *node;
+					for (node = ntree->nodes.first; node; node = node->next) {
+						if (node->type == CMP_NODE_BOKEHIMAGE) {
+							NodeBokehImage *n = node->storage;
+							n->angle = DEG2RADF(n->angle);
+						}
+						if (node->type == CMP_NODE_MASK_BOX) {
+							NodeBoxMask *n = node->storage;
+							n->rotation = DEG2RADF(n->rotation);
+						}
+						if (node->type == CMP_NODE_MASK_ELLIPSE) {
+							NodeEllipseMask *n = node->storage;
+							n->rotation = DEG2RADF(n->rotation);
+						}
+					}
+				}
+			} FOREACH_NODETREE_END
+		}
+
 		if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingPlaneTrack", "float", "image_opacity")) {
 			MovieClip *clip;
 			for (clip = main->movieclip.first; clip; clip = clip->id.next) {
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index 9877067..144fe75 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -1127,6 +1127,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
 		et->setData("energy", &(lamp->energy));
 		et->setData("dist", &(lamp->dist));
 		et->setData("spotsize", &(lamp->spotsize));
+		lamp->spotsize = DEG2RADF(lamp->spotsize);
 		et->setData("spotblend", &(lamp->spotblend));
 		et->setData("halo_intensity", &(lamp->haint));
 		et->setData("att1", &(lamp->att1));
@@ -1223,7 +1224,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
 					lamp->falloff_type = LA_FALLOFF_INVSQUARE;
 				if (IS_EQ(att2, 0.0f) && att1 > 0)
 					lamp->falloff_type = LA_FALLOFF_INVLINEAR;
-				lamp->spotsize = light->getFallOffAngle().getValue();
+				lamp->spotsize = DEG2RADF(light->getFallOffAngle().getValue());
 				lamp->spotblend = light->getFallOffExponent().getValue();
 			}
 			break;
diff --git a/source/blender/collada/LightExporter.cpp b/source/blender/collada/LightExporter.cpp
index a277963..ff50abf 100644
--- a/source/blender/collada/LightExporter.cpp
+++ b/source/blender/collada/LightExporter.cpp
@@ -101,7 +101,7 @@ void LightsExporter::operator()(Object *ob)
 	else if (la->type == LA_SPOT) {
 		COLLADASW::SpotLight cla(mSW, la_id, la_name);
 		cla.setColor(col, false, "color");
-		cla.setFallOffAngle(la->spotsize, false, "fall_off_angle");
+		cla.setFallOffAngle(RAD2DEGF(la->spotsize), false, "fall_off_angle");
 		cla.setFallOffExponent(la->spotblend, false, "fall_off_exponent");
 		cla.setConstantAttenuation(constatt);
 		cla.setLinearAttenuation(linatt);
@@ -147,7 +147,7 @@ bool LightsExporter::exportBlenderProfile(COLLADASW::Light &cla, Lamp *la)
 	cla.addExtraTechniqueParameter("blender", "shadow_b", la->shdwb, "blender_shadow_b");
 	cla.addExtraTechniqueParameter("blender", "energy", la->energy, "blender_energy");
 	cla.addExtraTechniqueParameter("blender", "dist", la->dist, "blender_dist");
-	cla.addExtraTechniqueParameter("blender", "spotsize", la->spotsize);
+	cla.addExtraTechniqueParameter("blender", "spotsize", RAD2DEGF(la->spotsize));
 	cla.addExtraTechniqueParameter("blender", "spotblend", la->spotblend);
 	cla.addExtraTechniqueParameter("blender", "halo_intensity", la->haint, "blnder_halo_intensity");
 	cla.addExtraTechniqueParameter("blender", "att1", la->att1);
diff --git a/source/blender/compositor/nodes/COM_DefocusNode.cpp b/source/blender/compositor/nodes/COM_DefocusNode.cpp
index b6dd0e5..c2bd899 100644
--- a/source/blender/compositor/nodes/COM_DefocusNode.cpp
+++ b/source/blender/compositor/nodes/COM_DefocusNode.cpp
@@ -85,7 +85,7 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext
 	
 	BokehImageOperation *bokeh = new BokehImageOperation();
 	NodeBokehImage *bokehdata = new NodeBokehImage();
-	bokehdata->angle = RAD2DEGF(data->rotation);
+	bokehdata->angle = data->rotation;
 	bokehdata->rounding = 0.0f;
 	bokehdata->flaps = data->bktype;
 	if (data->bktype < 3) {
diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.cpp b/source/blender/compositor/operations/COM_BokehImageOperation.cpp
index 82de750..6617fc6 100644
--- a/source/blender/compositor/operations/COM_BokehImageOperation.cpp
+++ b/source/blender/compositor/operations/COM_BokehImageOperation.cpp
@@ -35,7 +35,7 @@ void BokehImageOperation::initExecution()
 	this->m_inverseRounding = 1.0f - this->m_data->rounding;
 	this->m_circularDistance = getWidth() / 2;
 	this->m_flapRad = (float)(M_PI * 2) / this->m_data->flaps;
-	this->m_flapRadAdd = (this->m_data->angle / 360.0f) * (float)(M_PI * 2.0);
+	this->m_flapRadAdd = this->m_data->angle;
 	while (this->m_flapRadAdd < 0.0f) {
 		this->m_flapRadAdd += (float)(M_PI * 2.0);
 	}
diff --git a/source/blender/compositor/operations/COM_BoxMaskOperation.cpp b/source/blender/compositor/operations/COM_BoxMaskOperation.cpp
index 4dd92ae..4e95

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list