public override Application setup(Tree target) {
			float radius = worldRadius / target.voxelSize();
			Vector3 radiusCube = new Vector3(radius, radius, radius);
			Vector3 center = target.globalToVoxelPosition(worldPosition);
			Vector3 exactMin = center - radiusCube;
			Vector3 exactMax = center + radiusCube;
			SphereApp app = new SphereApp();
			app.tree = target;
			app.min = new Index(target.maxDetail, (uint)exactMin.x, (uint)exactMin.y, (uint)exactMin.z);
			app.max = new Index(target.maxDetail, (uint)exactMax.x, (uint)exactMax.y, (uint)exactMax.z);
			app.position = center;
			app.radius = radius;
			return app;
		}
Exemple #2
0
        public override Application setup(Tree target)
        {
            float     radius     = worldRadius / target.voxelSize();
            Vector3   radiusCube = new Vector3(radius, radius, radius);
            Vector3   center     = target.globalToVoxelPosition(worldPosition);
            Vector3   exactMin   = center - radiusCube;
            Vector3   exactMax   = center + radiusCube;
            SphereApp app        = new SphereApp();

            app.tree     = target;
            app.min      = new Index(target.maxDetail, (uint)exactMin.x, (uint)exactMin.y, (uint)exactMin.z);
            app.max      = new Index(target.maxDetail, (uint)exactMax.x, (uint)exactMax.y, (uint)exactMax.z);
            app.position = center;
            app.radius   = radius;
            return(app);
        }
Exemple #3
0
        public override Voxel mutate(LocalApplication app, Index p, LocalAction action, Voxel original)
        {
            SphereApp    sApp    = (SphereApp)app;
            SphereAction sAction = (SphereAction)action;

            float dis        = Mathf.Sqrt(sAction.disSqr);
            byte  newOpacity = (dis <= sAction.minRadius) ?
                               value.averageOpacity() :
                               (byte)((original.averageOpacity() * (dis - sAction.minRadius) + value.averageOpacity() * (sAction.maxRadius - dis)) / 2);
            byte newSubstance = original.averageMaterialType();

            if (newOpacity >= 2 * original.averageOpacity() ||
                (overwriteSubstance && dis < sApp.radius))
            {
                newSubstance = value.averageMaterialType();
            }
            if (!overwriteShape)
            {
                newOpacity = original.averageOpacity();
            }
            return(new Voxel(newSubstance, newOpacity));
        }
Exemple #4
0
        public override LocalAction checkMutation(LocalApplication app, Index p, Vector3 diff, float voxelSize)
        {
            SphereApp    sApp   = (SphereApp)app;
            SphereAction action = new SphereAction();

            action.disSqr    = diff.sqrMagnitude;
            action.maxRadius = sApp.radius + voxelSize;
            float maxRadSqr = action.maxRadius * action.maxRadius;

            if (action.disSqr > maxRadSqr)
            {
                return(action);
            }
            action.modify    = true;
            action.minRadius = Mathf.Max(0, sApp.radius - voxelSize);
            float minRadSqr = action.minRadius * action.minRadius;

            if (action.disSqr >= minRadSqr)
            {
                action.doTraverse = true;
            }
            return(action);
        }