Merge branch 'master' into blender2.8
authorBastien Montagne <montagne29@wanadoo.fr>
Tue, 4 Jul 2017 11:13:49 +0000 (13:13 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Tue, 4 Jul 2017 11:13:49 +0000 (13:13 +0200)
Conflicts:
source/blender/makesdna/DNA_particle_types.h

intern/cycles/device/device_cpu.cpp
intern/cycles/kernel/split/kernel_queue_enqueue.h
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/rigidbody.c
source/blender/editors/space_view3d/drawarmature.c
source/blender/editors/transform/transform_conversions.c
source/blender/makesdna/DNA_particle_types.h

index 29bb1f91a40b1fc330bc001341084c4d74fa4447..a0cdec0951b58183f9c2e12c9c9b315a218f6a2e 100644 (file)
@@ -248,6 +248,7 @@ public:
                REGISTER_SPLIT_KERNEL(direct_lighting);
                REGISTER_SPLIT_KERNEL(shadow_blocked_ao);
                REGISTER_SPLIT_KERNEL(shadow_blocked_dl);
+               REGISTER_SPLIT_KERNEL(enqueue_inactive);
                REGISTER_SPLIT_KERNEL(next_iteration_setup);
                REGISTER_SPLIT_KERNEL(indirect_subsurface);
                REGISTER_SPLIT_KERNEL(buffer_update);
index e2e841f36d3b31f18b370dd87716886ab9a41d55..66ce2dfb6f14815a6824523f20087646e26bc3bc 100644 (file)
@@ -51,7 +51,8 @@ ccl_device void kernel_queue_enqueue(KernelGlobals *kg,
        int queue_number = -1;
 
        if(IS_STATE(kernel_split_state.ray_state, ray_index, RAY_HIT_BACKGROUND) ||
-          IS_STATE(kernel_split_state.ray_state, ray_index, RAY_UPDATE_BUFFER)) {
+          IS_STATE(kernel_split_state.ray_state, ray_index, RAY_UPDATE_BUFFER) ||
+          IS_STATE(kernel_split_state.ray_state, ray_index, RAY_TO_REGENERATE)) {
                queue_number = QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS;
        }
        else if(IS_STATE(kernel_split_state.ray_state, ray_index, RAY_ACTIVE) ||
index 0a7ccc3ce3569c7923649ce34f1f378c7ad1bca5..dabade5649082c7a72f0a25364486db93a2983e4 100644 (file)
@@ -255,11 +255,16 @@ struct LatticeDeformData *psys_create_lattice_deform_data(ParticleSimulationData
        if (psys_in_edit_mode(sim->scene, sim->psys) == 0) {
                Object *lattice = NULL;
                ModifierData *md = (ModifierData *)psys_get_modifier(sim->ob, sim->psys);
+               int mode = G.is_rendering ? eModifierMode_Render : eModifierMode_Realtime;
 
                for (; md; md = md->next) {
                        if (md->type == eModifierType_Lattice) {
-                               LatticeModifierData *lmd = (LatticeModifierData *)md;
-                               lattice = lmd->object;
+                               if (md->mode & mode) {
+                                       LatticeModifierData *lmd = (LatticeModifierData *)md;
+                                       lattice = lmd->object;
+                                       sim->psys->lattice_strength = lmd->strength;
+                               }
+
                                break;
                        }
                }
@@ -2710,7 +2715,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
                        /* lattices have to be calculated separately to avoid mixups between effector calculations */
                        if (psys->lattice_deform_data) {
                                for (k = 0, ca = cache[p]; k <= segments; k++, ca++)
-                                       calc_latt_deform(psys->lattice_deform_data, ca->co, 1.0f);
+                                       calc_latt_deform(psys->lattice_deform_data, ca->co, psys->lattice_strength);
                        }
                }
 
@@ -3753,7 +3758,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
                                        }
 
                                        if (psys->lattice_deform_data && edit == 0)
-                                               calc_latt_deform(psys->lattice_deform_data, state->co, 1.0f);
+                                               calc_latt_deform(psys->lattice_deform_data, state->co, psys->lattice_strength);
                                }
                        }
                }
@@ -3992,7 +3997,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
                        do_child_modifiers(NULL, sim, NULL, key1->co, key1->vel, key1->rot, par_orco, cpa, cpa->fuv, mat, state, t);
 
                        if (psys->lattice_deform_data)
-                               calc_latt_deform(psys->lattice_deform_data, state->co, 1.0f);
+                               calc_latt_deform(psys->lattice_deform_data, state->co, psys->lattice_strength);
                }
                else {
                        if (pa->state.time == cfra || ELEM(part->phystype, PART_PHYS_NO, PART_PHYS_KEYED))
@@ -4051,7 +4056,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
                        }
 
                        if (sim->psys->lattice_deform_data)
-                               calc_latt_deform(sim->psys->lattice_deform_data, state->co, 1.0f);
+                               calc_latt_deform(sim->psys->lattice_deform_data, state->co, psys->lattice_strength);
                }
                
                return 1;
@@ -4298,7 +4303,7 @@ void psys_apply_hair_lattice(Scene *scene, Object *ob, ParticleSystem *psys)
                        hkey = pa->hair;
                        for (h = 0; h < pa->totkey; h++, hkey++) {
                                mul_m4_v3(hairmat, hkey->co);
-                               calc_latt_deform(psys->lattice_deform_data, hkey->co, 1.0f);
+                               calc_latt_deform(psys->lattice_deform_data, hkey->co, psys->lattice_strength);
                                mul_m4_v3(imat, hkey->co);
                        }
                }
index 11c1a9b6bb18cf878f499f6110119af4cdded5ac..a2b5ac4359d3d383f8b7e11f8c34f234a9ce1cce 100644 (file)
@@ -1485,24 +1485,60 @@ void BKE_rigidbody_sync_transforms(RigidBodyWorld *rbw, Object *ob, float ctime)
 void BKE_rigidbody_aftertrans_update(Object *ob, float loc[3], float rot[3], float quat[4], float rotAxis[3], float rotAngle)
 {
        RigidBodyOb *rbo = ob->rigidbody_object;
+       bool correct_delta = !(rbo->flag & RBO_FLAG_KINEMATIC || rbo->type == RBO_TYPE_PASSIVE);
 
        /* return rigid body and object to their initial states */
        copy_v3_v3(rbo->pos, ob->loc);
        copy_v3_v3(ob->loc, loc);
 
+       if (correct_delta) {
+               add_v3_v3(rbo->pos, ob->dloc);
+       }
+
        if (ob->rotmode > 0) {
-               eulO_to_quat(rbo->orn, ob->rot, ob->rotmode);
+               float qt[4];
+               eulO_to_quat(qt, ob->rot, ob->rotmode);
+
+               if (correct_delta) {
+                       float dquat[4];
+                       eulO_to_quat(dquat, ob->drot, ob->rotmode);
+
+                       mul_qt_qtqt(rbo->orn, dquat, qt);
+               }
+               else {
+                       copy_qt_qt(rbo->orn, qt);
+               }
+
                copy_v3_v3(ob->rot, rot);
        }
        else if (ob->rotmode == ROT_MODE_AXISANGLE) {
-               axis_angle_to_quat(rbo->orn, ob->rotAxis, ob->rotAngle);
+               float qt[4];
+               axis_angle_to_quat(qt, ob->rotAxis, ob->rotAngle);
+
+               if (correct_delta) {
+                       float dquat[4];
+                       axis_angle_to_quat(dquat, ob->drotAxis, ob->drotAngle);
+
+                       mul_qt_qtqt(rbo->orn, dquat, qt);
+               }
+               else {
+                       copy_qt_qt(rbo->orn, qt);
+               }
+
                copy_v3_v3(ob->rotAxis, rotAxis);
                ob->rotAngle = rotAngle;
        }
        else {
-               copy_qt_qt(rbo->orn, ob->quat);
+               if (correct_delta) {
+                       mul_qt_qtqt(rbo->orn, ob->dquat, ob->quat);
+               }
+               else {
+                       copy_qt_qt(rbo->orn, ob->quat);
+               }
+
                copy_qt_qt(ob->quat, quat);
        }
+
        if (rbo->physics_object) {
                /* allow passive objects to return to original transform */
                if (rbo->type == RBO_TYPE_PASSIVE)
@@ -1514,8 +1550,9 @@ void BKE_rigidbody_aftertrans_update(Object *ob, float loc[3], float rot[3], flo
 
 void BKE_rigidbody_cache_reset(RigidBodyWorld *rbw)
 {
-       if (rbw)
+       if (rbw) {
                rbw->pointcache->flag |= PTCACHE_OUTDATED;
+       }
 }
 
 /* ------------------ */
@@ -1577,6 +1614,10 @@ void BKE_rigidbody_do_simulation(Scene *scene, float ctime)
        // RB_TODO deal with interpolated, old and baked results
        bool can_simulate = (ctime == rbw->ltime + 1) && !(cache->flag & PTCACHE_BAKED);
 
+       if (cache->flag & PTCACHE_OUTDATED || cache->last_exact == 0) {
+               rbw->ltime = cache->startframe;
+       }
+
        if (BKE_ptcache_read(&pid, ctime, can_simulate)) {
                BKE_ptcache_validate(cache, (int)ctime);
                return;
index 5845a53055c9cb0e9bdd3fd0051cbf1c084f422f..35ccd385d02fe4405dbad36dda387f3422c73f0c 100644 (file)
@@ -2099,6 +2099,11 @@ static void draw_pose_bones(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *
                }
        }
        
+       /* custom bone may draw outline double-width */
+       if (arm->flag & ARM_POSEMODE) {
+               glLineWidth(1.0f);
+       }
+
        /* draw custom bone shapes as wireframes */
        if (!(arm->flag & ARM_NO_CUSTOM) &&
            (draw_wire || (dt <= OB_WIRE)) )
@@ -2164,11 +2169,6 @@ static void draw_pose_bones(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *
                        index = -1;
                }
        }
-       
-       /* custom bone may draw outline double-width */
-       if (arm->flag & ARM_POSEMODE) {
-               glLineWidth(1.0f);
-       }
 
        /* wire draw over solid only in posemode */
        if ((dt <= OB_WIRE) || (arm->flag & ARM_POSEMODE) || ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)) {
index 2b25581e2b34c3a27348d719dab2ad54a05502d6..cfc648e1fd03e08d7f9f4f108baf3bb47bc17a08 100644 (file)
@@ -5333,7 +5333,8 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
                        }
                        /* update object's loc/rot to get current rigid body transform */
                        mat4_to_loc_rot_size(ob->loc, rot, scale, ob->obmat);
-                       BKE_object_mat3_to_rot(ob, rot, false);
+                       sub_v3_v3(ob->loc, ob->dloc);
+                       BKE_object_mat3_to_rot(ob, rot, false); /* drot is already corrected here */
                }
        }
 
index cde8eef6ef39dc4f7997bf759facf0c9b58d1b73..d0dfe18d0c4588ed14557a176f6cd3fd99ebfc1d 100644 (file)
@@ -324,7 +324,7 @@ typedef struct ParticleSystem {
        struct ParticleDrawData *pdd;
 
        float dt_frac;                                                  /* current time step, as a fraction of a frame */
-       float _pad;                                                             /* spare capacity */
+       float lattice_strength;                                 /* influence of the lattice modifier */
 
        void *batch_cache;
 } ParticleSystem;