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();
                }
            }
        }
Example #2
0
 public int PickParticle(Vector3 _origin, Vector3 _direction)
 {
     return(FlexUtils.PickParticle(ref _origin, ref _direction, particleData.particles, particleData.phases, container.maxParticles, container.solidRest * 0.5f));
 }