Пример #1
0
        void PaintFixedParticles(Rect r, bool _fix)
        {
            FlexAsset asset = target as FlexAsset;

            if (asset)
            {
                Vector2 rectPoint = Event.current.mousePosition - r.min;
                Vector2 viewPoint = new Vector2(2.0f * rectPoint.x / r.width - 1.0f, 1.0f - 2.0f * rectPoint.y / r.height);
                Camera  cam       = m_previewRender.camera;
                float   tanFOV    = Mathf.Tan(cam.fieldOfView * Mathf.Deg2Rad * 0.5f);
                Vector3 camPoint  = new Vector3(viewPoint.x * tanFOV * r.width / r.height, viewPoint.y * tanFOV, 1.0f) * cam.nearClipPlane;
                Ray     mouseRay  = new Ray(cam.transform.position, (cam.transform.TransformPoint(camPoint) - cam.transform.position).normalized);
                //Bounds bounds = asset.referenceMesh.bounds;
                //bounds.size = new Vector3(bounds.size.x * asset.meshLocalScale.x, bounds.size.y * asset.meshLocalScale.y, bounds.size.z * asset.meshLocalScale.z);
                //float radius = 0.1f;// bounds.size.magnitude * 0.5f * 0.03f;
                int node = FlexUtils.PickParticle(mouseRay, asset.particles, m_paintParticleRadius);
                if (node != -1)
                {
                    if (asset.FixedParticle(node, _fix))
                    {
                        asset.Rebuild();
                        ReleaseBuffers();
                    }
                    Event.current.Use();
                    GUI.changed = true;
                    EditorUtility.SetDirty(target);
                    HandleUtility.Repaint();
                }
            }
        }
Пример #2
0
 void ReleaseAsset()
 {
     if (m_currentAsset)
     {
         m_currentAsset.onBeforeRebuild -= OnBeforeRecreate;
         m_currentAsset.onAfterRebuild  -= OnAfterRecreate;
         m_currentAsset = null;
     }
 }
Пример #3
0
 void AcquireAsset()
 {
     if (subclassAsset)
     {
         m_currentAsset = subclassAsset;
         m_currentAsset.onBeforeRebuild += OnBeforeRecreate;
         m_currentAsset.onAfterRebuild  += OnAfterRecreate;
     }
 }
Пример #4
0
 void ReleaseAsset()
 {
     if (m_currentAsset)
     {
         m_currentAsset.onBeforeRebuild -= OnBeforeRecreate;
         m_currentAsset.onAfterRebuild  -= OnAfterRecreate;
         m_currentAsset = null;
         m_particles    = null;
         m_velocities   = null;
     }
 }
Пример #5
0
 void AcquireAsset()
 {
     if (subclassAsset)
     {
         m_currentAsset = subclassAsset;
         m_currentAsset.onBeforeRebuild += OnBeforeRecreate;
         m_currentAsset.onAfterRebuild  += OnAfterRecreate;
         m_particles  = new Vector4[m_currentAsset.particles.Length];
         m_velocities = new Vector3[m_currentAsset.particles.Length];
     }
 }