[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43507] trunk/blender/intern/cycles: Fix small code issue pointed out by nico_ga, was doing negation on unsigned type,

Brecht Van Lommel brechtvanlommel at pandora.be
Wed Jan 18 23:36:13 CET 2012


Revision: 43507
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43507
Author:   blendix
Date:     2012-01-18 22:36:12 +0000 (Wed, 18 Jan 2012)
Log Message:
-----------
Fix small code issue pointed out by nico_ga, was doing negation on unsigned type,
didn't seem to break anything though.

Modified Paths:
--------------
    trunk/blender/intern/cycles/kernel/kernel_shader.h
    trunk/blender/intern/cycles/render/light.cpp

Modified: trunk/blender/intern/cycles/kernel/kernel_shader.h
===================================================================
--- trunk/blender/intern/cycles/kernel/kernel_shader.h	2012-01-18 22:32:33 UTC (rev 43506)
+++ trunk/blender/intern/cycles/kernel/kernel_shader.h	2012-01-18 22:36:12 UTC (rev 43507)
@@ -151,7 +151,7 @@
 			instanced = true;
 		else
 #endif
-			sd->object = -sd->object-1;
+			sd->object = ~sd->object;
 #ifdef __INSTANCING__
 	}
 #endif

Modified: trunk/blender/intern/cycles/render/light.cpp
===================================================================
--- trunk/blender/intern/cycles/render/light.cpp	2012-01-18 22:32:33 UTC (rev 43506)
+++ trunk/blender/intern/cycles/render/light.cpp	2012-01-18 22:36:12 UTC (rev 43507)
@@ -109,7 +109,7 @@
 
 	/* triangles */
 	size_t offset = 0;
-	size_t j = 0;
+	int j = 0;
 
 	foreach(Object *object, scene->objects) {
 		Mesh *mesh = object->mesh;
@@ -128,8 +128,11 @@
 		/* sum area */
 		if(have_emission) {
 			Transform tfm = object->tfm;
-			int object_id = (mesh->transform_applied)? -j-1: j;
+			int object_id = j;
 
+			if(mesh->transform_applied)
+				object_id = ~object_id;
+
 			for(size_t i = 0; i < mesh->triangles.size(); i++) {
 				Shader *shader = scene->shaders[mesh->shader[i]];
 
@@ -161,9 +164,9 @@
 	if(!multi_light) {
 		float lightarea = (totarea > 0.0f)? totarea/scene->lights.size(): 1.0f;
 
-		for(size_t i = 0; i < scene->lights.size(); i++, offset++) {
+		for(int i = 0; i < scene->lights.size(); i++, offset++) {
 			distribution[offset].x = totarea;
-			distribution[offset].y = __int_as_float(-i-1);
+			distribution[offset].y = __int_as_float(~(int)i);
 			distribution[offset].z = 1.0f;
 			distribution[offset].w = scene->lights[i]->size;
 			totarea += lightarea;



More information about the Bf-blender-cvs mailing list