[Bf-blender-cvs] [3de5370e9df] blender2.8: Cleanup: unused defines

2017-06-30 Thread Campbell Barton
Commit: 3de5370e9dfc9d9f90b9bf2d5eeb47e9ae7bf1dd
Author: Campbell Barton
Date:   Sat Jul 1 20:19:12 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB3de5370e9dfc9d9f90b9bf2d5eeb47e9ae7bf1dd

Cleanup: unused defines

===

M   
source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
M   
source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c
M   source/blender/makesdna/intern/makesdna.c
M   
source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c

===

diff --git 
a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
 
b/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
index 485b42f9929..0b979758688 100644
--- 
a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
+++ 
b/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
@@ -432,8 +432,6 @@ static void manipulator_dial_invoke(
  *
  * \{ */
 
-#define ASSERT_TYPE_CHECK(mpr) BLI_assert(mpr->type->draw == 
manipulator_dial_draw)
-
 static void MANIPULATOR_WT_dial_3d(wmManipulatorType *wt)
 {
/* identifiers */
diff --git 
a/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c
 
b/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c
index 9e563f6133b..6943ae2c9f0 100644
--- 
a/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c
+++ 
b/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c
@@ -78,7 +78,6 @@ typedef struct GrabInteraction {
} output;
 } GrabInteraction;
 
-#define DIAL_WIDTH   1.0f
 #define DIAL_RESOLUTION 32
 
 /*  */
@@ -223,8 +222,6 @@ static void manipulator_grab_invoke(
  *
  * \{ */
 
-#define ASSERT_TYPE_CHECK(mpr) BLI_assert(mpr->type->draw == 
manipulator_grab_draw)
-
 static void MANIPULATOR_WT_grab_3d(wmManipulatorType *wt)
 {
/* identifiers */
diff --git a/source/blender/makesdna/intern/makesdna.c 
b/source/blender/makesdna/intern/makesdna.c
index 76be857b1af..182a026df94 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -56,9 +56,6 @@
 
 #include "../blenlib/BLI_sys_types.h" // for intptr_t support
 
-/* Allow includinsg DNA files for specially guarded namespaces */
-#define DNA_NAMESPACE
-
 #define SDNA_MAX_FILENAME_LENGTH 255
 
 
diff --git 
a/source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c
 
b/source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c
index 4a022c06613..fcf7b2c986f 100644
--- 
a/source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c
+++ 
b/source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c
@@ -45,9 +45,6 @@
 #include "wm_manipulator_wmapi.h"
 #include "wm_manipulator_intern.h"
 
-/* factor for precision tweaking */
-#define MANIPULATOR_PRECISION_FAC 0.05f
-
 /*  */
 
 /** \name Property Definition
@@ -274,4 +271,4 @@ void WM_manipulatortype_target_property_def(
BLI_addtail(>target_property_defs, mpt);
 }
 
-/** \} */
\ No newline at end of file
+/** \} */

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


[Bf-blender-cvs] [67df724a1fd] fluid-mantaflow: added particle data pointer getter to mantaflow files

2017-06-30 Thread Sebastián Barschkis
Commit: 67df724a1fdc72fb34a5b4159f33805fa20099b7
Author: Sebastián Barschkis
Date:   Sun Jun 25 17:37:04 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB67df724a1fdc72fb34a5b4159f33805fa20099b7

added particle data pointer getter to mantaflow files

===

M   intern/mantaflow/intern/manta_pp/omp/particle.cpp
M   intern/mantaflow/intern/manta_pp/omp/particle.h
M   intern/mantaflow/intern/manta_pp/omp/particle.h.reg
M   intern/mantaflow/intern/manta_pp/omp/particle.h.reg.cpp
M   intern/mantaflow/intern/manta_pp/tbb/particle.cpp
M   intern/mantaflow/intern/manta_pp/tbb/particle.h
M   intern/mantaflow/intern/manta_pp/tbb/particle.h.reg
M   intern/mantaflow/intern/manta_pp/tbb/particle.h.reg.cpp

===

diff --git a/intern/mantaflow/intern/manta_pp/omp/particle.cpp 
b/intern/mantaflow/intern/manta_pp/omp/particle.cpp
index 19a58bc24c3..58355f67cf4 100644
--- a/intern/mantaflow/intern/manta_pp/omp/particle.cpp
+++ b/intern/mantaflow/intern/manta_pp/omp/particle.cpp
@@ -239,6 +239,12 @@ void BasicParticleSystem::printParts(IndexInt start, 
IndexInt stop, bool printIn
debMsg( sstr.str() , 1 );
 }
 
+std::string BasicParticleSystem::getDataPointer() {
+   std::ostringstream out;
+   out << 
+   return out.str();
+}
+
 void BasicParticleSystem::readParticles(BasicParticleSystem* from) {
// re-allocate all data
this->resizeAll( from->size() ); 
@@ -390,7 +396,7 @@ template   struct knSetPdataConst : public 
KernelBase { knSetPdataConst
  {  
 #pragma omp for  
   for (IndexInt i = 0; i < _sz; i++) op(i,pdata,value);  }   } 
ParticleDataImpl& pdata; T value;   };
-#line 376 "particle.cpp"
+#line 382 "particle.cpp"
 
 
 
@@ -399,7 +405,7 @@ template   struct knPdataSet : public 
KernelBase { knPdataSet(
  {  
 #pragma omp for  
   for (IndexInt i = 0; i < _sz; i++) op(i,me,other);  }   } 
ParticleDataImpl& me; const ParticleDataImpl& other;   };
-#line 378 "particle.cpp"
+#line 384 "particle.cpp"
 
 
 template   struct knPdataAdd : public KernelBase { 
knPdataAdd(ParticleDataImpl& me, const ParticleDataImpl& other) :  
KernelBase(me.size()) ,me(me),other(other)   { runMessage(); run(); }   inline 
void op(IndexInt idx, ParticleDataImpl& me, const ParticleDataImpl& other 
)  { me[idx] += other[idx]; }inline ParticleDataImpl& getArg0() { return 
me; } typedef ParticleDataImpl type0;inline const ParticleDataImpl& 
getArg1() { return other; } typedef P [...]
@@ -407,7 +413,7 @@ template   struct knPdataAdd : public 
KernelBase { knPdataAdd(
  {  
 #pragma omp for  
   for (IndexInt i = 0; i < _sz; i++) op(i,me,other);  }   } 
ParticleDataImpl& me; const ParticleDataImpl& other;   };
-#line 379 "particle.cpp"
+#line 385 "particle.cpp"
 
 
 template   struct knPdataSub : public KernelBase { 
knPdataSub(ParticleDataImpl& me, const ParticleDataImpl& other) :  
KernelBase(me.size()) ,me(me),other(other)   { runMessage(); run(); }   inline 
void op(IndexInt idx, ParticleDataImpl& me, const ParticleDataImpl& other 
)  { me[idx] -= other[idx]; }inline ParticleDataImpl& getArg0() { return 
me; } typedef ParticleDataImpl type0;inline const ParticleDataImpl& 
getArg1() { return other; } typedef P [...]
@@ -415,7 +421,7 @@ template   struct knPdataSub : public 
KernelBase { knPdataSub(
  {  
 #pragma omp for  
   for (IndexInt i = 0; i < _sz; i++) op(i,me,other);  }   } 
ParticleDataImpl& me; const ParticleDataImpl& other;   };
-#line 380 "particle.cpp"
+#line 386 "particle.cpp"
 
 
 template   struct knPdataMult : public KernelBase { 
knPdataMult(ParticleDataImpl& me, const ParticleDataImpl& other) :  
KernelBase(me.size()) ,me(me),other(other)   { runMessage(); run(); }   inline 
void op(IndexInt idx, ParticleDataImpl& me, const ParticleDataImpl& other 
)  { me[idx] *= other[idx]; }inline ParticleDataImpl& getArg0() { return 
me; } typedef ParticleDataImpl type0;inline const ParticleDataImpl& 
getArg1() { return other; } typedef [...]
@@ -423,7 +429,7 @@ template   struct knPdataMult : public 
KernelBase { knPdataMul
  {  
 #pragma omp for  
   for (IndexInt i = 0; i < _sz; i++) op(i,me,other);  }   } 
ParticleDataImpl& me; const ParticleDataImpl& other;   };
-#line 381 "particle.cpp"
+#line 387 "particle.cpp"
 
 
 template   struct knPdataDiv : public KernelBase { 
knPdataDiv(ParticleDataImpl& me, const ParticleDataImpl& other) :  
KernelBase(me.size()) ,me(me),other(other)   { runMessage(); run(); }   inline 
void op(IndexInt idx, ParticleDataImpl& me, const ParticleDataImpl& other 
)  { me[idx] /= other[idx]; }inline ParticleDataImpl& getArg0() { return 
me; } typedef ParticleDataImpl type0;inline const ParticleDataImpl& 
getArg1() { return other; } typedef P [...]
@@ -431,7 +437,7 @@ template   struct knPdataDiv : public 
KernelBase { knPdataDiv(
  {  
 #pragma omp for  
   for (IndexInt i = 0; i < 

[Bf-blender-cvs] [273cf1f65c0] fluid-mantaflow: cleanup in FLUID class

2017-06-30 Thread Sebastián Barschkis
Commit: 273cf1f65c05b7a64602e09b74454c6feddaae70
Author: Sebastián Barschkis
Date:   Tue Jun 27 20:23:09 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB273cf1f65c05b7a64602e09b74454c6feddaae70

cleanup in FLUID class

===

M   intern/mantaflow/intern/FLUID.cpp

===

diff --git a/intern/mantaflow/intern/FLUID.cpp 
b/intern/mantaflow/intern/FLUID.cpp
index a2ad21c1a17..5a2b4838e57 100644
--- a/intern/mantaflow/intern/FLUID.cpp
+++ b/intern/mantaflow/intern/FLUID.cpp
@@ -644,6 +644,8 @@ std::string FLUID::getRealValue(const std::string& varName, 
 SmokeModifierData *
ss << smd->domain->particle_radius;
else if (varName == "PARTICLE_BAND_WIDTH")
ss << smd->domain->particle_band_width;
+   else if (varName == "SNDPARTICLE_VEL_THRESH")
+   ss << smd->domain->particle_velocity_threshold;
else if (varName == "GRAVITY_X")
ss << smd->domain->gravity[0];
else if (varName == "GRAVITY_Y")
@@ -846,15 +848,15 @@ void FLUID::exportLiquidData(SmokeModifierData *smd)
FLUID::saveLiquidDataHigh(parent_dir);
 }
 
-void* FLUID::getGridPointer(std::string gridName, std::string solverName)
+void* FLUID::getDataPointer(std::string varName, std::string parentName)
 {
-   if ((gridName == "") && (solverName == "")) return NULL;
+   if ((varName == "") && (parentName == "")) return NULL;
 
PyGILState_STATE gilstate = PyGILState_Ensure();
 
// Get pyobject that holds pointer address as string
PyObject* main = PyImport_AddModule("__main__");
-   PyObject* gridObject = PyObject_GetAttrString(main, gridName.c_str());
+   PyObject* gridObject = PyObject_GetAttrString(main, varName.c_str());
PyObject* func = PyObject_GetAttrString(gridObject, (char*) 
"getDataPointer");
PyObject* returnedValue = PyObject_CallObject(func, NULL);
PyObject* encoded = PyUnicode_AsUTF8String(returnedValue);
@@ -862,8 +864,8 @@ void* FLUID::getGridPointer(std::string gridName, 
std::string solverName)
// Convert string pointer to void pointer
std::string pointerString = PyBytes_AsString(encoded);
std::istringstream in(pointerString);
-   void *gridPointer = NULL;
-   in >> gridPointer;
+   void *dataPointer = NULL;
+   in >> dataPointer;

Py_DECREF(gridObject);
Py_DECREF(func);
@@ -871,7 +873,7 @@ void* FLUID::getGridPointer(std::string gridName, 
std::string solverName)
Py_DECREF(encoded);
 
PyGILState_Release(gilstate);
-   return gridPointer;
+   return dataPointer;
 }
 
 void FLUID::updateMeshData(const char* filename)
@@ -1053,46 +1055,46 @@ void FLUID::updatePointers()
std::string solver = "s" + id;
std::string solver_ext = "_" + solver;

-   mObstacle= (int*) getGridPointer("flags" + solver_ext,  solver);
-   mNumObstacle = (int*) getGridPointer("numObs" + solver_ext, solver);
+   mObstacle= (int*) getDataPointer("flags" + solver_ext,  solver);
+   mNumObstacle = (int*) getDataPointer("numObs" + solver_ext, solver);

-   mVelocityX = (float*) getGridPointer("x_vel" + solver_ext, solver);
-   mVelocityY = (float*) getGridPointer("y_vel" + solver_ext, solver);
-   mVelocityZ = (float*) getGridPointer("z_vel" + solver_ext, solver);
+   mVelocityX = (float*) getDataPointer("x_vel" + solver_ext, solver);
+   mVelocityY = (float*) getDataPointer("y_vel" + solver_ext, solver);
+   mVelocityZ = (float*) getDataPointer("z_vel" + solver_ext, solver);

-   mObVelocityX = (float*) getGridPointer("x_obvel" + solver_ext, solver);
-   mObVelocityY = (float*) getGridPointer("y_obvel" + solver_ext, solver);
-   mObVelocityZ = (float*) getGridPointer("z_obvel" + solver_ext, solver);
+   mObVelocityX = (float*) getDataPointer("x_obvel" + solver_ext, solver);
+   mObVelocityY = (float*) getDataPointer("y_obvel" + solver_ext, solver);
+   mObVelocityZ = (float*) getDataPointer("z_obvel" + solver_ext, solver);

-   mForceX= (float*) getGridPointer("x_force" + solver_ext, solver);
-   mForceY= (float*) getGridPointer("y_force" + solver_ext, solver);
-   mForceZ= (float*) getGridPointer("z_force" + solver_ext, solver);
+   mForceX= (float*) getDataPointer("x_force" + solver_ext, solver);
+   mForceY= (float*) getDataPointer("y_force" + solver_ext, solver);
+   mForceZ= (float*) getDataPointer("z_force" + solver_ext, solver);

-   mPhiObs = (float*) getGridPointer("phiObsIn" + solver_ext, solver);
+   mPhiObs = (float*) getDataPointer("phiObsIn" + solver_ext, solver);

// Liquid
if (mUsingLiquid) {
-   mPhiIn  = (float*) getGridPointer("phiIn" + solver_ext,  

[Bf-blender-cvs] [9b7d06b255b] fluid-mantaflow: added particle UI tab

2017-06-30 Thread Sebastián Barschkis
Commit: 9b7d06b255b4584c989eac6da5f46a8efcce3e38
Author: Sebastián Barschkis
Date:   Mon Jun 26 21:20:50 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB9b7d06b255b4584c989eac6da5f46a8efcce3e38

added particle UI tab

===

M   release/scripts/startup/bl_ui/properties_physics_smoke.py
M   source/blender/blenkernel/intern/smoke.c
M   source/blender/makesdna/DNA_smoke_types.h
M   source/blender/makesrna/intern/rna_smoke.c

===

diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py 
b/release/scripts/startup/bl_ui/properties_physics_smoke.py
index d04248cbebf..cefbfeb0c2a 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -278,7 +278,7 @@ class PHYSICS_PT_smoke_adaptive_domain(PhysicButtonsPanel, 
Panel):
 col.prop(domain, "adapt_threshold")
 
 
-class PHYSICS_PT_smoke_highres(PhysicButtonsPanel, Panel):
+class PHYSICS_PT_smoke_quality(PhysicButtonsPanel, Panel):
 bl_label = "Fluid Quality"
 COMPAT_ENGINES = {'BLENDER_RENDER'}
 
@@ -342,6 +342,36 @@ class PHYSICS_PT_smoke_highres(PhysicButtonsPanel, Panel):
 sub.prop(domain, "noise_pos_scale")
 sub.prop(domain, "noise_time_anim")
 
+class PHYSICS_PT_smoke_particles(PhysicButtonsPanel, Panel):
+bl_label = "Fluid Particles"
+COMPAT_ENGINES = {'BLENDER_RENDER'}
+
+@classmethod
+def poll(cls, context):
+md = context.smoke
+rd = context.scene.render
+return md and (md.smoke_type == 'DOMAIN') and (rd.engine in 
cls.COMPAT_ENGINES)
+
+def draw(self, context):
+layout = self.layout
+domain = context.smoke.domain_settings
+
+split = layout.split()
+
+col = split.column()
+col.enabled = not domain.point_cache.is_baked
+col.label(text="Type:")
+   #col.prop(domain, "use_flip_particles", text="FLIP")
+col.prop(domain, "use_drop_particles", text="Secondary")
+#col.prop(domain, "use_float_particles", text="Floats")
+#col.prop(domain, "use_tracer_particles", text="Tracer")
+
+col = split.column()
+col.label(text="")
+sub = col.column()
+sub.active = domain.use_drop_particles
+sub.prop(domain, "particle_velocity_threshold", text="Threshold")
+
 class PHYSICS_PT_smoke_groups(PhysicButtonsPanel, Panel):
 bl_label = "Fluid Groups"
 bl_options = {'DEFAULT_CLOSED'}
@@ -446,7 +476,7 @@ class OBJECT_OT_RunMantaButton(bpy.types.Operator):
 bpy.ops.manta.make_file()
 return{'FINISHED'}
 
-class PHYSICS_PT_smoke_manta_settings(PhysicButtonsPanel, Panel):
+class PHYSICS_PT_smoke_export_manta(PhysicButtonsPanel, Panel):
 bl_label = "Fluid Export"
 bl_options = {'DEFAULT_CLOSED'}
 
@@ -525,12 +555,13 @@ classes = (
 PHYSICS_PT_smoke,
 PHYSICS_PT_smoke_flow_advanced,
 PHYSICS_PT_smoke_adaptive_domain,
-PHYSICS_PT_smoke_highres,
+PHYSICS_PT_smoke_quality,
+PHYSICS_PT_smoke_particles,
 PHYSICS_PT_smoke_groups,
 PHYSICS_PT_smoke_cache,
 PHYSICS_PT_smoke_field_weights,
 OBJECT_OT_RunMantaButton,
-PHYSICS_PT_smoke_manta_settings,
+PHYSICS_PT_smoke_export_manta,
 PHYSICS_PT_smoke_display_settings,
 )
 
diff --git a/source/blender/blenkernel/intern/smoke.c 
b/source/blender/blenkernel/intern/smoke.c
index 196982d46d8..3bd22dd8420 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -542,6 +542,8 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
smd->domain->particle_number = 2;
smd->domain->particle_radius = 1.0f;
smd->domain->particle_band_width = 3.0f;
+   smd->domain->particle_velocity_threshold = 2.0f;
+   smd->domain->particle_type = 0;
 
/*mantaflow settings*/
smd->domain->manta_solver_res = 3;
@@ -666,6 +668,7 @@ void smokeModifier_copy(struct SmokeModifierData *smd, 
struct SmokeModifierData
tsmd->domain->particle_number = smd->domain->particle_number;
tsmd->domain->particle_radius = smd->domain->particle_radius;
tsmd->domain->particle_band_width = 
smd->domain->particle_band_width;
+   tsmd->domain->particle_velocity_threshold = 
smd->domain->particle_velocity_threshold;
 
tsmd->domain->manta_solver_res = smd->domain->manta_solver_res;
tsmd->domain->noise_pos_scale = smd->domain->noise_pos_scale;
diff --git a/source/blender/makesdna/DNA_smoke_types.h 
b/source/blender/makesdna/DNA_smoke_types.h
index 0405cf2d716..17899b0c359 100644
--- a/source/blender/makesdna/DNA_smoke_types.h
+++ b/source/blender/makesdna/DNA_smoke_types.h

[Bf-blender-cvs] [1bdf2152e11] fluid-mantaflow: added first version of secondary particle function to mantaflow files

2017-06-30 Thread Sebastián Barschkis
Commit: 1bdf2152e115dd670300ff63bfb3870cda310e8d
Author: Sebastián Barschkis
Date:   Sat Jun 24 19:55:49 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB1bdf2152e115dd670300ff63bfb3870cda310e8d

added first version of secondary particle function to mantaflow files

liquid script now also has additional particle system (for all secondary 
particles)

===

M   intern/mantaflow/intern/manta_pp/omp/plugin/flip.cpp
M   intern/mantaflow/intern/manta_pp/omp/registration.cpp
M   intern/mantaflow/intern/manta_pp/tbb/plugin/flip.cpp
M   intern/mantaflow/intern/manta_pp/tbb/registration.cpp
M   intern/mantaflow/intern/strings/liquid_script.h

===

diff --git a/intern/mantaflow/intern/manta_pp/omp/plugin/flip.cpp 
b/intern/mantaflow/intern/manta_pp/omp/plugin/flip.cpp
index c591c8dbc87..e4629d291c5 100644
--- a/intern/mantaflow/intern/manta_pp/omp/plugin/flip.cpp
+++ b/intern/mantaflow/intern/manta_pp/omp/plugin/flip.cpp
@@ -715,6 +715,74 @@ void combineGridVel( MACGrid& vel, Grid& weight, 
MACGrid& combineVel, Leve
knCombineVels(vel, weight, combineVel, phi, narrowBand, thresh);
 } static PyObject* _W_17 (PyObject* _self, PyObject* _linargs, PyObject* 
_kwds) { try { PbArgs _args(_linargs, _kwds); FluidSolver *parent = 
_args.obtainParent(); bool noTiming = _args.getOpt("notiming", -1, 0); 
pbPreparePlugin(parent, "combineGridVel" , !noTiming ); PyObject *_retval = 0; 
{ ArgLocker _lock; MACGrid& vel = *_args.getPtr("vel",0,&_lock); 
Grid& weight = *_args.getPtr("weight",1,&_lock); MACGrid& 
combineVel = *_args.getPtr("combi [...]
 
+void sampleSndParts(BasicParticleSystem& parts, FlagGrid& flags, MACGrid& vel, 
ParticleDataImpl& partVel, LevelsetGrid& phi, Real thresh, int 
minParticles, int maxParticles, Vec3 gravity) {
+
+   Real dt = flags.getParent()->getDt();
+   Vec3 grav = gravity * flags.getParent()->getDt() / flags.getDx();
+   Grid tmp( vel.getParent() );
+   RandomStream mRand(9832);
+
+   // Delete drop particles inside fluid. Then set new position to those 
that survived
+   for (IndexInt idx=0; idx<(int)parts.size(); idx++) {
+   if (parts.isActive(idx)) {
+   Vec3i p = toVec3i(parts.getPos(idx));
+   if (!tmp.isInBounds(p)) {
+   parts.kill(idx); // out of domain, remove
+   continue;
+   }
+   Real phiv = phi.getInterpolated( parts.getPos(idx) );
+   if( phiv < 0 ) { parts.kill(idx); continue; }
+
+   int num = tmp(p);
+   if (num > maxParticles) {
+   parts.kill(idx);
+   } else {
+   tmp(p) = num+1;
+   }
+   
+   // This particle is valid. Set its next position
+   const Vec3 p2 = parts.getPos(idx) + partVel[idx] * dt; 
// euler step
+   parts.setPos(idx, p2);
+   }
+   }
+
+   // Generate new drop particles
+   FOR_IJK_BND(phi, 0) {
+   if ( flags.isObstacle(i,j,k) ) continue;
+   if ( phi(i,j,k) > 0.3f && phi(i,j,k) < 0.7f ) continue; // Only 
generate particles at surface
+   if ( fabs(vel(i,j,k).x) < thresh || fabs(vel(i,j,k).y) < thresh 
|| fabs(vel(i,j,k).z) < thresh ) continue;
+
+   int cnt = tmp(i,j,k);
+   if (cnt >= minParticles) continue;
+
+   if ( flags.isFluid(i,j,k) || flags.isEmpty(i,j,k) ) {
+   Vec3 pos = Vec3(i,j,k);
+   const Vec3 pos2 = pos + vel(i,j,k) * dt; // next 
particle position
+   Real phiv = phi.getInterpolated(pos2);
+   
+   // Ensure that new particle is only added if its next 
position is valid
+   if (phiv > 0) {
+   parts.addBuffered(pos + mRand.getVec3());
+   }
+   }
+   }
+   parts.doCompress();
+   parts.insertBufferedParticles();
+
+   // Update forces: gravity and initial particle velocity
+   for (IndexInt idx=0; idx<(int)parts.size(); idx++) {
+   if (parts.isActive(idx)) {
+
+   // Initial velocity (only for new particles)
+   if (parts.getStatus(idx) & ParticleBase::PNEW) {
+   partVel[idx] = vel.getInterpolated( 
parts[idx].pos );
+   }
+
+   partVel[idx] += grav;
+   }
+   }
+} static PyObject* _W_18 (PyObject* _self, PyObject* _linargs, PyObject* 
_kwds) { try { PbArgs _args(_linargs, _kwds); FluidSolver *parent = 
_args.obtainParent(); bool 

[Bf-blender-cvs] [a9992eaaabe] fluid-mantaflow: first support for ptcache files for liquids

2017-06-30 Thread Sebastián Barschkis
Commit: a9992eaaabec8441cbf2a73fc64b03c3427460ce
Author: Sebastián Barschkis
Date:   Fri Jun 30 23:17:45 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rBa9992eaaabec8441cbf2a73fc64b03c3427460ce

first support for ptcache files for liquids

===

M   intern/mantaflow/extern/manta_fluid_API.h
M   intern/mantaflow/intern/FLUID.cpp
M   intern/mantaflow/intern/FLUID.h
M   intern/mantaflow/intern/manta_fluid_API.cpp
M   source/blender/blenkernel/intern/pointcache.c
M   source/blender/blenkernel/intern/smoke.c
M   source/blender/makesrna/intern/rna_smoke.c

===

diff --git a/intern/mantaflow/extern/manta_fluid_API.h 
b/intern/mantaflow/extern/manta_fluid_API.h
index ed76fbee91a..96ef02c9b0d 100644
--- a/intern/mantaflow/extern/manta_fluid_API.h
+++ b/intern/mantaflow/extern/manta_fluid_API.h
@@ -44,7 +44,7 @@ void smoke_manta_export(struct FLUID* smoke, struct 
SmokeModifierData *smd);
 void smoke_step(struct FLUID *smoke, int framenr);
 void smoke_dissolve(struct FLUID *smoke, int speed, int log);
 void smoke_dissolve_wavelet(struct FLUID *smoke, int speed, int log);
-void smoke_export(struct FLUID *smoke, float *dt, float *dx, float **dens, 
float **react, float **flame, float **fuel, float **heat, float **vx, float 
**vy, float **vz, float **r, float **g, float **b, int **obstacles);
+void smoke_export(struct FLUID *smoke, float *dt, float *dx, float **dens, 
float **react, float **flame, float **fuel, float **heat, float **vx, float 
**vy, float **vz, float **r, float **g, float **b, int **obstacles, float 
**phi, float **pp, float **pvel, int *numParts);
 void smoke_turbulence_export(struct FLUID *smoke, float **dens, float **react, 
float **flame, float **fuel, float **r, float **g, float **b , float **tcu, 
float **tcv, float **tcw, float **tcu2, float **tcv2, float **tcw2);
 float *smoke_get_density(struct FLUID *smoke);
 float *smoke_get_fuel(struct FLUID *smoke);
@@ -116,12 +116,15 @@ float liquid_get_particle_position_z_at(struct FLUID 
*liquid, int i);
 float liquid_get_particle_velocity_x_at(struct FLUID *liquid, int i);
 float liquid_get_particle_velocity_y_at(struct FLUID *liquid, int i);
 float liquid_get_particle_velocity_z_at(struct FLUID *liquid, int i);
+float *liquid_get_particle_data(struct FLUID *liquid);
+float *liquid_get_particle_velocity(struct FLUID *liquid);
 void liquid_update_mesh_data(struct FLUID *liquid, char *filename);
-void liquid_update_particle_data(struct FLUID *liquid, char* filename);
 void liquid_save_mesh_high(struct FLUID *liquid, char *filename);
 void liquid_save_data_high(struct FLUID *liquid, char *pathname);
 void liquid_load_data_high(struct FLUID *liquid, char *pathname);
 void liquid_manta_export(struct FLUID* smoke, struct SmokeModifierData *smd);
+void liquid_set_particle_data(struct FLUID* liquid, float* buffer, int 
numParts);
+void liquid_set_particle_velocity(struct FLUID* liquid, float* buffer, int 
numParts);
 
 int *fluid_get_num_obstacle(struct FLUID *fluid);
 float *fluid_get_inflow(struct FLUID *fluid);
diff --git a/intern/mantaflow/intern/FLUID.cpp 
b/intern/mantaflow/intern/FLUID.cpp
index 5a2b4838e57..8a9c5503f7c 100644
--- a/intern/mantaflow/intern/FLUID.cpp
+++ b/intern/mantaflow/intern/FLUID.cpp
@@ -117,16 +117,15 @@ FLUID::FLUID(int *res, SmokeModifierData *smd) : 
mCurrentID(++solverID)
mPhiIn  = NULL;
mPhiObs = NULL;
mPhiOut = NULL;
+   mPhi= NULL;
 
mNumVertices  = 0;
mNumNormals   = 0;
mNumTriangles = 0;
 
// Particles
-   mNumParticles = 0;
-   mParticleDimX = 0;
-   mParticleDimY = 0;
-   mParticleDimZ = 0;
+   mParticleData  = NULL;
+   mParticleVelocity  = NULL;
 
// Only start Mantaflow once. No need to start whenever new FLUID 
objected is allocated
if (!mantaInitialized)
@@ -475,6 +474,10 @@ FLUID::~FLUID()
mPhiIn  = NULL;
mPhiObs = NULL;
mPhiOut = NULL;
+   mPhi= NULL;
+
+   mParticleData  = NULL;
+   mParticleVelocity  = NULL;
 
// Reset flags
mUsingHeat= false;
@@ -952,99 +955,99 @@ void FLUID::updateMeshData(const char* filename)
gzclose(gzf);
 }
 
-void FLUID::updateParticleData(const char* filename)
-{
-   gzFile gzf;
-   float fbuffer[3];
-   int ibuffer[4];
-
-   gzf = (gzFile) BLI_gzopen(filename, "rb1"); // do some compression
-   if (!gzf)
-   std::cout << "updateParticleData: unable to open file" << 
std::endl;
-
-   char ID[5] = {0,0,0,0,0};
-   gzread(gzf, ID, 4);
-
-   if (!strcmp(ID, "PB01")) {
-   std::cout << "particle uni file format v01 not supported 
anymore" << std::endl;
-   return;
-   }
-
-   // pdata uni header
-   const int STR_LEN_PDATA = 256;

[Bf-blender-cvs] [29553c06845] fluid-mantaflow: replaced particle dim getter with domain dim getter

2017-06-30 Thread Sebastián Barschkis
Commit: 29553c06845728cc5fe5ddd948add25f07ec77aa
Author: Sebastián Barschkis
Date:   Mon Jun 26 23:46:11 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB29553c06845728cc5fe5ddd948add25f07ec77aa

replaced particle dim getter with domain dim getter

===

M   intern/mantaflow/extern/manta_fluid_API.h
M   intern/mantaflow/intern/manta_fluid_API.cpp
M   source/blender/blenkernel/intern/particle_system.c

===

diff --git a/intern/mantaflow/extern/manta_fluid_API.h 
b/intern/mantaflow/extern/manta_fluid_API.h
index bdbd21a774a..ed76fbee91a 100644
--- a/intern/mantaflow/extern/manta_fluid_API.h
+++ b/intern/mantaflow/extern/manta_fluid_API.h
@@ -109,9 +109,6 @@ float liquid_get_triangle_x_at(struct FLUID *liquid, int i);
 float liquid_get_triangle_y_at(struct FLUID *liquid, int i);
 float liquid_get_triangle_z_at(struct FLUID *liquid, int i);
 int liquid_get_num_particles(struct FLUID *liquid);
-int liquid_get_particle_dim_x(struct FLUID *liquid);
-int liquid_get_particle_dim_y(struct FLUID *liquid);
-int liquid_get_particle_dim_z(struct FLUID *liquid);
 int liquid_get_particle_flag_at(struct FLUID *liquid, int i);
 float liquid_get_particle_position_x_at(struct FLUID *liquid, int i);
 float liquid_get_particle_position_y_at(struct FLUID *liquid, int i);
@@ -128,6 +125,9 @@ void liquid_manta_export(struct FLUID* smoke, struct 
SmokeModifierData *smd);
 
 int *fluid_get_num_obstacle(struct FLUID *fluid);
 float *fluid_get_inflow(struct FLUID *fluid);
+int fluid_get_res_x(struct FLUID *fluid);
+int fluid_get_res_y(struct FLUID *fluid);
+int fluid_get_res_z(struct FLUID *fluid);
 
 #ifdef __cplusplus
 }
diff --git a/intern/mantaflow/intern/manta_fluid_API.cpp 
b/intern/mantaflow/intern/manta_fluid_API.cpp
index a16e43280ed..5e9da740cf8 100644
--- a/intern/mantaflow/intern/manta_fluid_API.cpp
+++ b/intern/mantaflow/intern/manta_fluid_API.cpp
@@ -614,21 +614,6 @@ extern "C" int liquid_get_num_particles(FLUID *liquid)
return liquid->getNumParticles();
 }
 
-extern "C" int liquid_get_particle_dim_x(FLUID *liquid)
-{
-   return liquid->getParticleDimX();
-}
-
-extern "C" int liquid_get_particle_dim_y(FLUID *liquid)
-{
-   return liquid->getParticleDimY();
-}
-
-extern "C" int liquid_get_particle_dim_z(FLUID *liquid)
-{
-   return liquid->getParticleDimZ();
-}
-
 extern "C" int liquid_get_particle_flag_at(FLUID *liquid, int i)
 {
return liquid->getParticleFlagAt(i);
@@ -685,3 +670,18 @@ extern "C" float *fluid_get_inflow(FLUID* fluid)
 {
return fluid->getInflow();
 }
+
+extern "C" int fluid_get_res_x(FLUID* fluid)
+{
+   return fluid->getResX();
+}
+
+extern "C" int fluid_get_res_y(FLUID* fluid)
+{
+   return fluid->getResY();
+}
+
+extern "C" int fluid_get_res_z(FLUID* fluid)
+{
+   return fluid->getResZ();
+}
diff --git a/source/blender/blenkernel/intern/particle_system.c 
b/source/blender/blenkernel/intern/particle_system.c
index 48a5dd69c78..b056bca9535 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -3807,14 +3807,14 @@ static void particles_manta_step(ParticleSimulationData 
*sim, int UNUSED(cfra),
pa->state.co[2] = 
liquid_get_particle_position_z_at(sds->fluid, p);
 
// translate particles coordinates to  
origin (0,0,0)
-   pa->state.co[0] -= 
liquid_get_particle_dim_x(sds->fluid) / 2.0f;
-   pa->state.co[1] -= 
liquid_get_particle_dim_y(sds->fluid) / 2.0f;
-   pa->state.co[2] -= 
liquid_get_particle_dim_z(sds->fluid) / 2.0f;
+   pa->state.co[0] -= 
fluid_get_res_x(sds->fluid) / 2.0f;
+   pa->state.co[1] -= 
fluid_get_res_y(sds->fluid) / 2.0f;
+   pa->state.co[2] -= 
fluid_get_res_z(sds->fluid) / 2.0f;
 
// scale down
-   pa->state.co[0] *= 1.0f / 
liquid_get_particle_dim_x(sds->fluid);
-   pa->state.co[1] *= 1.0f / 
liquid_get_particle_dim_y(sds->fluid);
-   pa->state.co[2] *= 1.0f / 
liquid_get_particle_dim_z(sds->fluid);
+   pa->state.co[0] *= 1.0f / 
fluid_get_res_x(sds->fluid);
+   pa->state.co[1] *= 1.0f / 
fluid_get_res_y(sds->fluid);
+   pa->state.co[2] *= 1.0f / 
fluid_get_res_z(sds->fluid);
 
// scale up
mul_v3_fl(pa->state.co, sds->scale);
@@ -3841,9 +3841,9 @@ static void 

[Bf-blender-cvs] [60600dd36e6] fluid-mantaflow: updated manta obstacle velocity

2017-06-30 Thread Sebastián Barschkis
Commit: 60600dd36e69bf02626ea9c08f7600d0f9dd1402
Author: Sebastián Barschkis
Date:   Sat Jun 24 18:52:41 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB60600dd36e69bf02626ea9c08f7600d0f9dd1402

updated manta obstacle velocity

some more improvements to obstacle velocities in mantaflow. now manta only 
accepts mac grids. any resampling from vec3 to mac needs to be done before 
calling wall function.

===

M   intern/mantaflow/intern/manta_pp/omp/plugin/extforces.cpp
M   intern/mantaflow/intern/manta_pp/tbb/plugin/extforces.cpp
M   intern/mantaflow/intern/strings/liquid_script.h
M   intern/mantaflow/intern/strings/smoke_script.h

===

diff --git a/intern/mantaflow/intern/manta_pp/omp/plugin/extforces.cpp 
b/intern/mantaflow/intern/manta_pp/omp/plugin/extforces.cpp
index ad96422d1cc..7c1d71e5169 100644
--- a/intern/mantaflow/intern/manta_pp/omp/plugin/extforces.cpp
+++ b/intern/mantaflow/intern/manta_pp/omp/plugin/extforces.cpp
@@ -224,22 +224,17 @@ void setInflowBcs(MACGrid& vel, string dir, Vec3 value) {
 // set obstacle boundary conditions
 
 //! set no-stick wall boundary condition between ob/fl and ob/ob cells
- struct KnSetWallBcs : public KernelBase { KnSetWallBcs(FlagGrid& flags, 
MACGrid& vel, Grid* obvel) :  KernelBase(,0) 
,flags(flags),vel(vel),obvel(obvel)   { runMessage(); run(); }  inline void 
op(int i, int j, int k, FlagGrid& flags, MACGrid& vel, Grid* obvel )  {
+ struct KnSetWallBcs : public KernelBase { KnSetWallBcs(FlagGrid& flags, 
MACGrid& vel, MACGrid* obvel) :  KernelBase(,0) 
,flags(flags),vel(vel),obvel(obvel)   { runMessage(); run(); }  inline void 
op(int i, int j, int k, FlagGrid& flags, MACGrid& vel, MACGrid* obvel )  {
 
bool curFluid = flags.isFluid(i,j,k);
bool curObs   = flags.isObstacle(i,j,k);
Vec3 bcsVel(0.,0.,0.);
if (!curFluid && !curObs) return;
 
-   // optional obstacle velocities. interpolate centered obvels or just 
copy obvels (for MAC grids)
if (obvel) {
-   bool isMACObvel = obvel->getType() & GridBase::TypeMAC;
-   if (i>0 && (*obvel)(i,j,k).x)
-   bcsVel.x = (isMACObvel || !(*obvel)(i-1,j,k).x) ? 
(*obvel)(i,j,k).x : 0.5*((*obvel)(i-1,j,k).x + (*obvel)(i,j,k).x);
-   if (j>0 && (*obvel)(i,j,k).y)
-   bcsVel.y = (isMACObvel || !(*obvel)(i,j-1,k).y) ? 
(*obvel)(i,j,k).y : 0.5*((*obvel)(i,j-1,k).y + (*obvel)(i,j,k).y);
-   if (k>0 && (*obvel)(i,j,k).z)
-   bcsVel.z = (isMACObvel || !(*obvel)(i,j,k-1).z) ? 
(*obvel)(i,j,k).z : 0.5*((*obvel)(i,j,k-1).z + (*obvel)(i,j,k).z);
+   bcsVel.x = (*obvel)(i,j,k).x;
+   bcsVel.y = (*obvel)(i,j,k).y;
+   if(!(*obvel).is3D()) bcsVel.z = (*obvel)(i,j,k).z;
}
 
// we use i>0 instead of bnd=1 to check outer wall
@@ -260,7 +255,7 @@ void setInflowBcs(MACGrid& vel, string dir, Vec3 value) {
if (vel.is3D() && ((k>0 && flags.isStick(i,j,k-1)) || 
(k 1) { 
+}   inline FlagGrid& getArg0() { return flags; } typedef FlagGrid type0;inline 
MACGrid& getArg1() { return vel; } typedef MACGrid type1;inline MACGrid* 
getArg2() { return obvel; } typedef MACGrid type2; void runMessage() { 
debMsg("Executing kernel KnSetWallBcs ", 3); debMsg("Kernel range" <<  " x "<<  
maxX  << " y "<< maxY  << " z "<< minZ<<" - "<< maxZ  << " "   , 4); }; void 
run() {  const int _maxX = maxX; const int _maxY = maxY; if (maxZ > 1) { 
 #pragma omp parallel 
  {  
 #pragma omp for  
@@ -268,7 +263,7 @@ void setInflowBcs(MACGrid& vel, string dir, Vec3 value) {
 #pragma omp parallel 
  {  
 #pragma omp for  
-  for (int j=0; j < _maxY; j++) for (int i=0; i < _maxX; i++) 
op(i,j,k,flags,vel,obvel);  } }  } FlagGrid& flags; MACGrid& vel; Grid* 
obvel;   };
+  for (int j=0; j < _maxY; j++) for (int i=0; i < _maxX; i++) 
op(i,j,k,flags,vel,obvel);  } }  } FlagGrid& flags; MACGrid& vel; MACGrid* 
obvel;   };
 #line 171 "plugin/extforces.cpp"
 
 
@@ -276,11 +271,11 @@ void setInflowBcs(MACGrid& vel, string dir, Vec3 value) {
 //! set wall BCs for fill fraction mode, note - only needs obstacle SDF
 
 
- struct KnSetWallBcsFrac : public KernelBase { KnSetWallBcsFrac(FlagGrid& 
flags, MACGrid& vel, MACGrid& velTarget, Grid* phiObs, const int 

[Bf-blender-cvs] [03742faf431] fluid-mantaflow: added guards in pointcache read/write functions

2017-06-30 Thread Sebastián Barschkis
Commit: 03742faf431e39887acd42dfd46de99ae49e6bb3
Author: Sebastián Barschkis
Date:   Thu Jun 29 14:42:33 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB03742faf431e39887acd42dfd46de99ae49e6bb3

added guards in pointcache read/write functions

if we want to use ptcache format for liquids, first make sure not to access 
smoke fields.

===

M   source/blender/blenkernel/intern/pointcache.c

===

diff --git a/source/blender/blenkernel/intern/pointcache.c 
b/source/blender/blenkernel/intern/pointcache.c
index 58da1525c44..9ba1dace233 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -608,17 +608,19 @@ static int ptcache_smoke_write(PTCacheFile *pf, void 
*smoke_v)
 
smoke_export(sds->fluid, , , , , , 
, , , , , , , , );
 
-   ptcache_file_compressed_write(pf, (unsigned char *)sds->shadow, 
in_len, out, mode);
-   ptcache_file_compressed_write(pf, (unsigned char *)dens, 
in_len, out, mode);
-   if (fluid_fields & SM_ACTIVE_HEAT) {
+   if (dens) {
+   ptcache_file_compressed_write(pf, (unsigned char 
*)sds->shadow, in_len, out, mode);
+   ptcache_file_compressed_write(pf, (unsigned char 
*)dens, in_len, out, mode);
+   }
+   if (heat && fluid_fields & SM_ACTIVE_HEAT) {
ptcache_file_compressed_write(pf, (unsigned char 
*)heat, in_len, out, mode);
}
-   if (fluid_fields & SM_ACTIVE_FIRE) {
+   if (flame && fluid_fields & SM_ACTIVE_FIRE) {
ptcache_file_compressed_write(pf, (unsigned char 
*)flame, in_len, out, mode);
ptcache_file_compressed_write(pf, (unsigned char 
*)fuel, in_len, out, mode);
ptcache_file_compressed_write(pf, (unsigned char 
*)react, in_len, out, mode);
}
-   if (fluid_fields & SM_ACTIVE_COLORS) {
+   if (r && fluid_fields & SM_ACTIVE_COLORS) {
ptcache_file_compressed_write(pf, (unsigned char *)r, 
in_len, out, mode);
ptcache_file_compressed_write(pf, (unsigned char *)g, 
in_len, out, mode);
ptcache_file_compressed_write(pf, (unsigned char *)b, 
in_len, out, mode);
@@ -658,16 +660,17 @@ static int ptcache_smoke_write(PTCacheFile *pf, void 
*smoke_v)
smoke_turbulence_get_res(sds->fluid, res_big_array);
 
res_big = res_big_array[0]*res_big_array[1]*res_big_array[2];
+   in_len_big = sizeof(float) * (unsigned int)res_big;
+   out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len_big), 
"pointcache_lzo_buffer");
//mode =  res_big >= 100 ? 2 : 1;
mode = 1;   // light
if (sds->cache_high_comp == SM_CACHE_HEAVY) mode=2; // heavy
 
-   in_len_big = sizeof(float) * (unsigned int)res_big;
-
smoke_turbulence_export(sds->fluid, , , , 
, , , , , , , , , );
 
-   out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len_big), 
"pointcache_lzo_buffer");
-   ptcache_file_compressed_write(pf, (unsigned char *)dens, 
in_len_big, out, mode);
+   if (dens) {
+   ptcache_file_compressed_write(pf, (unsigned char 
*)dens, in_len_big, out, mode);
+   }
if (fluid_fields & SM_ACTIVE_FIRE) {
ptcache_file_compressed_write(pf, (unsigned char 
*)flame, in_len_big, out, mode);
ptcache_file_compressed_write(pf, (unsigned char 
*)fuel, in_len_big, out, mode);
@@ -681,13 +684,16 @@ static int ptcache_smoke_write(PTCacheFile *pf, void 
*smoke_v)
MEM_freeN(out);
 
out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len), 
"pointcache_lzo_buffer");
-   ptcache_file_compressed_write(pf, (unsigned char *)tcu, in_len, 
out, mode);
-   ptcache_file_compressed_write(pf, (unsigned char *)tcv, in_len, 
out, mode);
-   ptcache_file_compressed_write(pf, (unsigned char *)tcw, in_len, 
out, mode);
-   
-   ptcache_file_compressed_write(pf, (unsigned char *)tcu2, 
in_len, out, mode);
-   ptcache_file_compressed_write(pf, (unsigned char *)tcv2, 
in_len, out, mode);
-   ptcache_file_compressed_write(pf, (unsigned char *)tcw2, 
in_len, out, mode);
+   if (tcu) {
+   ptcache_file_compressed_write(pf, (unsigned char *)tcu, 
in_len, out, mode);
+   ptcache_file_compressed_write(pf, (unsigned char *)tcv, 
in_len, out, mode);
+   ptcache_file_compressed_write(pf, (unsigned char *)tcw, 
in_len, out, mode);
+   

[Bf-blender-cvs] [672caef66fa] fluid-mantaflow: big cleanup for manta directives

2017-06-30 Thread Sebastián Barschkis
Commit: 672caef66faefbb615ceb7b442b502c73f50ae5e
Author: Sebastián Barschkis
Date:   Sat Jun 24 16:22:58 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB672caef66faefbb615ceb7b442b502c73f50ae5e

big cleanup for manta directives

very early in the project these directives where set to preserve the 
functionality of the original smoke code. keeping up this dual compatibility 
would be an overkill for this branch.

===

M   source/blender/blenkernel/BKE_smoke.h
M   source/blender/blenkernel/intern/particle_system.c
M   source/blender/blenkernel/intern/pointcache.c
M   source/blender/blenkernel/intern/smoke.c
M   source/blender/editors/physics/CMakeLists.txt
M   source/blender/editors/physics/physics_fluid.c
M   source/blender/editors/space_view3d/drawvolume.c
M   source/blender/gpu/intern/gpu_draw.c
M   source/blender/makesrna/intern/rna_smoke.c
M   source/blender/render/intern/source/voxeldata.c

===

diff --git a/source/blender/blenkernel/BKE_smoke.h 
b/source/blender/blenkernel/BKE_smoke.h
index 20366f00df6..b4de2f21eb8 100644
--- a/source/blender/blenkernel/BKE_smoke.h
+++ b/source/blender/blenkernel/BKE_smoke.h
@@ -41,7 +41,6 @@ void smoke_reallocate_fluid(struct SmokeDomainSettings *sds, 
float dx, int res[3
 void smoke_reallocate_highres_fluid(struct SmokeDomainSettings *sds, float dx, 
int res[3], int free_old);
 void smokeModifier_free(struct SmokeModifierData *smd);
 void smokeModifier_reset(struct SmokeModifierData *smd);
-void smokeModifier_reset_turbulence(struct SmokeModifierData *smd);
 void smokeModifier_createType(struct SmokeModifierData *smd);
 void smokeModifier_copy(struct SmokeModifierData *smd, struct 
SmokeModifierData *tsmd);
 
diff --git a/source/blender/blenkernel/intern/particle_system.c 
b/source/blender/blenkernel/intern/particle_system.c
index af2e312f48c..48a5dd69c78 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -105,8 +105,8 @@
 
 /* manta sim particle import */
 #ifdef WITH_MANTA
-   #include "DNA_smoke_types.h"
-   #include "manta_fluid_API.h"
+#  include "DNA_smoke_types.h"
+#  include "manta_fluid_API.h"
 #endif // WITH_MANTA
 
 static ThreadRWMutex psys_bvhtree_rwlock = BLI_RWLOCK_INITIALIZER;
diff --git a/source/blender/blenkernel/intern/pointcache.c 
b/source/blender/blenkernel/intern/pointcache.c
index 8e80b269a7c..58da1525c44 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -77,10 +77,8 @@
 
 /* both in intern */
 #ifdef WITH_SMOKE
-#ifndef WITH_MANTA
-   #include "smoke_API.h"
-#else
-   #include "manta_fluid_API.h"
+#ifdef WITH_MANTA
+#  include "manta_fluid_API.h"
 #endif
 #endif
 
@@ -647,11 +645,7 @@ static int ptcache_smoke_write(PTCacheFile *pf, void 
*smoke_v)
ret = 1;
}
 
-#ifndef WITH_MANTA
-   if (sds->wt) {
-#else
if (sds->fluid && sds->flags & MOD_SMOKE_HIGHRES) {
-#endif
int res_big_array[3];
int res_big;
int res = sds->res[0]*sds->res[1]*sds->res[2];
@@ -661,11 +655,8 @@ static int ptcache_smoke_write(PTCacheFile *pf, void 
*smoke_v)
unsigned char *out;
int mode;
 
-#ifndef WITH_MANTA
-   smoke_turbulence_get_res(sds->wt, res_big_array);
-#else
smoke_turbulence_get_res(sds->fluid, res_big_array);
-#endif
+
res_big = res_big_array[0]*res_big_array[1]*res_big_array[2];
//mode =  res_big >= 100 ? 2 : 1;
mode = 1;   // light
@@ -673,11 +664,7 @@ static int ptcache_smoke_write(PTCacheFile *pf, void 
*smoke_v)
 
in_len_big = sizeof(float) * (unsigned int)res_big;
 
-#ifndef WITH_MANTA
-   smoke_turbulence_export(sds->wt, , , , , 
, , , , , );
-#else
smoke_turbulence_export(sds->fluid, , , , 
, , , , , , , , , );
-#endif
 
out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len_big), 
"pointcache_lzo_buffer");
ptcache_file_compressed_write(pf, (unsigned char *)dens, 
in_len_big, out, mode);
@@ -698,11 +685,10 @@ static int ptcache_smoke_write(PTCacheFile *pf, void 
*smoke_v)
ptcache_file_compressed_write(pf, (unsigned char *)tcv, in_len, 
out, mode);
ptcache_file_compressed_write(pf, (unsigned char *)tcw, in_len, 
out, mode);

-#ifdef WITH_MANTA
ptcache_file_compressed_write(pf, (unsigned char *)tcu2, 
in_len, out, mode);
ptcache_file_compressed_write(pf, (unsigned char *)tcv2, 
in_len, out, mode);
ptcache_file_compressed_write(pf, (unsigned char *)tcw2, 
in_len, out, mode);
-#endif
+
MEM_freeN(out);

   

[Bf-blender-cvs] [927694fd137] greasepencil-object: Changes in previous fix for T51942

2017-06-30 Thread Antonio Vazquez
Commit: 927694fd137e250feec9207c912a5b83c3373dfa
Author: Antonio Vazquez
Date:   Fri Jun 30 20:49:07 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB927694fd137e250feec9207c912a5b83c3373dfa

Changes in previous fix for T51942

The previous commit broken the stroke color update

===

M   source/blender/makesrna/intern/rna_palette.c

===

diff --git a/source/blender/makesrna/intern/rna_palette.c 
b/source/blender/makesrna/intern/rna_palette.c
index f326cd71b03..5aa797e671a 100644
--- a/source/blender/makesrna/intern/rna_palette.c
+++ b/source/blender/makesrna/intern/rna_palette.c
@@ -55,7 +55,7 @@
 static void rna_GPencil_update(Main *UNUSED(bmain), Scene *UNUSED(scene), 
PointerRNA *UNUSED(ptr))
 {
BKE_gpencil_batch_cache_alldirty();
-   WM_main_add_notifier(NC_SCREEN | NC_GPENCIL | NA_EDITED, NULL);
+   WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
 }
 
 static PaletteColor *rna_Palette_color_new(Palette *palette)
@@ -233,7 +233,7 @@ static void rna_def_palettecolor(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "rgb");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Color", "");
-   RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS | ND_DATA | 
NC_GPENCIL, "rna_GPencil_update");
+   RNA_def_property_update(prop, NC_SCREEN | NC_SCENE | ND_TOOLSETTINGS | 
ND_DATA | NC_GPENCIL, "rna_GPencil_update");
 
prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.0, 1.0);
@@ -267,7 +267,7 @@ static void rna_def_palettecolor(BlenderRNA *brna)
RNA_def_property_array(prop, 3);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Fill Color", "Color for filling region 
bounded by each stroke");
-   RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS | ND_DATA | 
NC_GPENCIL, "rna_GPencil_update");
+   RNA_def_property_update(prop, NC_SCREEN | NC_SCENE | ND_TOOLSETTINGS | 
ND_DATA | NC_GPENCIL, "rna_GPencil_update");
 
/* Fill alpha */
prop = RNA_def_property(srna, "fill_alpha", PROP_FLOAT, PROP_NONE);

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


[Bf-blender-cvs] [8d4072f434f] greasepencil-object: Merge branch 'blender2.8' into greasepencil-object

2017-06-30 Thread Antonio Vazquez
Commit: 8d4072f434f29819d755cee02019656cd5032361
Author: Antonio Vazquez
Date:   Fri Jun 30 20:14:29 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB8d4072f434f29819d755cee02019656cd5032361

Merge branch 'blender2.8' into greasepencil-object

===



===



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


[Bf-blender-cvs] [d0c17ef893f] greasepencil-object: Fix T51942: Color not updated in UI panel

2017-06-30 Thread Antonio Vazquez
Commit: d0c17ef893fed7cb3186dbb957b1e0ba806a4630
Author: Antonio Vazquez
Date:   Fri Jun 30 20:02:44 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rBd0c17ef893fed7cb3186dbb957b1e0ba806a4630

Fix T51942: Color not updated in UI panel

When update the color in the panel, the color box was not updated after release 
control.

===

M   source/blender/makesrna/intern/rna_palette.c

===

diff --git a/source/blender/makesrna/intern/rna_palette.c 
b/source/blender/makesrna/intern/rna_palette.c
index 928bd43129b..f326cd71b03 100644
--- a/source/blender/makesrna/intern/rna_palette.c
+++ b/source/blender/makesrna/intern/rna_palette.c
@@ -55,7 +55,7 @@
 static void rna_GPencil_update(Main *UNUSED(bmain), Scene *UNUSED(scene), 
PointerRNA *UNUSED(ptr))
 {
BKE_gpencil_batch_cache_alldirty();
-   WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
+   WM_main_add_notifier(NC_SCREEN | NC_GPENCIL | NA_EDITED, NULL);
 }
 
 static PaletteColor *rna_Palette_color_new(Palette *palette)

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


[Bf-blender-cvs] [82835bcaad3] soc-2017-sculpting_improvements: Progress on generated shape. Lots of smaller bugfixes parts are partially bridged.

2017-06-30 Thread witt
Commit: 82835bcaad3f1277a693d771b29fdf4a130ffd73
Author: witt
Date:   Fri Jun 30 19:40:07 2017 +0200
Branches: soc-2017-sculpting_improvements
https://developer.blender.org/rB82835bcaad3f1277a693d771b29fdf4a130ffd73

Progress on generated shape. Lots of smaller bugfixes parts are partially 
bridged.

===

M   source/blender/editors/sculpt_paint/sculpt.c

===

diff --git a/source/blender/editors/sculpt_paint/sculpt.c 
b/source/blender/editors/sculpt_paint/sculpt.c
index ea0f027f8c3..b117d8c5725 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -5167,6 +5167,12 @@ static void bl_debug_draw_BB_add(BB *bb,const unsigned 
int col)
 }
 #endif
 
+typedef enum {
+   SIL_INIT = 0,
+   SIL_DRAWING = 1,
+   SIL_OP = 2
+} SilhouetteState;
+
 typedef struct SilhouetteData {
ARegion *ar;/* region that Silhouette started drawn in */
void *draw_handle;  /* for drawing preview loop */
@@ -5179,8 +5185,12 @@ typedef struct SilhouetteData {
float add_col[3];
float last_mouse_pos[2];
 
+   SilhouetteState state;
+
float depth;
+   float smoothness;
float anchor[3];
+   float z_vec[3];
 } SilhouetteData;
 
 typedef struct {
@@ -5233,14 +5243,14 @@ static SilhouetteStroke *silhouette_stroke_new(int 
max_verts)
 {
SilhouetteStroke *stroke = MEM_callocN(sizeof(SilhouetteStroke), 
"SilhouetteStroke");
stroke->points = 0;
-   stroke->points = 
MEM_callocN(sizeof(float)*2*max_verts,"SilhouetteStrokePoints");//TODO: Dynamic 
length
+   stroke->points = MEM_callocN(sizeof(float) * 3 * 
max_verts,"SilhouetteStrokePoints");//TODO: Dynamic length
stroke->totvert = 0;
stroke->max_verts = max_verts;
printf("Init silhouette Data\n");
return stroke;
 }
 
-static SilhouetteData *silhouette_data_new(bContext *C, wmOperator *UNUSED(op))
+static SilhouetteData *silhouette_data_new(bContext *C, wmOperator *op, bool 
rna_full)
 {
SilhouetteData *sil = MEM_callocN(sizeof(SilhouetteData), 
"SilhouetteData");
Object *obedit = CTX_data_edit_object(C);
@@ -5256,13 +5266,21 @@ static SilhouetteData *silhouette_data_new(bContext *C, 
wmOperator *UNUSED(op))
sil->add_col[1] = 0.39;
sil->add_col[2] = 0.39;
 
-   sil->depth = 1.5f;
+   sil->smoothness = RNA_float_get(op->ptr, "smoothness");
+   sil->depth = RNA_float_get(op->ptr, "depth");
+   if(rna_full){
+   RNA_float_get_array(op->ptr, "z_vec", sil->z_vec);
+   RNA_float_get_array(op->ptr, "anchor", sil->anchor);
+   RNA_float_get_array(op->ptr, "points", 
sil->current_stroke->points);
+   sil->current_stroke->totvert = RNA_int_get(op->ptr, "totvert");
+   }
 
 
/* assign the drawing handle for drawing preview line... */
sil->scene = scene;
sil->ob = obedit;
 
+   sil->state = SIL_INIT;
return sil;
 }
 
@@ -5277,14 +5295,29 @@ static void silhouette_data_free(struct wmOperator *op)
 }
 
 static void silhoute_stroke_point_to_3d(SilhouetteData *sil, int point, float 
r_v[3]){
-   ED_view3d_win_to_3d(sil->vc.v3d, sil->ar, sil->anchor, 
>current_stroke->points[point], r_v);
+   copy_v3_v3(r_v,>current_stroke->points[point]);
+   //ED_view3d_win_to_3d(sil->vc.v3d, sil->ar, sil->anchor, 
>current_stroke->points[point], r_v);
 }
 
-static void silhouette_stroke_add_point(SilhouetteStroke *stroke, float 
point[2])
+static void silhouette_stroke_add_3Dpoint(SilhouetteStroke *stroke, float 
point[3])
 {
if (stroke->totvert < stroke->max_verts) {
-   stroke->points[stroke->totvert*2] = point[0];
-   stroke->points[stroke->totvert*2+1] = point[1];
+   copy_v3_v3(>points[stroke->totvert * 3], point);
+   //ED_view3d_win_to_3d(sil->vc.v3d, sil->ar, sil->anchor, point, 
>current_stroke->points[stroke->totvert * 3]);
+   /*stroke->points[stroke->totvert * 3] = point[0];
+stroke->points[stroke->totvert*2+1] = point[1];*/
+   stroke->totvert ++;
+   } else {
+   printf("Stroke reached maximum vert count.\n");
+   }
+}
+
+static void silhouette_stroke_add_point(SilhouetteData *sil, SilhouetteStroke 
*stroke, float point[2])
+{
+   if (stroke->totvert < stroke->max_verts) {
+   ED_view3d_win_to_3d(sil->vc.v3d, sil->ar, sil->anchor, point, 
>current_stroke->points[stroke->totvert * 3]);
+   /*stroke->points[stroke->totvert * 3] = point[0];
+   stroke->points[stroke->totvert*2+1] = point[1];*/
stroke->totvert ++;
} else {
printf("Stroke reached maximum vert count.\n");
@@ -5297,6 +5330,7 @@ static void silhouette_set_ref_plane(const bContext *C, 
SilhouetteData 

[Bf-blender-cvs] [49a35033be6] blender2.8: Fix T51877: Deleting a scene uses freed memory

2017-06-30 Thread Dalai Felinto
Commit: 49a35033be60e58ed4910346bc29ffa1954b34ec
Author: Dalai Felinto
Date:   Fri Jun 30 18:59:29 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB49a35033be60e58ed4910346bc29ffa1954b34ec

Fix T51877: Deleting a scene uses freed memory

At the moment libblock_remap_data_preprocess is using
FOREACH_SCENE_OBJECT to iterate over all the objects of the scene and
unlink them.

However we were storing a reference to the Base of the removed object.
Anyways, the loop is now sanitized so that this crash no longer happens.

Also now we have an unittest for this.

===

M   source/blender/blenkernel/intern/collection.c
M   tests/python/render_layer/CMakeLists.txt
A   tests/python/render_layer/test_scene_delete.py

===

diff --git a/source/blender/blenkernel/intern/collection.c 
b/source/blender/blenkernel/intern/collection.c
index caaf482736b..38534f03123 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -565,7 +565,7 @@ void BKE_scene_collections_iterator_end(struct BLI_Iterator 
*iter)
 
 typedef struct SceneObjectsIteratorData {
GSet *visited;
-   LinkData *link;
+   LinkData *link_next;
BLI_Iterator scene_collection_iter;
 } SceneObjectsIteratorData;
 
@@ -609,10 +609,10 @@ static LinkData *object_base_unique(GSet *gs, LinkData 
*link)
 void BKE_scene_objects_iterator_next(BLI_Iterator *iter)
 {
SceneObjectsIteratorData *data = iter->data;
-   LinkData *link = data->link ? object_base_unique(data->visited, 
data->link->next) : NULL;
+   LinkData *link = data->link_next ? object_base_unique(data->visited, 
data->link_next) : NULL;
 
if (link) {
-   data->link = link;
+   data->link_next = link->next;
iter->current = link->data;
}
else {
@@ -624,8 +624,8 @@ void BKE_scene_objects_iterator_next(BLI_Iterator *iter)
/* get the first unique object of this collection */
LinkData *new_link = object_base_unique(data->visited, 
sc->objects.first);
if (new_link) {
-   data->link = new_link;
-   iter->current = data->link->data;
+   data->link_next = new_link->next;
+   iter->current = new_link->data;
return;
}

BKE_scene_collections_iterator_next(>scene_collection_iter);
diff --git a/tests/python/render_layer/CMakeLists.txt 
b/tests/python/render_layer/CMakeLists.txt
index 526b169bc3d..b3c064289a0 100644
--- a/tests/python/render_layer/CMakeLists.txt
+++ b/tests/python/render_layer/CMakeLists.txt
@@ -170,4 +170,5 @@ RENDER_LAYER_TEST(scene_copy_b)
 RENDER_LAYER_TEST(scene_copy_c)
 RENDER_LAYER_TEST(scene_copy_d)
 RENDER_LAYER_TEST(scene_copy_e)
+RENDER_LAYER_TEST(scene_delete)
 RENDER_LAYER_TEST(scene_write_read)
diff --git a/tests/python/render_layer/test_scene_delete.py 
b/tests/python/render_layer/test_scene_delete.py
new file mode 100644
index 000..cd59a446c9a
--- /dev/null
+++ b/tests/python/render_layer/test_scene_delete.py
@@ -0,0 +1,39 @@
+# 
+# Importing - Same For All Render Layer Tests
+# 
+
+import unittest
+import os
+import sys
+
+from render_layer_common import *
+
+
+# 
+# Testing
+# 
+
+class UnitTesting(RenderLayerTesting):
+def test_scene_delete(self):
+"""
+See if a scene can be properly deleted
+"""
+import bpy
+
+scene = bpy.context.scene
+bpy.data.scenes.new('New')
+bpy.data.scenes.remove(scene)
+
+
+# 
+# Main - Same For All Render Layer Tests
+# 
+
+if __name__ == '__main__':
+import sys
+
+extra_arguments = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv 
else []
+sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 2:] if "--" in 
sys.argv else [])
+
+UnitTesting._extra_arguments = extra_arguments
+unittest.main()

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


[Bf-blender-cvs] [9cd6b03187b] master: Fix T50230: Rigid Body simulation shouldn't step when time is beyond cached area

2017-06-30 Thread Luca Rood
Commit: 9cd6b03187b91bb2c267a45eac3cee7738e0e220
Author: Luca Rood
Date:   Fri Jun 30 15:56:44 2017 +0200
Branches: master
https://developer.blender.org/rB9cd6b03187b91bb2c267a45eac3cee7738e0e220

Fix T50230: Rigid Body simulation shouldn't step when time is beyond cached area

This makes the last time (`ltime`) stored in the rigid body world (`rbw`)
only be updated once a simulation step actually occurs, this prevents
another simulation step from being solved unless the current time is
exactly one frame after the last cached frame. Thus this prevents the
formation of gaps in the cache, such as seen in T50230.

Reviewers: mont29, sergey, angavrilov

Tags: #physics

Maniphest Tasks: T50230

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

===

M   source/blender/blenkernel/intern/rigidbody.c

===

diff --git a/source/blender/blenkernel/intern/rigidbody.c 
b/source/blender/blenkernel/intern/rigidbody.c
index 390e6dedc3f..c4fb0aec97b 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -1563,12 +1563,8 @@ void BKE_rigidbody_do_simulation(Scene *scene, float 
ctime)
BKE_ptcache_id_time(, scene, ctime, , , NULL);
cache = rbw->pointcache;
 
-   if (ctime <= startframe) {
-   rbw->ltime = startframe;
-   return;
-   }
/* make sure we don't go out of cache frame range */
-   else if (ctime > endframe) {
+   if (ctime > endframe) {
ctime = endframe;
}
 
@@ -1584,7 +1580,6 @@ void BKE_rigidbody_do_simulation(Scene *scene, float 
ctime)
 
if (BKE_ptcache_read(, ctime, can_simulate)) {
BKE_ptcache_validate(cache, (int)ctime);
-   rbw->ltime = ctime;
return;
}

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


[Bf-blender-cvs] [b43cdc91ce4] blender2.8: Fix T51721: OpenGL Detection is broken on Windows

2017-06-30 Thread Dalai Felinto
Commit: b43cdc91ce4188e2fc18ff6646781ff03fbfd693
Author: Dalai Felinto
Date:   Fri Jun 30 13:33:54 2017 +0200
Branches: blender2.8
https://developer.blender.org/rBb43cdc91ce4188e2fc18ff6646781ff03fbfd693

Fix T51721: OpenGL Detection is broken on Windows

Now computers that support OpenGl3.3 (but not 4.5) can run Blender 2.8.

For any given HDC, you may only call SetPixelFormat *ONCE* any future
calls for the same HDC will fail. And computers that would support only
OpenGL 3.3 wouldn't have a change to get a valid OpenGL context because
the pixelformat was already set while trying to probe the supported
contexts.

We fix this by splitting the final context creation from the query of
supported OpenGL versions.

Patch by Ray Molenkamp (bzzt_ploink/LazyDodo) with code style fixes and
comments by me.

===

M   intern/ghost/intern/GHOST_ContextWGL.cpp
M   intern/ghost/intern/GHOST_ContextWGL.h
M   intern/ghost/intern/GHOST_WindowWin32.cpp

===

diff --git a/intern/ghost/intern/GHOST_ContextWGL.cpp 
b/intern/ghost/intern/GHOST_ContextWGL.cpp
index 8cf311b9e84..d2dd38878f7 100644
--- a/intern/ghost/intern/GHOST_ContextWGL.cpp
+++ b/intern/ghost/intern/GHOST_ContextWGL.cpp
@@ -914,29 +914,6 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
reportContextString("Version",  m_dummyVersion,  version);
 #endif
 
-   if ((strcmp(vendor, "Microsoft Corporation") == 0 ||
-strcmp(renderer, "GDI Generic") == 0) && version[0] == '1' && 
version[2] == '1')
-   {
-   MessageBox(m_hWnd, "Your system does not use 3D hardware 
acceleration.\n"
-  "Blender requires a graphics driver with 
OpenGL 3.3 support.\n\n"
-  "This may be caused by:\n"
-  "* A missing or faulty graphics driver 
installation.\n"
-  "  Blender needs a graphics card driver to 
work correctly.\n"
-  "* Accessing Blender through a remote 
connection.\n"
-  "* Using Blender through a virtual 
machine.\n\n"
-  "The program will now close.",
-  "Blender - Can't detect 3D hardware accelerated 
Driver!",
-  MB_OK | MB_ICONERROR);
-   exit(0);
-   }
-   else if (version[0] < '3' || (version[0] == '3' && version[2] < '3')) {
-   MessageBox(m_hWnd, "Blender requires a graphics driver with 
OpenGL 3.3 support.\n\n"
-  "The program will now close.",
-  "Blender - Unsupported Graphics Driver!",
-  MB_OK | MB_ICONERROR);
-   exit(0);
-   }
-
return GHOST_kSuccess;
 }
 
@@ -950,3 +927,97 @@ GHOST_TSuccess GHOST_ContextWGL::releaseNativeHandles()
 
return success;
 }
+
+/**
+ * For any given HDC you may call SetPixelFormat once
+ *
+ * So we better try to get the correct OpenGL version in a new window 
altogether, in case it fails.
+ * (see 
https://msdn.microsoft.com/en-us/library/windows/desktop/dd369049(v=vs.85).aspx)
+ */
+static bool TryOpenGLVersion(
+HWND hwnd,
+bool wantStereoVisual,
+bool wantAlphaBackground,
+GHOST_TUns16 wantNumOfAASamples,
+int contextProfileMask,
+bool debugContext,
+int major, int minor)
+{
+   HWND dummyHWND = clone_window(hwnd, NULL);
+   if (dummyHWND == NULL) {
+   return false;
+   }
+
+   HDC dummyHDC = GetDC(dummyHWND);
+   if (dummyHDC == NULL) {
+   return false;
+   }
+
+   GHOST_ContextWGL * context = new GHOST_ContextWGL(
+   wantStereoVisual,
+   wantAlphaBackground,
+   wantNumOfAASamples,
+   dummyHWND,
+   dummyHDC,
+   contextProfileMask,
+   major, minor,
+   (debugContext ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
+   GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
+
+   bool result = context->initializeDrawingContext();
+   delete context;
+
+   ReleaseDC(dummyHWND, dummyHDC);
+   DestroyWindow(dummyHWND);
+
+   return result;
+}
+
+GHOST_TSuccess GHOST_ContextWGL::getMaximumSupportedOpenGLVersion(
+HWND hwnd,
+bool wantStereoVisual,
+bool wantAlphaBackground,
+GHOST_TUns16 wantNumOfAASamples,
+int contextProfileMask,
+bool debugContext,
+GHOST_TUns8 *r_major_version,
+GHOST_TUns8 *r_minor_version)
+{
+   /* - AMD and Intel give us exactly this version
+* - NVIDIA gives at least this version <-- desired behavior
+* So we ask for 4.5, 4.4 ... 3.3 in descending order to get the best 
version on the user's system. */
+   

[Bf-blender-cvs] [d958084187b] greasepencil-object: Merge branch 'blender2.8' into greasepencil-object

2017-06-30 Thread Antonio Vazquez
Commit: d958084187baf7ebf4385d15b7c8cfa4fc5ce499
Author: Antonio Vazquez
Date:   Fri Jun 30 15:39:06 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rBd958084187baf7ebf4385d15b7c8cfa4fc5ce499

Merge branch 'blender2.8' into greasepencil-object

===



===



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


[Bf-blender-cvs] [073ef79840b] greasepencil-object: Fix T51936: Show draw strokes since first stroke

2017-06-30 Thread Antonio Vazquez
Commit: 073ef79840b5898ef0efc59c3815ac6e2faae405
Author: Antonio Vazquez
Date:   Fri Jun 30 15:34:34 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB073ef79840b5898ef0efc59c3815ac6e2faae405

Fix T51936: Show draw strokes since first stroke

The drawing stroke must not be related to cache drawing because only one stroke 
is done at time.

===

M   source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M   source/blender/draw/engines/gpencil/gpencil_engine.c
M   source/blender/draw/engines/gpencil/gpencil_engine.h

===

diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c 
b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index c79bbc7418d..3905e0724b9 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -200,9 +200,6 @@ void gpencil_batch_cache_clear(bGPdata *gpd)
MEM_SAFE_FREE(cache->batch_fill);
MEM_SAFE_FREE(cache->batch_edit);
}
-
-   BATCH_DISCARD_ALL_SAFE(cache->batch_buffer_stroke);
-   BATCH_DISCARD_ALL_SAFE(cache->batch_buffer_fill);
 }
 
 /* get cache */
@@ -505,7 +502,7 @@ static void gpencil_draw_strokes(GpencilBatchCache *cache, 
GPENCIL_e_data *e_dat
 }
 
  /* draw stroke in drawing buffer */
-static void gpencil_draw_buffer_strokes(GpencilBatchCache *cache, void 
*vedata, ToolSettings *ts, bGPdata *gpd)
+void DRW_gpencil_populate_buffer_strokes(void *vedata, ToolSettings *ts, 
bGPdata *gpd)
 {
GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
bGPDbrush *brush = BKE_gpencil_brush_getactive(ts);
@@ -522,21 +519,21 @@ static void gpencil_draw_buffer_strokes(GpencilBatchCache 
*cache, void *vedata,
*/
short lthick = brush->thickness;
if (gpd->sbuffer_size == 1) {
-   cache->batch_buffer_stroke = 
DRW_gpencil_get_buffer_point_geom(gpd, lthick);
-   
DRW_shgroup_call_add(stl->g_data->shgrps_point_volumetric, 
cache->batch_buffer_stroke, stl->storage->unit_matrix);
+   stl->g_data->batch_buffer_stroke = 
DRW_gpencil_get_buffer_point_geom(gpd, lthick);
+   
DRW_shgroup_call_add(stl->g_data->shgrps_point_volumetric, 
stl->g_data->batch_buffer_stroke, stl->storage->unit_matrix);
}
else {
/* use unit matrix because the buffer is in 
screen space and does not need conversion */
-   cache->batch_buffer_stroke = 
DRW_gpencil_get_buffer_stroke_geom(gpd, stl->storage->unit_matrix, lthick);
-   
DRW_shgroup_call_add(stl->g_data->shgrps_drawing_stroke, 
cache->batch_buffer_stroke, stl->storage->unit_matrix);
+   stl->g_data->batch_buffer_stroke = 
DRW_gpencil_get_buffer_stroke_geom(gpd, stl->storage->unit_matrix, lthick);
+   
DRW_shgroup_call_add(stl->g_data->shgrps_drawing_stroke, 
stl->g_data->batch_buffer_stroke, stl->storage->unit_matrix);
 
if ((gpd->sbuffer_size >= 3) && (gpd->sfill[3] 
> GPENCIL_ALPHA_OPACITY_THRESH)) {
/* if not solid, fill is simulated with 
solid color */
if (gpd->bfill_style > 0) {
gpd->sfill[3] = 0.5f;
}
-   cache->batch_buffer_fill = 
DRW_gpencil_get_buffer_fill_geom(gpd->sbuffer, gpd->sbuffer_size, gpd->sfill);
-   
DRW_shgroup_call_add(stl->g_data->shgrps_drawing_fill, 
cache->batch_buffer_fill, stl->storage->unit_matrix);
+   stl->g_data->batch_buffer_fill = 
DRW_gpencil_get_buffer_fill_geom(gpd->sbuffer, gpd->sbuffer_size, gpd->sfill);
+   
DRW_shgroup_call_add(stl->g_data->shgrps_drawing_fill, 
stl->g_data->batch_buffer_fill, stl->storage->unit_matrix);
}
}
}
@@ -644,8 +641,6 @@ void DRW_gpencil_populate_datablock(GPENCIL_e_data *e_data, 
void *vedata, Scene
/* draw normal strokes */
gpencil_draw_strokes(cache, e_data, vedata, ts, ob, gpd, gpl, 
gpf, gpl->opacity, gpl->tintcolor, false, false);
}
-   /* draw current painting strokes */
-   gpencil_draw_buffer_strokes(cache, vedata, ts, gpd);
cache->is_dirty = false;
 }
 
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c 
b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 1e3a8df2379..80817da3a02 

[Bf-blender-cvs] [76eefa5c0d0] master: Better fix for isfinite problem - works in older gcc's too.

2017-06-30 Thread Howard Trickey
Commit: 76eefa5c0d034d00ddec42efa7351e1c85df3906
Author: Howard Trickey
Date:   Fri Jun 30 09:04:01 2017 -0400
Branches: master
https://developer.blender.org/rB76eefa5c0d034d00ddec42efa7351e1c85df3906

Better fix for isfinite problem - works in older gcc's too.

Previous fix relying on __cplusplus value didn't fix for older
gcc's on linux, but this fix does.

===

M   intern/elbeem/intern/isosurface.cpp

===

diff --git a/intern/elbeem/intern/isosurface.cpp 
b/intern/elbeem/intern/isosurface.cpp
index dc2cf684200..de7bfe8e687 100644
--- a/intern/elbeem/intern/isosurface.cpp
+++ b/intern/elbeem/intern/isosurface.cpp
@@ -15,20 +15,19 @@
 #include "particletracer.h"
 #include 
 #include 
+#include 
 
 #ifdef sun
 #include "ieeefp.h"
 #endif
 
-#if  __cplusplus < 201103L
-#define isfinite finite
-#endif
-
 // just use default rounding for platforms where its not available
 #ifndef round
 #define round(x) (x)
 #endif
 
+using std::isfinite;
+
 /**
  * Constructor
  */

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


[Bf-blender-cvs] [1af42b70d13] greasepencil-object: Minimize Alpha stroke issue

2017-06-30 Thread Antonio Vazquez
Commit: 1af42b70d13dc3d19d75609f96606cc768effe39
Author: Antonio Vazquez
Date:   Fri Jun 30 14:41:59 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB1af42b70d13dc3d19d75609f96606cc768effe39

Minimize Alpha stroke issue

Here we need is OIT (Order Independant Transparency) which is still an open 
issue in the realtime field (and also for Eevee). The best OIT method I know of 
is somewhat complex and not very precise (still not 1:1 with the ordered 
version). It involves more framebuffers and performance cost.

I may need to implement that in the draw manager in the future so that all 
engines can use it.

Thanks to Clement Foucault for the support provided.

===

M   source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M   source/blender/draw/engines/gpencil/gpencil_engine.c
M   source/blender/draw/engines/gpencil/gpencil_engine.h

===

diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c 
b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 31a39a96a32..c79bbc7418d 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -72,11 +72,24 @@ tGPencilObjectCache 
*gpencil_object_cache_allocate(tGPencilObjectCache *cache, i
 /* add a gpencil object to cache to defer drawing */
 void gpencil_object_cache_add(tGPencilObjectCache *cache, Object *ob, int 
*gp_cache_used)
 {
+   const DRWContextState *draw_ctx = DRW_context_state_get();
+   RegionView3D *rv3d = draw_ctx->rv3d;
+
/* save object */
cache[*gp_cache_used].ob = ob;
cache[*gp_cache_used].init_grp = 0;
cache[*gp_cache_used].end_grp = -1;
 
+   /* calculate zdepth from point of view */
+   float zdepth = 0.0;
+   if (rv3d->is_persp) {
+   zdepth = ED_view3d_calc_zfac(rv3d, ob->loc, NULL);
+   }
+   else {
+   zdepth = -dot_v3v3(rv3d->viewinv[2], ob->loc);
+   }
+   cache[*gp_cache_used].zdepth = zdepth;
+
/* increase slots used in cache */
++*gp_cache_used;
 }
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c 
b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 874ec91be78..1e3a8df2379 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -235,6 +235,17 @@ static void GPENCIL_cache_finish(void *vedata)
MEM_SAFE_FREE(stl->g_data->gpd_in_cache);
 }
 
+/* helper function to sort inverse gpencil objects using qsort */
+static int gpencil_object_cache_compare_zdepth(const void *a1, const void *a2)
+{
+   const tGPencilObjectCache *ps1 = a1, *ps2 = a2;
+
+   if (ps1->zdepth < ps2->zdepth) return 1;
+   else if (ps1->zdepth > ps2->zdepth) return -1;
+
+   return 0;
+}
+
 static void GPENCIL_draw_scene(void *vedata)
 {
GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
@@ -247,7 +258,11 @@ static void GPENCIL_draw_scene(void *vedata)
 
/* Draw all pending objects */
if (stl->g_data->gp_cache_used > 0) {
-   
+
+   /* sort by zdepth */
+   qsort(stl->g_data->gp_object_cache, stl->g_data->gp_cache_used, 
+   sizeof(tGPencilObjectCache), 
gpencil_object_cache_compare_zdepth);
+
/* attach temp textures */
DRW_framebuffer_texture_attach(fbl->temp_color_fb, 
e_data.temp_fbcolor_depth_tx, 0, 0);
DRW_framebuffer_texture_attach(fbl->temp_color_fb, 
e_data.temp_fbcolor_color_tx, 0, 0);
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h 
b/source/blender/draw/engines/gpencil/gpencil_engine.h
index ce92893d9cf..26f281e4f37 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -40,6 +40,7 @@ struct tGPspoint;
 typedef struct tGPencilObjectCache {
struct Object *ob;
int init_grp, end_grp;
+   float zdepth;
 } tGPencilObjectCache;
 
   /* *** LISTS *** */

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


[Bf-blender-cvs] [08310996645] blender2.8: Eevee: Principled BSDF: add support for specular tint + optimisation

2017-06-30 Thread Clément Foucault
Commit: 08310996645f0afb5d1d6ecd4c6b41a2ab22cd89
Author: Clément Foucault
Date:   Fri Jun 30 14:12:25 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB08310996645f0afb5d1d6ecd4c6b41a2ab22cd89

Eevee: Principled BSDF: add support for specular tint + optimisation

Only use clearcoat version if there is something linked or if the clearcoat 
value is not 0.

===

M   source/blender/gpu/shaders/gpu_shader_material.glsl
M   source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c

===

diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl 
b/source/blender/gpu/shaders/gpu_shader_material.glsl
index 2633c2965b1..0c36d6ca618 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -2573,13 +2573,41 @@ vec3 rotate_vector(vec3 p, vec3 n, float theta) {
   );
 }
 
-void convert_metallic_to_specular(vec4 basecol, float metallic, float 
specular_fac, out vec4 diffuse, out vec4 f0)
+void prepare_tangent(
+float anisotropic, float anisotropic_rotation, float roughness, vec3 
N, vec3 T,
+out vec3 X, out vec3 Y, out float ax, out float ay)
 {
-   vec4 dielectric = vec4(0.034) * specular_fac * 2.0;
-   diffuse = mix(basecol, vec4(0.0), metallic);
+   /* rotate tangent */
+   if (anisotropic_rotation != 0.0) {
+   T = rotate_vector(T, N, anisotropic_rotation * 2.0 * M_PI);
+   }
+
+   Y = normalize(cross(T, N));
+
+   float aspect = sqrt(1.0 - anisotropic * 0.9);
+   float a = sqr(roughness);
+   ax = max(0.001, a / aspect);
+   ay = max(0.001, a * aspect);
+}
+
+void convert_metallic_to_specular(vec3 basecol, float metallic, float 
specular_fac, out vec3 diffuse, out vec3 f0)
+{
+   vec3 dielectric = vec3(0.034) * specular_fac * 2.0;
+   diffuse = mix(basecol, vec3(0.0), metallic);
f0 = mix(dielectric, basecol, metallic);
 }
 
+void convert_metallic_to_specular_tinted(
+vec3 basecol, float metallic, float specular_fac, float specular_tint,
+out vec3 diffuse, out vec3 f0)
+{
+   vec3 dielectric = vec3(0.034) * specular_fac * 2.0;
+   float lum = dot(basecol, vec3(0.3, 0.6, 0.1)); /* luminance approx. */
+   vec3 tint = lum > 0 ? basecol / lum : vec3(1.0); /* normalize lum. to 
isolate hue+sat */
+   f0 = mix(dielectric * mix(vec3(1.0), tint, specular_tint), basecol, 
metallic);
+   diffuse = mix(basecol, vec3(0.0), metallic);
+}
+
 /*** NEW SHADER NODES ***/
 
 #define NUM_LIGHTS 3
@@ -2656,50 +2684,10 @@ void node_bsdf_principled(vec4 base_color, float 
subsurface, vec3 subsurface_rad
float specular_tint, float roughness, float anisotropic, float 
anisotropic_rotation, float sheen, float sheen_tint, float clearcoat,
float clearcoat_roughness, float ior, float transmission, float 
transmission_roughness, vec3 N, vec3 CN, vec3 T, vec3 I, out vec4 result)
 {
-   /* rotate tangent */
-   if (anisotropic_rotation != 0.0) {
-   T = rotate_vector(T, N, anisotropic_rotation * 2.0 * M_PI);
-   }
-
-   /* calculate the tangent and bitangent */
-   vec3 Y = T;
-   vec3 X = normalize(cross(Y, N));
-
-   float aspect = sqrt(1.0 - anisotropic * 0.9);
-   float a = sqr(roughness);
-   float ax = max(0.001, a / aspect);
-   float ay = max(0.001, a * aspect);
+   vec3 X, Y;
+   float ax, ay;
+   prepare_tangent(anisotropic, anisotropic_rotation, roughness, N, T, X, 
Y, ax, ay);
 
-#ifdef EEVEE_ENGINE
-   vec4 diffuse, f0;
-   convert_metallic_to_specular(base_color, metallic, specular, diffuse, 
f0);
-
-   /* Original value is 0.25 but this one seems to fit cycles better */
-   clearcoat *= 0.5;
-
-#if 0 /* Wait until temporal AA (aka. denoising) */
-   /* Distribute N in anisotropy direction. */
-   vec4 surface_color = vec4(0.0);
-   for (float i = 0.0; i < 5.0; ++i) {
-   vec4 rand = texture(utilTex, vec3((gl_FragCoord.xy + i) / 
LUT_SIZE, 2.0));
-
-   float tmp = sqrt( rand.x / (1.0 - rand.x) );
-   float x = (ax > ay ? ax : 0.0) * tmp * rand.z;
-   float y = (ay > ax ? ay : 0.0) * tmp * rand.w;
-   vec3 Ht = normalize(vec3(x, y, 1.0));
-   N = tangent_to_world(Ht, N, Y, X);
-
-   if (dot(N, cameraVec) > 0) {
-   surface_color.rgb += eevee_surface_clearcoat_lit(N, 
diffuse.rgb, f0.rgb, sqrt(min(ax, ay)), CN, clearcoat, clearcoat_roughness, 
1.0);
-   surface_color.a += 1.0;
-   }
-   }
-   result = vec4(surface_color.rgb / surface_color.a, 1.0);
-#else
-   result = vec4(eevee_surface_clearcoat_lit(N, diffuse.rgb, f0.rgb, 
sqrt(min(ax, ay)), CN, clearcoat * 0.5, clearcoat_roughness, 1.0), 1.0);
-#endif

[Bf-blender-cvs] [178c470c438] blender2.8: Eevee: Fix specular shadowing.

2017-06-30 Thread Clément Foucault
Commit: 178c470c43870adae4bfdcb6d03e1657a6f98f43
Author: Clément Foucault
Date:   Fri Jun 30 14:10:42 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB178c470c43870adae4bfdcb6d03e1657a6f98f43

Eevee: Fix specular shadowing.

Compute luminance approximation instead of using green channel.
This is to match cycles principled bsdf.

===

M   source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl

===

diff --git a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl 
b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
index 0ccf2309bb4..0351fa4a861 100644
--- a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
@@ -266,16 +266,16 @@ vec3 F_area(vec3 f0, vec2 lut)
vec2 fac = normalize(lut.xy);
 
/* Unreal specular matching : if specular color is below 2% intensity,
-* (using green channel for intensity) treat as shadowning */
-   return saturate(50.0 * f0.g) * fac.y + fac.x * f0;
+* treat as shadowning */
+   return saturate(50.0 * dot(f0, vec3(0.3, 0.6, 0.1))) * fac.y + fac.x * 
f0;
 }
 
 /* Fresnel approximation for LTC area lights (not MRP) */
 vec3 F_ibl(vec3 f0, vec2 lut)
 {
/* Unreal specular matching : if specular color is below 2% intensity,
-* (using green channel for intensity) treat as shadowning */
-   return saturate(50.0 * f0.g) * lut.y + lut.x * f0;
+* treat as shadowning */
+   return saturate(50.0 * dot(f0, vec3(0.3, 0.6, 0.1))) * lut.y + lut.x * 
f0;
 }
 
 /* GGX */

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


[Bf-blender-cvs] [1938a81e420] master: Fix compile error after recent 9c2bbfb6 commit.

2017-06-30 Thread Howard Trickey
Commit: 1938a81e420d2c97fe1ef04a0768d37fb1ccbd9c
Author: Howard Trickey
Date:   Fri Jun 30 07:47:37 2017 -0400
Branches: master
https://developer.blender.org/rB1938a81e420d2c97fe1ef04a0768d37fb1ccbd9c

Fix compile error after recent 9c2bbfb6 commit.

Older C++ compilers use finite instead of isfinite.

===

M   intern/elbeem/intern/isosurface.cpp

===

diff --git a/intern/elbeem/intern/isosurface.cpp 
b/intern/elbeem/intern/isosurface.cpp
index b29c9e20358..dc2cf684200 100644
--- a/intern/elbeem/intern/isosurface.cpp
+++ b/intern/elbeem/intern/isosurface.cpp
@@ -20,6 +20,10 @@
 #include "ieeefp.h"
 #endif
 
+#if  __cplusplus < 201103L
+#define isfinite finite
+#endif
+
 // just use default rounding for platforms where its not available
 #ifndef round
 #define round(x) (x)

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


[Bf-blender-cvs] [bf6338c4818] soc-2017-vertex_paint: added the weight to paint converter as option in paint in verte xpainting and weight in weight painting

2017-06-30 Thread Darshan Kadu
Commit: bf6338c48184e528880e48043964ae7b4189ae57
Author: Darshan Kadu
Date:   Fri Jun 30 16:25:08 2017 +0530
Branches: soc-2017-vertex_paint
https://developer.blender.org/rBbf6338c48184e528880e48043964ae7b4189ae57

added the weight to paint converter as option in paint in verte xpainting and 
weight in weight painting

===

M   release/scripts/startup/bl_ui/space_view3d.py
M   source/blender/editors/sculpt_paint/paint_vertex.c

===

diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index 643a4b8cc00..42a6d3138a7 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -1779,6 +1779,7 @@ class VIEW3D_MT_paint_vertex(Menu):
 layout.operator("paint.vertex_color_set")
 layout.operator("paint.vertex_color_smooth")
 layout.operator("paint.vertex_color_dirt")
+layout.operator("paint.weight_to_vertex_convert")
 
 layout.separator()
 
@@ -1869,6 +1870,7 @@ class VIEW3D_MT_paint_weight(Menu):
 layout.separator()
 
 layout.operator("paint.weight_set")
+layout.operator("paint.weight_to_vertex_convert")
 
 
 # ** Sculpt menu **
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c 
b/source/blender/editors/sculpt_paint/paint_vertex.c
index 25ffd312ced..24ef4fd6315 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -124,6 +124,13 @@ int vertex_paint_mode_poll(bContext *C)
return ob && ob->mode == OB_MODE_VERTEX_PAINT && ((Mesh 
*)ob->data)->totpoly;
 }
 
+int vertex_weight_paint_mode_poll(bContext *C)
+{
+   Object *ob = CTX_data_active_object(C);
+
+   return ob && (ob->mode == OB_MODE_VERTEX_PAINT || ob->mode == 
OB_MODE_WEIGHT_PAINT) && ((Mesh *)ob->data)->totpoly;
+}
+
 int vertex_paint_poll(bContext *C)
 {
if (vertex_paint_mode_poll(C) && 
@@ -4584,8 +4591,9 @@ void PAINT_OT_weight_gradient(wmOperatorType *ot)
WM_operator_properties_gesture_straightline(ot, CURSOR_EDIT);
 }
 
-static bool weight_to_vert_convert(Object *ob)
+static bool weight_to_vert_convert(bContext *C)
 {
+   Object *ob = CTX_data_active_object(C);
Mesh *me;
const MPoly *mp;
int vgroup_active;
@@ -4611,13 +4619,15 @@ static bool weight_to_vert_convert(Object *ob)
j++;
} while (j <= mp->totloop - 1);
}
+
+   DAG_id_tag_update(>id, OB_RECALC_DATA);
+   WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
return true;
 }
 
 static int weight_to_vert_convert_exec(bContext *C, wmOperator *op)
 {
-   Object *obact = CTX_data_active_object(C);
-   if (weight_to_vert_convert(obact)) {
+   if (weight_to_vert_convert(C)) {
return OPERATOR_FINISHED;
}
return OPERATOR_CANCELLED;
@@ -4626,13 +4636,13 @@ static int weight_to_vert_convert_exec(bContext *C, 
wmOperator *op)
 void PAINT_OT_weight_to_vertex_convert(wmOperatorType *ot)
 {
/* identifiers */
-   ot->name = "Weight to Vertex Converter";
+   ot->name = "Weight to Vertex Convert";
ot->idname = "PAINT_OT_weight_to_vertex_convert";
ot->description = "Converts the weight color into the black and white 
vertex color";
 
/* api callback */
ot->exec = weight_to_vert_convert_exec;
-   ot->poll = weight_paint_poll;
+   ot->poll = vertex_weight_paint_mode_poll;
 
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;

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


[Bf-blender-cvs] [1b4bd1c84e4] blender2.8: Fix T51118: Outliner crash when unlinking collection

2017-06-30 Thread Luca Rood
Commit: 1b4bd1c84e404261e267b9cba44fcff20914de6c
Author: Luca Rood
Date:   Fri Jun 30 12:32:18 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB1b4bd1c84e404261e267b9cba44fcff20914de6c

Fix T51118: Outliner crash when unlinking collection

The outliner tree was not being rebuilt after unlinking a collection,
and thus a dangling pointer to the collection was kept in the tree.

===

M   source/blender/editors/space_outliner/outliner_collections.c

===

diff --git a/source/blender/editors/space_outliner/outliner_collections.c 
b/source/blender/editors/space_outliner/outliner_collections.c
index 315a3af1898..2db87df8809 100644
--- a/source/blender/editors/space_outliner/outliner_collections.c
+++ b/source/blender/editors/space_outliner/outliner_collections.c
@@ -216,6 +216,7 @@ static int collection_unlink_poll(bContext *C)
 static int collection_unlink_exec(bContext *C, wmOperator *op)
 {
LayerCollection *lc = outliner_collection_active(C);
+   SpaceOops *soops = CTX_wm_space_outliner(C);
 
if (lc == NULL) {
BKE_report(op->reports, RPT_ERROR, "Active element is not a 
collection");
@@ -225,6 +226,10 @@ static int collection_unlink_exec(bContext *C, wmOperator 
*op)
SceneLayer *sl = CTX_data_scene_layer(C);
BKE_collection_unlink(sl, lc);
 
+   if (soops) {
+   outliner_cleanup_tree(soops);
+   }
+
DEG_relations_tag_update(CTX_data_main(C));
 
/* TODO(sergey): Use proper flag for tagging here. */

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


[Bf-blender-cvs] [1a6ae0c70e2] blender2.8: DwM: Use GWN_vertbuf_raw_* access for shading data

2017-06-30 Thread Campbell Barton
Commit: 1a6ae0c70e24a00dce5a65748c1b4487730fde7d
Author: Campbell Barton
Date:   Fri Jun 30 18:01:20 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB1a6ae0c70e24a00dce5a65748c1b4487730fde7d

DwM: Use GWN_vertbuf_raw_* access for shading data

Gives approx 14% speedup here.

===

M   source/blender/draw/intern/draw_cache_impl_mesh.c

===

diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c 
b/source/blender/draw/intern/draw_cache_impl_mesh.c
index 4446fb2ce22..48730afdacc 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -35,6 +35,7 @@
 #include "BLI_math_vector.h"
 #include "BLI_math_bits.h"
 #include "BLI_string.h"
+#include "BLI_alloca.h"
 
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
@@ -1211,59 +1212,6 @@ static bool mesh_render_data_edge_vcos_manifold_pnors(
return true;
 }
 
-static void mesh_render_data_looptri_uvs_get(
-MeshRenderData *rdata, const int tri_idx, const int uv_layer,
-float *(*r_vert_uvs)[3])
-{
-   if (rdata->edit_bmesh) {
-   const BMLoop **bm_looptri = (const BMLoop 
**)rdata->edit_bmesh->looptris[tri_idx];
-   (*r_vert_uvs)[0] = ((MLoopUV 
*)BM_ELEM_CD_GET_VOID_P(bm_looptri[0], rdata->cd.offset.uv[uv_layer]))->uv;
-   (*r_vert_uvs)[1] = ((MLoopUV 
*)BM_ELEM_CD_GET_VOID_P(bm_looptri[1], rdata->cd.offset.uv[uv_layer]))->uv;
-   (*r_vert_uvs)[2] = ((MLoopUV 
*)BM_ELEM_CD_GET_VOID_P(bm_looptri[2], rdata->cd.offset.uv[uv_layer]))->uv;
-   }
-   else {
-   const MLoopTri *mlt = >mlooptri[tri_idx];
-   (*r_vert_uvs)[0] = 
rdata->cd.layers.uv[uv_layer][mlt->tri[0]].uv;
-   (*r_vert_uvs)[1] = 
rdata->cd.layers.uv[uv_layer][mlt->tri[1]].uv;
-   (*r_vert_uvs)[2] = 
rdata->cd.layers.uv[uv_layer][mlt->tri[2]].uv;
-   }
-}
-
-static void mesh_render_data_looptri_cols_get(
-MeshRenderData *rdata, const int tri_idx, const int vcol_layer,
-unsigned char *(*r_vert_cols)[3])
-{
-   if (rdata->edit_bmesh) {
-   const BMLoop **bm_looptri = (const BMLoop 
**)rdata->edit_bmesh->looptris[tri_idx];
-   (*r_vert_cols)[0] = &((MLoopCol 
*)BM_ELEM_CD_GET_VOID_P(bm_looptri[0], rdata->cd.offset.vcol[vcol_layer]))->r;
-   (*r_vert_cols)[1] = &((MLoopCol 
*)BM_ELEM_CD_GET_VOID_P(bm_looptri[1], rdata->cd.offset.vcol[vcol_layer]))->r;
-   (*r_vert_cols)[2] = &((MLoopCol 
*)BM_ELEM_CD_GET_VOID_P(bm_looptri[2], rdata->cd.offset.vcol[vcol_layer]))->r;
-   }
-   else {
-   const MLoopTri *mlt = >mlooptri[tri_idx];
-   (*r_vert_cols)[0] = 
>cd.layers.vcol[vcol_layer][mlt->tri[0]].r;
-   (*r_vert_cols)[1] = 
>cd.layers.vcol[vcol_layer][mlt->tri[1]].r;
-   (*r_vert_cols)[2] = 
>cd.layers.vcol[vcol_layer][mlt->tri[2]].r;
-   }
-}
-
-static void mesh_render_data_looptri_tans_get(
-MeshRenderData *rdata, const int tri_idx, const int tangent_layer,
-float *(*r_vert_tans)[3])
-{
-   if (rdata->edit_bmesh) {
-   const BMLoop **bm_looptri = (const BMLoop 
**)rdata->edit_bmesh->looptris[tri_idx];
-   (*r_vert_tans)[0] = 
rdata->cd.layers.tangent[tangent_layer][BM_elem_index_get(bm_looptri[0])];
-   (*r_vert_tans)[1] = 
rdata->cd.layers.tangent[tangent_layer][BM_elem_index_get(bm_looptri[1])];
-   (*r_vert_tans)[2] = 
rdata->cd.layers.tangent[tangent_layer][BM_elem_index_get(bm_looptri[2])];
-   }
-   else {
-   const MLoopTri *mlt = >mlooptri[tri_idx];
-   (*r_vert_tans)[0] = 
rdata->cd.layers.tangent[tangent_layer][mlt->tri[0]];
-   (*r_vert_tans)[1] = 
rdata->cd.layers.tangent[tangent_layer][mlt->tri[1]];
-   (*r_vert_tans)[2] = 
rdata->cd.layers.tangent[tangent_layer][mlt->tri[2]];
-   }
-}
 
 /* First 2 bytes are bit flags
  * 3rd is for sharp edges
@@ -1731,10 +1679,12 @@ static Gwn_VertBuf 
*mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata,
 #define USE_COMP_MESH_DATA
 
if (cache->shaded_triangles_data == NULL) {
-   unsigned int vidx = 0;
-   const char *attrib_name;
+   const uint uv_len = rdata->cd.layers.uv_len;
+   const uint tangent_len = rdata->cd.layers.tangent_len;
+   const uint vcol_len = rdata->cd.layers.vcol_len;
+   const uint layers_combined_len = uv_len + vcol_len + 
tangent_len;
 
-   if (rdata->cd.layers.uv_len + rdata->cd.layers.tangent_len + 
rdata->cd.layers.vcol_len == 0) {
+   if (layers_combined_len == 0) {
return NULL;
}
 
@@ -1743,13 +1693,19 @@ static Gwn_VertBuf 

[Bf-blender-cvs] [34e49486825] blender2.8: Fix T51919: Tangents need UV's allocated

2017-06-30 Thread Campbell Barton
Commit: 34e49486825734f41629b21cc96b4635ffb20b54
Author: Campbell Barton
Date:   Fri Jun 30 17:48:18 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB34e49486825734f41629b21cc96b4635ffb20b54

Fix T51919: Tangents need UV's allocated

===

M   source/blender/draw/intern/draw_cache_impl_mesh.c

===

diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c 
b/source/blender/draw/intern/draw_cache_impl_mesh.c
index 32bc0603532..4446fb2ce22 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -305,9 +305,6 @@ static void mesh_cd_calc_used_gpu_layers(
}
if (layer != -1) {
cd_lused[CD_TANGENT] |= 
(1 << layer);
-
-   /* TODO(campbell): 
investigate why this is needed T51919. */
-   cd_lused[CD_MLOOPUV] |= 
(1 << layer);
}
break;
}
@@ -1737,7 +1734,7 @@ static Gwn_VertBuf 
*mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata,
unsigned int vidx = 0;
const char *attrib_name;
 
-   if (rdata->cd.layers.uv_len + rdata->cd.layers.vcol_len == 0) {
+   if (rdata->cd.layers.uv_len + rdata->cd.layers.tangent_len + 
rdata->cd.layers.vcol_len == 0) {
return NULL;
}
 
@@ -1748,7 +1745,7 @@ static Gwn_VertBuf 
*mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata,
/* initialize vertex format */
unsigned int *uv_id = MEM_mallocN(sizeof(*uv_id) * 
rdata->cd.layers.uv_len, "UV attrib format");
unsigned int *vcol_id = MEM_mallocN(sizeof(*vcol_id) * 
rdata->cd.layers.vcol_len, "Vcol attrib format");
-   unsigned int *tangent_id = MEM_mallocN(sizeof(*tangent_id) * 
rdata->cd.layers.uv_len, "Tangent attrib format");
+   unsigned int *tangent_id = MEM_mallocN(sizeof(*tangent_id) * 
rdata->cd.layers.tangent_len, "Tangent attrib format");
 
for (int i = 0; i < rdata->cd.layers.uv_len; i++) {
/* UV */

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