コード例 #1
0
    public void OnWillRenderObject()
    {
        VLightInterleavedSampling.renderCount++;

        if (!VLightInterleavedSampling.renderingInterleaved)
        {
            UpdateSettings();
            UpdateViewMatrices(Camera.current);
            UpdateLightMatrices();
            if (!_renderShadowMapInUpdate)
            {
                RenderShadowMap();
            }

            _queueRenderShadowMap = true;

            MeshRender.GetPropertyBlock(PropertyBlock);
            SetShaderPropertiesBlock(PropertyBlock);
            MeshRender.SetPropertyBlock(PropertyBlock);
        }

        if (useCurves)
        {
            if (Application.isEditor)
            {
                UpdateFalloffCurve();
            }
        }
    }
コード例 #2
0
ファイル: MeshRenderGroup.cs プロジェクト: luxgile/Entygine
 public bool HasMeshRender(RenderMesh meshRender)
 {
     return(MeshRender.Equals(meshRender));
 }
コード例 #3
0
ファイル: JCTTransition.cs プロジェクト: silveryw/mcs
    /// <summary>
    /// Internal method to update the mesh on any morph changes.
    /// </summary>
    /// <remarks>this is not fully optimized even with reduced jct calculations because it gets called on ANY morph change, not specific morph changes.</remarks>
    void HotfixUpdate()
    {
        int i = 0;

        // resets everything to originals

        base_bind_poses.CopyTo(current_bind_poses, 0);
        base_bone_positions.CopyTo(current_bone_positions, 0);

        // CHANGE : lets zero all the destinations and get the current active from blendshapemodel - aka charman
        // 10% of 12 total
        var enumerator = morph_to_BS_index.GetEnumerator();

        while (enumerator.MoveNext())
        {
            string key = enumerator.Current.Key;
            morph_to_BS_float[key] = Clamp(MeshRender.GetBlendShapeWeight(morph_to_BS_index[key]) / 100.0f, 0.0f, 1.0f);
        }

        // twice as efficient, same-ish memory even without optimzied get active call, but failed likely because the names are different
        // List<CoreBlendshape> active = charman.GetActiveBlendShapes ();
        // foreach (CoreBlendshape bs in active) {
        //      morph_to_BS_float [bs.dazName] = bs.currentValue;
        // }

        // this goes through each and every local jct affected morph (112) and tries to get value out of current active blendshapes
        // this could be innefficient in ways.
        // 1) if we are local ct morh centric, we always check for 112 morphs
        // 2) if we are active morph centric, we start with a lower number but may eventually ahve more than 112 morphs
        // 3) linq functions are slow for union and itnersect, but we could loop through the active morphs and check if they are a jct morph.
        // this make every frmae slightly slower, but never completely wasteful
        // it is likely splitting hairs...
        // roughly 4% of 12 processing
        i = 0;
        for (; i < m_morphs.Length; i++)
        {
            float val = m_morphs[i].m_value;
            if (morph_to_BS_float.TryGetValue(m_morphs[i].m_name, out val))
            {
                m_morphs[i].m_value = val;
                // Debug.Log (m_morphs [i].m_name + ":" + m_morphs[i].m_value);
            }

            // we wont apply changes, we will save them and broadcast the change to listeners
            if (m_morphs[i].m_value != 0)
            {
                ApplyBindPoseChanges(m_morphs[i]);
            }
        }



        //again no application - just calculation
        MeshRender.sharedMesh.bindposes = current_bind_poses;


        bool needs_swizzle = false;

        if (subscribers != null)
        {
            foreach (SkinnedMeshRenderer ren in subscribers)
            {
                if (ren.enabled == false)
                {
                    needs_swizzle = true;
                }

                // Debug.Log (ren.name);
                indexes = SubscriberBoneMapsproxy[ren];
                // Matrix4x4[] bind_p = ren.sharedMesh.bindposes;
                i = 0;
                foreach (int index in indexes)
                {
                    if (index < 0)
                    {
                    }
                    else
                    {
                        // Debug.Log (ren.sharedMesh.bindposes [i].ToString ("F6"));
                        // Debug.Log ("--------------");
                        // Debug.Log (current_bind_poses [index].ToString ("F6"));
                        // bind_p[i] = current_bind_poses[index];
                        SubscriberBoneMaps[ren][i] = current_bind_poses[index];
                        // Debug.Log (current_bind_poses[index][13].ToString ("F6") + ":" + SubscriberBoneMaps[ren][i][13].ToString ("F6"));
                    }
                    i++;
                }

                // ren.sharedMesh.bindposes = bind_p;
                if (needs_swizzle)
                {
                    ren.enabled = true;
                }

                ren.sharedMesh.bindposes = SubscriberBoneMaps[ren];

                if (needs_swizzle)
                {
                    ren.enabled   = false;
                    needs_swizzle = false;
                }
            }
        }

        if (temp_bones == null)
        {
            temp_bones = MeshRendererBones;
        }

        i = 0;
        for (; i < base_bind_poses.Length; i++)
        {
            // mecanim will change our bones, so we need the delta between the old and new bind pose to reapply on late update
            temp_bone_position_deltas[i] = current_bone_positions[i] - base_bone_positions[i];
            // no application - just calculation
            // MeshRender.bones[i].localPosition = current_bone_positions[i]; //when applying changes to item in arrays in a unity control item, its generally better to clone the whole array, apply the changes locally, then assign the whole array
            temp_bones [i].localPosition = current_bone_positions [i];
        }

        //there's a chance there is no animator component, so do a second check
        Animator anim = charman.GetAnimatorManager();

        if (anim != null)
        {
            //if we do, tell mecanim to rerun it's update, this will trigger a re rooting of the mesh at the root pivot point (typically the feet), see animator.pivotWeight
            anim.Update(0f);
        }
    }