[Bf-blender-cvs] [3af88c6] temp_viewport_fx_merge: cleanup: code style

2015-03-22 Thread Mike Erwin
Commit: 3af88c69aaf883c35f8e653637249348c92cb994
Author: Mike Erwin
Date:   Mon Mar 23 01:07:39 2015 -0400
Branches: temp_viewport_fx_merge
https://developer.blender.org/rB3af88c69aaf883c35f8e653637249348c92cb994

cleanup: code style

Mostly I wanted to go through the new GPU library code and learn it
thoroughly.

===

M   source/blender/gpu/GPU_aspect.h
M   source/blender/gpu/GPU_clipping.h
M   source/blender/gpu/GPU_debug.h
M   source/blender/gpu/GPU_font.h
M   source/blender/gpu/GPU_immediate.h
M   source/blender/gpu/GPU_lighting.h
M   source/blender/gpu/GPU_matrix.h
M   source/blender/gpu/GPU_pixels.h
M   source/blender/gpu/GPU_primitives.h
M   source/blender/gpu/GPU_raster.h
M   source/blender/gpu/GPU_sprite.h
M   source/blender/gpu/GPU_state_latch.h
M   source/blender/gpu/intern/gpu_aspect.c
M   source/blender/gpu/intern/gpu_basic.c
M   source/blender/gpu/intern/gpu_blender_aspect.c
M   source/blender/gpu/intern/gpu_clipping.c
M   source/blender/gpu/intern/gpu_common.c
M   source/blender/gpu/intern/gpu_debug.c
M   source/blender/gpu/intern/gpu_extensions.c
M   source/blender/gpu/intern/gpu_immediate.c
M   source/blender/gpu/intern/gpu_init_exit.c
M   source/blender/gpu/intern/gpu_lighting.c
M   source/blender/gpu/intern/gpu_matrix.c
M   source/blender/gpu/intern/gpu_pixels.c
M   source/blender/gpu/intern/gpu_primitives.c
M   source/blender/gpu/intern/gpu_primitives_inline.h
M   source/blender/gpu/intern/gpu_private.h
M   source/blender/gpu/intern/gpu_raster.c
M   source/blender/gpu/intern/gpu_sprite.c
M   source/blender/gpu/intern/gpu_state_latch.c

===

diff --git a/source/blender/gpu/GPU_aspect.h b/source/blender/gpu/GPU_aspect.h
index 36c6b06..b3ed093 100644
--- a/source/blender/gpu/GPU_aspect.h
+++ b/source/blender/gpu/GPU_aspect.h
@@ -29,7 +29,7 @@
  */
 
 /** \file blender/gpu/GPU_aspect.h
-  *  \ingroup gpu
+  * \ingroup gpu
   */
 
 #include "BLI_sys_types.h"
@@ -40,28 +40,28 @@
 extern "C" {
 #endif
 
-void GPU_gen_aspects   (size_t count,   uint32_t* aspects);
-void GPU_delete_aspects(size_t count, const uint32_t* aspects);
+void GPU_gen_aspects   (size_t count,   uint32_t *aspects);
+void GPU_delete_aspects(size_t count, const uint32_t *aspects);
 
 typedef struct GPUaspectimpl {
-   bool  (*render_begin )(const void* object, void* param);
-   bool  (*render_end   )(const void* object, void* param);
-   bool  (*render_commit)(const void* object);
-   bool  (*select_begin )(const void* object, void* param);
-   bool  (*select_end   )(const void* object, void* param);
-   bool  (*select_commit)(const void* object);
-   void  (*enable   )(const void* object, uint32_t options);
-   void  (*disable  )(const void* object, uint32_t options);
-   void* object;
-   void* current_param; /* not a part of the interface */
+   bool (*render_begin )(const void *object, void *param);
+   bool (*render_end   )(const void *object, void *param);
+   bool (*render_commit)(const void *object);
+   bool (*select_begin )(const void *object, void *param);
+   bool (*select_end   )(const void *object, void *param);
+   bool (*select_commit)(const void *object);
+   void (*enable   )(const void *object, uint32_t options);
+   void (*disable  )(const void *object, uint32_t options);
+   void *object;
+   void *current_param; /* not a part of the interface */
 } GPUaspectimpl;
 
-void GPU_aspect_impl(uint32_t aspect, GPUaspectimpl* aspectImpl);
+void GPU_aspect_impl(uint32_t aspect, GPUaspectimpl *aspectImpl);
 
-bool GPU_aspect_begin(uint32_t aspect, void* param);
-bool GPU_aspect_end  (void);
+bool GPU_aspect_begin(uint32_t aspect, void *param);
+bool GPU_aspect_end(void);
 
-void GPU_aspect_enable (uint32_t aspect, uint32_t options);
+void GPU_aspect_enable(uint32_t aspect, uint32_t options);
 void GPU_aspect_disable(uint32_t aspect, uint32_t options);
 
 bool GPU_commit_aspect(void);
diff --git a/source/blender/gpu/GPU_clipping.h 
b/source/blender/gpu/GPU_clipping.h
index 519f3a9..7e833c7 100644
--- a/source/blender/gpu/GPU_clipping.h
+++ b/source/blender/gpu/GPU_clipping.h
@@ -29,7 +29,7 @@
  */
 
 /** \file blender/gpu/GPU_clipping.h
- *   \ingroup gpu
+ *  \ingroup gpu
  */
 
 #ifdef __cplusplus
@@ -46,8 +46,8 @@ void GPU_set_clip_planes(int clip_plane_count, const GPUplane 
clip_planes[]);
 int GPU_get_clip_planes(GPUplane clip_planes_out[]);
 
 /* Set clip planes without transforming them.
-   Suitable for restoring a backup copy of previous clip plane state.
-   Keeps clip planes from getting transformed twice. */
+ * Suitable for restoring a backup copy of previous clip plane state.
+ * Keeps clip planes from getting transformed twice. */
 void GPU_restore_cli

[Bf-blender-cvs] [96b0175] temp_viewport_fx_merge: delete redundant C++ file

2015-03-22 Thread Mike Erwin
Commit: 96b01755af14fe96441c8c8373f4a4e13946630d
Author: Mike Erwin
Date:   Sun Mar 22 20:24:26 2015 -0400
Branches: temp_viewport_fx_merge
https://developer.blender.org/rB96b01755af14fe96441c8c8373f4a4e13946630d

delete redundant C++ file

gpu_lighting.c has all of this code.

===

D   source/blender/gpu/intern/gpu_lighting.cpp

===

diff --git a/source/blender/gpu/intern/gpu_lighting.cpp 
b/source/blender/gpu/intern/gpu_lighting.cpp
deleted file mode 100644
index ae86c2a..000
--- a/source/blender/gpu/intern/gpu_lighting.cpp
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * * BEGIN GPL LICENSE BLOCK *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2013 Blender Foundation.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Jason Wilkins
- *
- * * END GPL LICENSE BLOCK *
- */
-
-/** \file source/blender/gpu/intern/gpu_lighting.c
- *  \ingroup gpu
- */
-
-#if WITH_GL_PROFILE_COMPAT
-#define GPU_MANGLE_DEPRECATED 0 /* Allow use of deprecated OpenGL functions in 
this file */
-#endif
-
-/* my interface */
-#include "intern/gpu_lighting_intern.h"
-
-/* my library */
-#include "GPU_extensions.h"
-#include "GPU_matrix.h"
-#include "GPU_safety.h"
-#include "GPU_common.h"
-
-/* internal */
-#include "intern/gpu_common_intern.h"
-
-/* external */
-#include "BLI_math_vector.h"
-
-
-
-typedef struct GPUbasicmaterial {
-   float specular[4];
-   int   shininess;
-} GPUbasicmaterial;
-
-static struct LIGHTING {
-   GPUbasiclightlight[GPU_MAX_COMMON_LIGHTS];
-   GPUbasicmaterial material;
-
-   uint32_t light_count;
-} LIGHTING;
-
-
-
-
-const GPUbasiclight GPU_DEFAULT_LIGHT =
-{
-   { 0, 0, 1, 0 }, /* position: directional light that is straight above 
(in eye coordinates) */
-   { 1, 1, 1, 1 }, /* diffuse : white  
   */
-   { 1, 1, 1, 1 }, /* specular: white  
   */
-   1, 0, 0,/* attenuation polynomal coefficients: no attenuation   
   */
-   { 0, 0, 1 },/* spotlight direction: straight ahead (in eye 
coordinates)*/
-   180, 0  /* spotlight parameters: no spotlight   
   */
-};
-
-
-
-void gpu_lighting_init(void)
-{
-   GPU_restore_basic_lights(1, &GPU_DEFAULT_LIGHT);
-}
-
-
-
-void gpu_lighting_exit(void)
-{
-}
-
-
-
-bool gpu_lighting_is_fast(void)
-{
-   int i;
-
-   for (i = 0; i < LIGHTING.light_count; i++)
-   if (LIGHTING.light[i].position[3] != 0)
-   return false;
-
-   return true;
-}
-
-
-
-void gpu_commit_lighting(void)
-{
-   const struct GPUcommon* common = gpu_get_common();
-   const struct GPUbasiclight* light  = LIGHTING.light;
-
-   int i;
-
-   for (i = 0; i < LIGHTING.light_count; i++) {
-   if (common) {
-   glUniform4fv(common->light_position [i], 1, 
light->position);
-   glUniform4fv(common->light_diffuse  [i], 1, 
light->diffuse);
-   glUniform4fv(common->light_specular [i], 1, 
light->specular);
-
-   glUniform1f (common->light_constant_attenuation [i],
light->constant_attenuation);
-   glUniform1f (common->light_linear_attenuation   [i],
light->linear_attenuation);
-   glUniform1f (common->light_quadratic_attenuation[i],
light->quadratic_attenuation);
-
-   glUniform3fv(common->light_spot_direction   [i], 1, 
light->spot_direction);
-   glUniform1f (common->light_spot_cutoff  [i],
light->spot_cutoff);
-   glUniform1f (common->light_spot_cos_cutoff  [i],
DEG2RAD(light->spot_cutoff));
-   glUniform1f (common->light_spot_exponent[i],
light->spot_exponent);
-   }
-
-#if defined(WITH_GL_PROFILE_COMPAT)
-   if (i < 8) {
-   glEnable (GL_LIGHT0+i);
-
- 

[Bf-blender-cvs] [572489e] master: Fix wrong sizeof() in new ghash hashing helpers code.

2015-03-22 Thread Bastien Montagne
Commit: 572489ec8936be0dfa1137f497d295e21f9ce693
Author: Bastien Montagne
Date:   Sun Mar 22 21:13:43 2015 +0100
Branches: master
https://developer.blender.org/rB572489ec8936be0dfa1137f497d295e21f9ce693

Fix wrong sizeof() in new ghash hashing helpers code.

Spotted by Coverity.

===

M   source/blender/blenlib/intern/BLI_ghash.c

===

diff --git a/source/blender/blenlib/intern/BLI_ghash.c 
b/source/blender/blenlib/intern/BLI_ghash.c
index 49d3cec..cd86bb8 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -1004,7 +1004,7 @@ unsigned int BLI_ghashutil_uinthash_v4(const unsigned int 
key[4])
 }
 unsigned int BLI_ghashutil_uinthash_v4_murmur(const unsigned int key[4])
 {
-   return BLI_hash_mm2((const unsigned char *)key, sizeof(key), 0);
+   return BLI_hash_mm2((const unsigned char *)key, sizeof(int) * 4  /* 
sizeof(key) */, 0);
 }
 
 bool BLI_ghashutil_uinthash_v4_cmp(const void *a, const void *b)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [059d5bc] master: OSX: fix 1 leak ( found and fixed by marcclintdion ) and 1 possible leak in dragndrop, backport to 2.74

2015-03-22 Thread Jens Verwiebe
Commit: 059d5bc80988320dca9cc2797d7bddc75ba0b82f
Author: Jens Verwiebe
Date:   Sun Mar 22 19:29:31 2015 +0100
Branches: master
https://developer.blender.org/rB059d5bc80988320dca9cc2797d7bddc75ba0b82f

OSX: fix 1 leak ( found and fixed by marcclintdion ) and 1 possible leak in 
dragndrop, backport to 2.74

===

M   intern/ghost/intern/GHOST_EventDragnDrop.h
M   intern/ghost/intern/GHOST_SystemCocoa.mm

===

diff --git a/intern/ghost/intern/GHOST_EventDragnDrop.h 
b/intern/ghost/intern/GHOST_EventDragnDrop.h
index c51f956..b7bf37c 100644
--- a/intern/ghost/intern/GHOST_EventDragnDrop.h
+++ b/intern/ghost/intern/GHOST_EventDragnDrop.h
@@ -112,6 +112,7 @@ public:
for (i = 0; i < strArray->count; i++)
free(strArray->strings[i]);

+   free(strArray->strings);
free(strArray);
}
break;
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm 
b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 095c738..ed1200b 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -882,7 +882,10 @@ GHOST_TSuccess 
GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType
if (!strArray) return GHOST_kFailure;

strArray->count = [droppedArray count];
-   if (strArray->count == 0) return 
GHOST_kFailure;
+   if (strArray->count == 0) {
+   free(strArray);
+   return GHOST_kFailure;
+   }

strArray->strings = (GHOST_TUns8**) 
malloc(strArray->count*sizeof(GHOST_TUns8*));

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [e7d0510] master: BGE: New hysteresis offset to improve LOD level transitions

2015-03-22 Thread Jorge Bernal
Commit: e7d051043dc82c2991eb491e0630d9b1065934c3
Author: Jorge Bernal
Date:   Sun Mar 22 18:13:53 2015 +0100
Branches: master
https://developer.blender.org/rBe7d051043dc82c2991eb491e0630d9b1065934c3

BGE: New hysteresis offset to improve  LOD level transitions

This change introduces a new hysteresis parameter that it will be added
or subtracted to/from the LOD distance to avoid popping when a LOD
object moves close to the LOD transition continuously.

Then, we have the following:

- a new LOD Hysteresis setting per scene (default 10%) which is located
in Scene context --> Level of Detail panel. This scene parameter also
will active/deactive the scene hysteresis.
- and a new LOD Hysteresis setting per object (default 10%) which is
located in Object context --> Levels of Detail panel. The LOD hysteresis
setting per object (if active) will overwrite the hysteresis setting per
scene value.

For the new blends: the hysteresis setting per scene would be active by
default and the per object would be inactive by default.
For the old blends: both hysteresis settings (per scene and per object)
would be inactive by default. A quick way to take advantage of this
feature for old blends would be to activate the hysteresis parameter in
the scene context -> Level of Detail panel

Reviewers: campbellbarton, kupoman, moguri

Reviewed By: kupoman, moguri

Subscribers: nonamejuju, lordodin

Differential Revision: https://developer.blender.org/D957

===

M   release/scripts/startup/bl_ui/properties_game.py
M   source/blender/blenkernel/intern/object.c
M   source/blender/blenkernel/intern/scene.c
M   source/blender/blenloader/intern/versioning_270.c
M   source/blender/blenloader/intern/versioning_defaults.c
M   source/blender/makesdna/DNA_object_types.h
M   source/blender/makesdna/DNA_scene_types.h
M   source/blender/makesrna/intern/rna_object.c
M   source/blender/makesrna/intern/rna_scene.c
M   source/gameengine/Converter/BL_BlenderDataConversion.cpp
M   source/gameengine/Ketsji/KX_GameObject.cpp
M   source/gameengine/Ketsji/KX_GameObject.h
M   source/gameengine/Ketsji/KX_Scene.cpp
M   source/gameengine/Ketsji/KX_Scene.h

===

diff --git a/release/scripts/startup/bl_ui/properties_game.py 
b/release/scripts/startup/bl_ui/properties_game.py
index 32a8e73..8ef9a08 100644
--- a/release/scripts/startup/bl_ui/properties_game.py
+++ b/release/scripts/startup/bl_ui/properties_game.py
@@ -523,7 +523,27 @@ class SCENE_PT_game_navmesh(SceneButtonsPanel, Panel):
 row.prop(rd, "sample_max_error")
 
 
-class WorldButtonsPanel:
+class SCENE_PT_game_hysteresis(SceneButtonsPanel, Panel):
+bl_label = "Level of Detail"
+COMPAT_ENGINES = {'BLENDER_GAME'}
+
+@classmethod
+def poll(cls, context):
+scene = context.scene
+return (scene and scene.render.engine in cls.COMPAT_ENGINES)
+
+def draw(self, context):
+layout = self.layout
+gs = context.scene.game_settings
+
+row = layout.row()
+row.prop(gs, "use_scene_hysteresis", text="Hysteresis")
+row = layout.row()
+row.active = gs.use_scene_hysteresis
+row.prop(gs, "scene_hysteresis_percentage", text="")
+
+
+class WorldButtonsPanel():
 bl_space_type = 'PROPERTIES'
 bl_region_type = 'WINDOW'
 bl_context = "world"
@@ -765,6 +785,7 @@ class OBJECT_PT_levels_of_detail(ObjectButtonsPanel, Panel):
 def draw(self, context):
 layout = self.layout
 ob = context.object
+gs = context.scene.game_settings
 
 col = layout.column()
 
@@ -782,6 +803,13 @@ class OBJECT_PT_levels_of_detail(ObjectButtonsPanel, 
Panel):
 row.prop(level, "use_mesh", text="")
 row.prop(level, "use_material", text="")
 
+row = box.row()
+row.active = gs.use_scene_hysteresis
+row.prop(level, "use_object_hysteresis", text="Hysteresis 
Override")
+row = box.row()
+row.active = gs.use_scene_hysteresis and 
level.use_object_hysteresis
+row.prop(level, "object_hysteresis_percentage", text="")
+
 row = col.row(align=True)
 row.operator("object.lod_add", text="Add", icon='ZOOMIN')
 row.menu("OBJECT_MT_lod_tools", text="", icon='TRIA_DOWN')
diff --git a/source/blender/blenkernel/intern/object.c 
b/source/blender/blenkernel/intern/object.c
index 08a74d0..174fb38 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1098,10 +1098,12 @@ void BKE_object_lod_add(Object *ob)
BLI_addtail(&ob->lodlevels, base);
base->flags = OB_LOD_USE_MESH | OB_LOD_USE_MAT;
base->source = ob;
+   base->obhysteresis = 10;
last = ob->currentlod = base;
}

lod->distance = last->dist

[Bf-blender-cvs] [4b45183] alembic_pointcache: More control over verbosity with Alembic archive info printing.

2015-03-22 Thread Lukas Tönne
Commit: 4b451838ede700d48ceaf0b7d93cd737808f9bc5
Author: Lukas Tönne
Date:   Sun Mar 22 14:23:33 2015 +0100
Branches: alembic_pointcache
https://developer.blender.org/rB4b451838ede700d48ceaf0b7d93cd737808f9bc5

More control over verbosity with Alembic archive info printing.

===

M   intern/cycles/app/cycles_alembic.cpp
M   intern/cycles/app/cycles_alembic.h
M   intern/cycles/app/cycles_xml.cpp

===

diff --git a/intern/cycles/app/cycles_alembic.cpp 
b/intern/cycles/app/cycles_alembic.cpp
index c801dd4..5bae8ee 100644
--- a/intern/cycles/app/cycles_alembic.cpp
+++ b/intern/cycles/app/cycles_alembic.cpp
@@ -186,7 +186,7 @@ static void visitProperties(std::stringstream &ss, 
ICompoundProperty iParent, st
ioIndent = oldIndent;
 }
 
-static void visitObject(std::stringstream &ss, IObject iObj, std::string 
iIndent)
+static void visitObject(std::stringstream &ss, IObject iObj, std::string 
iIndent, AbcArchiveInfoLevel info_level)
 {
// Object has a name, a full name, some meta data,
// and then it has a compound property full of properties.
@@ -208,18 +208,20 @@ static void visitObject(std::stringstream &ss, IObject 
iObj, std::string iIndent
ss << "Object " << "name=" << path << std::endl;
}

-   // Get the properties.
-   ICompoundProperty props = iObj.getProperties();
-   visitProperties(ss, props, iIndent);
+   if (info_level >= ABC_INFO_PROPERTIES) {
+   // Get the properties.
+   ICompoundProperty props = iObj.getProperties();
+   visitProperties(ss, props, iIndent);
+   }

// now the child objects
for (size_t i = 0 ; i < iObj.getNumChildren() ; i++) {
-   visitObject(ss, IObject(iObj, 
iObj.getChildHeader(i).getName()), iIndent);
+   visitObject(ss, IObject(iObj, 
iObj.getChildHeader(i).getName()), iIndent, info_level);
}
}
 }
 
-static std::string abc_archive_info(IArchive &archive)
+static std::string abc_archive_info(IArchive &archive, AbcArchiveInfoLevel 
info_level)
 {
std::stringstream ss;

@@ -253,12 +255,15 @@ static std::string abc_archive_info(IArchive &archive)
ss << std::endl;
}

-   visitObject(ss, archive.getTop(), "");
+   if (info_level >= ABC_INFO_OBJECTS)
+   visitObject(ss, archive.getTop(), "", info_level);

return ss.str();
 }
 
-void abc_read_ogawa_file(Scene *scene, const char *filepath)
+/* = */
+
+void abc_read_ogawa_file(Scene *scene, const char *filepath, 
AbcArchiveInfoLevel info_level)
 {
IArchive archive;
ABC_SAFE_CALL_BEGIN
@@ -266,11 +271,12 @@ void abc_read_ogawa_file(Scene *scene, const char 
*filepath)
ABC_SAFE_CALL_END

if (archive) {
-   printf("%s", abc_archive_info(archive).c_str());
+   if (info_level >= ABC_INFO_BASIC)
+   printf("%s", abc_archive_info(archive, 
info_level).c_str());
}
 }
 
-void abc_read_hdf5_file(Scene *scene, const char *filepath)
+void abc_read_hdf5_file(Scene *scene, const char *filepath, 
AbcArchiveInfoLevel info_level)
 {
 #ifdef WITH_HDF5
IArchive archive;
@@ -279,7 +285,8 @@ void abc_read_hdf5_file(Scene *scene, const char *filepath)
ABC_SAFE_CALL_END

if (archive) {
-   printf(abc_archive_info(archive));
+   if (info_level >= ABC_INFO_BASIC)
+   printf("%s", abc_archive_info(archive, 
info_level).c_str());
}
 #endif
 }
diff --git a/intern/cycles/app/cycles_alembic.h 
b/intern/cycles/app/cycles_alembic.h
index 761058b..df17f8b 100644
--- a/intern/cycles/app/cycles_alembic.h
+++ b/intern/cycles/app/cycles_alembic.h
@@ -21,8 +21,15 @@ CCL_NAMESPACE_BEGIN
 
 class Scene;
 
-void abc_read_ogawa_file(Scene *scene, const char *filepath);
-void abc_read_hdf5_file(Scene *scene, const char *filepath);
+enum AbcArchiveInfoLevel {
+   ABC_INFO_NONE = 0,
+   ABC_INFO_BASIC,
+   ABC_INFO_OBJECTS,
+   ABC_INFO_PROPERTIES,
+};
+
+void abc_read_ogawa_file(Scene *scene, const char *filepath, 
AbcArchiveInfoLevel info_level = ABC_INFO_NONE);
+void abc_read_hdf5_file(Scene *scene, const char *filepath, 
AbcArchiveInfoLevel info_level = ABC_INFO_NONE);
 
 CCL_NAMESPACE_END
 
diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp
index 471f08e..a0a9b9e 100644
--- a/intern/cycles/app/cycles_xml.cpp
+++ b/intern/cycles/app/cycles_xml.cpp
@@ -1122,11 +1122,11 @@ static void xml_read_alembic(const XMLReadState& state, 
pugi::xml_node node)
 

[Bf-blender-cvs] [8c142af] alembic_pointcache: Simple mesh import from Alembic files in Cycles standalone.

2015-03-22 Thread Lukas Tönne
Commit: 8c142af0b08b13edbbcd897f4de4aa0da8cbab1c
Author: Lukas Tönne
Date:   Sun Mar 22 18:16:07 2015 +0100
Branches: alembic_pointcache
https://developer.blender.org/rB8c142af0b08b13edbbcd897f4de4aa0da8cbab1c

Simple mesh import from Alembic files in Cycles standalone.

Note that Cycles currently only supports tessellated triangle/quad
meshes. Alembic PolyMesh generally has ngons, so external tessellation
is required until cycles gets a proper tessellation implementation of
its own.

===

M   intern/cycles/app/cycles_alembic.cpp

===

diff --git a/intern/cycles/app/cycles_alembic.cpp 
b/intern/cycles/app/cycles_alembic.cpp
index 5bae8ee..3a1e6a6 100644
--- a/intern/cycles/app/cycles_alembic.cpp
+++ b/intern/cycles/app/cycles_alembic.cpp
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "camera.h"
 #include "film.h"
@@ -59,6 +60,7 @@ CCL_NAMESPACE_BEGIN
 
 using namespace Alembic;
 using namespace Abc;
+using namespace AbcGeom;
 
 #define ABC_SAFE_CALL_BEGIN \
try {
@@ -263,16 +265,143 @@ static std::string abc_archive_info(IArchive &archive, 
AbcArchiveInfoLevel info_
 
 /* = */
 
+struct AbcReadState {
+   Scene *scene;   /* scene pointer */
+   float time;
+   Transform tfm;  /* current transform state */
+   bool smooth;/* smooth normal state */
+   int shader; /* current shader */
+   string base;/* base path to current file*/
+   float dicing_rate;  /* current dicing rate */
+   Mesh::DisplacementMethod displacement_method;
+};
+
+static ISampleSelector get_sample_selector(const AbcReadState &state)
+{
+   return ISampleSelector(state.time, ISampleSelector::kFloorIndex);
+}
+
+static Mesh *add_mesh(Scene *scene, const Transform& tfm)
+{
+   /* create mesh */
+   Mesh *mesh = new Mesh();
+   scene->meshes.push_back(mesh);
+
+   /* create object*/
+   Object *object = new Object();
+   object->mesh = mesh;
+   object->tfm = tfm;
+   scene->objects.push_back(object);
+
+   return mesh;
+}
+
+static void read_mesh(const AbcReadState &state, IPolyMesh object)
+{
+   /* add mesh */
+   Mesh *mesh = add_mesh(state.scene, state.tfm);
+   mesh->used_shaders.push_back(state.shader);
+
+   /* read state */
+   int shader = state.shader;
+   bool smooth = state.smooth;
+
+   mesh->displacement_method = state.displacement_method;
+
+   ISampleSelector ss = get_sample_selector(state);
+   IPolyMeshSchema schema = object.getSchema();
+
+   IPolyMeshSchema::Sample sample;
+   schema.get(sample, ss);
+
+   int totverts = sample.getPositions()->size();
+   int totfaces = sample.getFaceCounts()->size();
+   const V3f *P = sample.getPositions()->get();
+   const int32_t *verts = sample.getFaceIndices()->get();
+   const int32_t *nverts = sample.getFaceCounts()->get();
+
+   /* create vertices */
+   mesh->verts.reserve(totverts);
+   for(int i = 0; i < totverts; i++) {
+   mesh->verts.push_back(make_float3(P[i].x, P[i].y, P[i].z));
+   }
+   
+   /* create triangles */
+   int index_offset = 0;
+   
+   for(int i = 0; i < totfaces; i++) {
+   int n = nverts[i];
+   /* XXX TODO only supports tris and quads atm,
+* need a proper tessellation algorithm in cycles.
+*/
+   if (n > 4) {
+   printf("%d-sided face found, only triangles and quads 
are supported currently", n);
+   n = 4;
+   }
+   
+   for(int j = 0; j < n-2; j++) {
+   int v0 = verts[index_offset];
+   int v1 = verts[index_offset + j + 1];
+   int v2 = verts[index_offset + j + 2];
+   
+   assert(v0 < (int)totverts);
+   assert(v1 < (int)totverts);
+   assert(v2 < (int)totverts);
+   
+   mesh->add_triangle(v0, v1, v2, shader, smooth);
+   }
+   
+   index_offset += n;
+   }
+
+   /* temporary for test compatibility */
+   mesh->attributes.remove(ATTR_STD_VERTEX_NORMAL);
+}
+
+static void read_object(const AbcReadState &state, IObject object)
+{
+   for (int i = 0; i < object.getNumChildren(); ++i) {
+   IObject child = object.getChild(i);
+   const MetaData &metadata = child.getMetaData();
+   
+   if (IPolyMeshSchema::matches(metadata)) {
+   read_mesh(state, IPolyMesh(child, kWrapExisting));
+   }
+   else {

[Bf-blender-cvs] [3523a13] fracture_modifier: use center between objects for constraint types different than fixed, note: other types only work between clusters and settings for them are limited to th

2015-03-22 Thread Martin Felke
Commit: 3523a136d046a7247db341b8588134d479368225
Author: Martin Felke
Date:   Sun Mar 22 18:17:11 2015 +0100
Branches: fracture_modifier
https://developer.blender.org/rB3523a136d046a7247db341b8588134d479368225

use center between objects for constraint types different than fixed, note: 
other types only work between clusters and settings for them are limited to the 
type currently

===

M   source/blender/blenkernel/intern/rigidbody.c
M   source/blender/editors/object/object_modifier.c

===

diff --git a/source/blender/blenkernel/intern/rigidbody.c 
b/source/blender/blenkernel/intern/rigidbody.c
index 6c0bccd..b296841 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -1519,7 +1519,16 @@ void 
BKE_rigidbody_validate_sim_shard_constraint(RigidBodyWorld *rbw, RigidBodyS
}
 
/* do this for all constraints */
-   copy_v3_v3(loc, rbc->mi1->rigidbody->pos);
+   /* location for fixed constraints doesnt matter, so keep old 
setting */
+   if (rbc->type == RBC_TYPE_FIXED) {
+   copy_v3_v3(loc, rbc->mi1->rigidbody->pos);
+   }
+   else {
+   /* else set location to center */
+   add_v3_v3v3(loc, rbc->mi1->rigidbody->pos, 
rbc->mi2->rigidbody->pos);
+   mul_v3_fl(loc, 0.5f);
+   }
+
copy_v4_v4(rot, rbc->mi1->rigidbody->orn);
 
if (rb1 && rb2) {
diff --git a/source/blender/editors/object/object_modifier.c 
b/source/blender/editors/object/object_modifier.c
index ad72108..35e2455 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -2754,7 +2754,16 @@ static Object* 
do_convert_constraints(FractureModifierData *fmd, RigidBodyShardC
 
/*use same settings as in modifier
 *XXX Maybe use the CENTER between objects ? Might be correct for Non 
fixed constraints*/
-   copy_v3_v3(rbcon->loc, ob1->loc);
+   /* location for fixed constraints doesnt matter, so keep old setting */
+   /* keep in sync with rigidbody.c, 
BKE_rigidbody_validate_sim_shard_constraint() */
+   if (con->type == RBC_TYPE_FIXED) {
+   copy_v3_v3(rbcon->loc, ob1->loc);
+   }
+   else {
+   /* else set location to center */
+   add_v3_v3v3(rbcon->loc, ob1->loc, ob2->loc);
+   mul_v3_fl(rbcon->loc, 0.5f);
+   }
 
/*omit check for existing objects in group, since this seems very slow, 
and should not be necessary in this internal function*/
do_unchecked_constraint_add(scene, rbcon, con->type, reports, *base);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0b4a71b] master: BGE: Add physics constraints replication

2015-03-22 Thread Thomas Szepe
Commit: 0b4a71b07245d5370a02fae4dbde9195c9c58881
Author: Thomas Szepe
Date:   Sun Mar 22 17:55:43 2015 +0100
Branches: master
https://developer.blender.org/rB0b4a71b07245d5370a02fae4dbde9195c9c58881

BGE: Add physics constraints replication

This patch will add a physics constraints replication for group instances
(dupli group).
It also fix crashing when when a group instance is made from a linked
group instance and both are on the active layer.

Initial patch T31443 from moerdn (Martin Sell).

Reviewers: lordloki, sergof, moguri, sybren

Reviewed By: moguri, sybren

Differential Revision: https://developer.blender.org/D658

===

M   source/gameengine/Converter/BL_BlenderDataConversion.cpp
M   source/gameengine/Ketsji/KX_GameObject.cpp
M   source/gameengine/Ketsji/KX_GameObject.h
M   source/gameengine/Ketsji/KX_Scene.cpp
M   source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
M   source/gameengine/Physics/Bullet/CcdPhysicsController.h
M   source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
M   source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
M   source/gameengine/Physics/common/PHY_IPhysicsController.h
M   source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h

===

diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp 
b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
index 7e0588f..cd2e215 100644
--- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp
+++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
@@ -1741,6 +1741,16 @@ static KX_GameObject* getGameOb(STR_String 
busc,CListValue* sumolist)
 
 }
 
+static bool bl_isConstraintInList(KX_GameObject *gameobj, set 
convertedlist)
+{
+   set::iterator gobit;
+   for (gobit = convertedlist.begin(); gobit != convertedlist.end(); 
gobit++) {
+   if ((*gobit)->GetName() == gameobj->GetName())
+   return true;
+   }
+   return false;
+}
+
 /* helper for BL_ConvertBlenderObjects, avoids code duplication
  * note: all var names match args are passed from the caller */
 static void bl_ConvertBlenderObject_Single(
@@ -1900,6 +1910,12 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
// is not in a separate thread.
BL_Texture::GetMaxUnits();
 
+   /* We have to ensure that group definitions are only converted once
+* push all converted group members to this set.
+* This will happen when a group instance is made from a linked group 
instance
+* and both are on the active layer. */
+   set convertedlist;
+
if (alwaysUseExpandFraming) {
frame_type = RAS_FrameSettings::e_frame_extend;
aspect_width = canvas->GetWidth();
@@ -2031,6 +2047,11 @@ void BL_ConvertBlenderObjects(struct Main* maggie,

converter,

libloading);
 
+   /* Insert object to the 
constraint game object list
+* so we can check later if 
there is a instance in the scene or
+* an instance and its actual 
group definition. */
+   
convertedlist.insert((KX_GameObject*)gameobj->AddRef());
+
bool isInActiveLayer = false;
if (gameobj)
{
@@ -2270,93 +2291,50 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
// create physics joints
for (i=0;iGetCount();i++)
{
-   KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i);
-   struct Object* blenderobject = gameobj->GetBlenderObject();
-   ListBase *conlist;
+   PHY_IPhysicsEnvironment *physEnv = 
kxscene->GetPhysicsEnvironment();
+   KX_GameObject *gameobj = (KX_GameObject *)sumolist->GetValue(i);
+   struct Object *blenderobject = gameobj->GetBlenderObject();
+   ListBase *conlist = get_active_constraints2(blenderobject);
bConstraint *curcon;
 
-   if ((gameobj->GetLayer()&activeLayerBitInfo)==0)
+   if (!conlist)
continue;
 
-   conlist = get_active_constraints2(blenderobject);
-   if (conlist) {
-   for (curcon = (bConstraint *)conlist->first; curcon; 
curcon = (bConstraint *)curcon->next) {
-   if 
(curcon->type==CONSTRAINT_TYPE_RIGIDBODYJOINT) {
-
-   bRigidBodyJ

[Bf-blender-cvs] [c27ef56] alembic_pointcache: Simple inclusion of alembic files from inside xml files for cycles standalone.

2015-03-22 Thread Lukas Tönne
Commit: c27ef5692c2d155fc25efe2a26fb81b80ffae42f
Author: Lukas Tönne
Date:   Sun Mar 22 13:26:46 2015 +0100
Branches: alembic_pointcache
https://developer.blender.org/rBc27ef5692c2d155fc25efe2a26fb81b80ffae42f

Simple inclusion of alembic files from inside xml files for cycles
standalone.

The cycles XML files now can refer to Alembic (.abc) files. This will
call the default alembic reader to read in scene data. Currently it
simply prints the Alembic file structure.

Eventually a proper schema needs to be defined for both xml and abc.
Also care has to be taken to handle potential conflicts between settings
both within xml/abc and between them.

===

M   intern/cycles/app/cycles_xml.cpp

===

diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp
index 05e3438..471f08e 100644
--- a/intern/cycles/app/cycles_xml.cpp
+++ b/intern/cycles/app/cycles_xml.cpp
@@ -42,6 +42,9 @@
 #include "util_xml.h"
 
 #include "cycles_xml.h"
+#ifdef WITH_ALEMBIC
+#include "cycles_alembic.h"
+#endif
 
 CCL_NAMESPACE_BEGIN
 
@@ -1109,6 +1112,25 @@ static void xml_read_state(XMLReadState& state, 
pugi::xml_node node)
state.displacement_method = Mesh::DISPLACE_BOTH;
 }
 
+/* Alembic */
+static void xml_read_alembic(const XMLReadState& state, pugi::xml_node node)
+{
+#ifdef WITH_ALEMBIC
+   string filepath;
+   
+   if(xml_read_string(&filepath, node, "file")) {
+   filepath = path_join(state.base, filepath);
+   
+   if(xml_equal_string(node, "type", "hdf5"))
+   abc_read_hdf5_file(state.scene, filepath.c_str());
+   else if(xml_equal_string(node, "type", "ogawa"))
+   abc_read_ogawa_file(state.scene, filepath.c_str());
+   else
+   abc_read_ogawa_file(state.scene, filepath.c_str()); /* 
default */
+   }
+#endif
+}
+
 /* Scene */
 
 static void xml_read_include(const XMLReadState& state, const string& src);
@@ -1158,6 +1180,9 @@ static void xml_read_scene(const XMLReadState& state, 
pugi::xml_node scene_node)
if(xml_read_string(&src, node, "src"))
xml_read_include(state, src);
}
+   else if(string_iequals(node.name(), "alembic")) {
+   xml_read_alembic(state, node);
+   }
else
fprintf(stderr, "Unknown node \"%s\".\n", node.name());
}

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [25397ea] fracture_modifier: fix: some speed improvement for converting to objects or to keyframed objects and proper renaming of shards and constraints being created

2015-03-22 Thread Martin Felke
Commit: 25397ea3556e7f2e21d6c037fed8e0bbc57b9302
Author: Martin Felke
Date:   Sun Mar 22 10:13:39 2015 +0100
Branches: fracture_modifier
https://developer.blender.org/rB25397ea3556e7f2e21d6c037fed8e0bbc57b9302

fix: some speed improvement for converting to objects or to keyframed objects 
and proper renaming of shards and constraints being created

===

M   source/blender/blenkernel/BKE_object.h
M   source/blender/blenkernel/intern/object.c
M   source/blender/editors/object/object_modifier.c
M   source/blender/modifiers/intern/MOD_fracture.c

===

diff --git a/source/blender/blenkernel/BKE_object.h 
b/source/blender/blenkernel/BKE_object.h
index 9a0b1e1..c875bd2 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -87,7 +87,7 @@ bool BKE_object_is_in_wpaint_select_vert(struct Object *ob);
 
 struct Object *BKE_object_add_only_object(struct Main *bmain, int type, const 
char *name);
 struct Object *BKE_object_add(struct Main *bmain, struct Scene *scene, int 
type);
-struct Object *BKE_object_add_named(struct Main *bmain, struct Scene *scene, 
int type, const char *custname);
+struct Object *BKE_object_add_named(struct Main *bmain, struct Scene *scene, 
int type, char *custname);
 void *BKE_object_obdata_add_from_type(struct Main *bmain, int type);
 
 void BKE_object_lod_add(struct Object *ob);
diff --git a/source/blender/blenkernel/intern/object.c 
b/source/blender/blenkernel/intern/object.c
index f6d300e..ab26294 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1023,7 +1023,7 @@ Object *BKE_object_add_only_object(Main *bmain, int type, 
const char *name)
 
 /* general add: to scene, with layer from area and default name */
 /* creates minimum required data, but without vertices etc. */
-Object *BKE_object_add_named(Main *bmain, Scene *scene, int type, const char 
*custname)
+Object *BKE_object_add_named(Main *bmain, Scene *scene, int type, char 
*custname)
 {
Object *ob;
Base *base;
@@ -1031,6 +1031,7 @@ Object *BKE_object_add_named(Main *bmain, Scene *scene, 
int type, const char *cu
 
if (custname) {
BLI_strncpy(name, custname, sizeof(name));
+   MEM_freeN(custname);
}
else {
BLI_strncpy(name, get_obdata_defname(type), sizeof(name));
diff --git a/source/blender/editors/object/object_modifier.c 
b/source/blender/editors/object/object_modifier.c
index 611de07..ad72108 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -102,6 +102,8 @@
 
 #include "object_intern.h"
 
+#include "PIL_time.h"
+
 static void modifier_skin_customdata_delete(struct Object *ob);
 
 / API /
@@ -2540,103 +2542,284 @@ void 
OBJECT_OT_rigidbody_constraints_refresh(wmOperatorType *ot)
edit_modifier_properties(ot);
 }
 
+static void do_add_group_unchecked(Group* group, Object *ob, Base *bas)
+{
+   GroupObject *go;
+
+   go = MEM_callocN(sizeof(GroupObject), "groupobject");
+   BLI_addtail(&group->gobject, go);
+   go->ob = ob;
+
+   ob->flag |= OB_FROMGROUP;
+   bas->flag |= OB_FROMGROUP;
+}
+
+static bool do_unchecked_constraint_add(Scene *scene, Object *ob, int type, 
ReportList *reports, Base* base)
+{
+   RigidBodyWorld *rbw = BKE_rigidbody_get_world(scene);
+
+   /* check that object doesn't already have a constraint */
+   if (ob->rigidbody_constraint) {
+   BKE_reportf(reports, RPT_INFO, "Object '%s' already has a Rigid 
Body Constraint", ob->id.name + 2);
+   return false;
+   }
+   /* create constraint group if it doesn't already exits */
+   if (rbw->constraints == NULL) {
+   rbw->constraints = BKE_group_add(G.main, 
"RigidBodyConstraints");
+   }
+   /* make rigidbody constraint settings */
+   ob->rigidbody_constraint = BKE_rigidbody_create_constraint(scene, ob, 
type);
+   ob->rigidbody_constraint->flag |= RBC_FLAG_NEEDS_VALIDATE;
+
+   /* add constraint to rigid body constraint group */
+   //BKE_group_object_add(rbw->constraints, ob, scene, NULL);
+   do_add_group_unchecked(rbw->constraints, ob, base);
+
+   DAG_id_tag_update(&ob->id, OB_RECALC_OB);
+   return true;
+}
+
+static Object* do_convert_meshisland_to_object(MeshIsland *mi, Scene* scene, 
Group* g, Object* ob,
+RigidBodyWorld *rbw, int i, 
Object*** objs, KDTree **objtree, Base** base)
+{
+   float cent[3];
+   Mesh* me;
+   ModifierData *md;
+   bool foundFracture = false;
+   Object* ob_new = NULL;
+   char *name = BLI_strdupcat(ob->id.name + 2, "_shard");
+
+   /* create separate objects for meshislands */
+#i