Beispiel #1
0
        public void renderCells(ssBVHNode <SSObject> n, ref SSAABB parentbox, int depth)
        {
            float nudge = 0f;

            if (parentbox.Equals(n.box))
            {
                // attempt to nudge out of z-fighting
                nudge = 0.2f;
            }

            if (highlightNodes.Contains(n))
            {
                if (n.gobjects == null)
                {
                    GL.Color4(Color.FromArgb(255, 25, 25, 100));
                }
                else
                {
                    GL.Color4(Color.Green);
                }
            }
            else
            {
                if (n.gobjects == null)
                {
                    GL.Color4(Color.FromArgb(255, 20, 20, 20));
                }
                else
                {
                    GL.Color4(Color.DarkRed);
                }
            }

            Vector3 nudgeVect = new Vector3(nudge);
            Vector3 scale     = n.box.max - n.box.min - 2f * nudgeVect;
            Matrix4 mat       = Matrix4.CreateScale(scale) * Matrix4.CreateTranslation(n.box.min + nudgeVect);

            GL.PushMatrix();
            GL.MultMatrix(ref mat);
            ibo.DrawElements(PrimitiveType.Lines, false);
            GL.PopMatrix();

            if (n.right != null)
            {
                renderCells(n.right, ref n.box, depth: depth + 1);
            }
            if (n.left != null)
            {
                renderCells(n.left, ref n.box, depth: depth + 1);
            }
        }
        internal bool refitVolume(SSBVHNodeAdaptor <GO> nAda)
        {
            if (gobjects.Count == 0)
            {
                throw new NotImplementedException();
            }                                                                  // TODO: fix this... we should never get called in this case...

            SSAABB oldbox = box;

            computeVolume(nAda);
            if (!box.Equals(oldbox))
            {
                if (parent != null)
                {
                    parent.childRefit(nAda);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }