コード例 #1
0
        public override int DrawBatch(int maxBlocksToDraw)
        {
            int count = 0;

            double fromT, toT, stepT;
            double fromU, toU, stepU;
            double fromV, toV, stepV;

            GetIterationBounds(0, out fromT, out toT, out stepT);
            GetIterationBounds(1, out fromU, out toU, out stepU);
            GetIterationBounds(2, out fromV, out toV, out stepV);

            for (double t = fromT; t <= toT; t += stepT)
            {
                for (double u = fromU; u <= toU; u += stepU)
                {
                    for (double v = fromV; v <= toV; v += stepV)
                    {
                        Coords.X = _Scaler.FromFuncResult(_Expressions[0].Evaluate(t, u, v), Bounds.XMin, Bounds.XMax);
                        Coords.Y = _Scaler.FromFuncResult(_Expressions[1].Evaluate(t, u, v), Bounds.YMin, Bounds.YMax);
                        Coords.Z = _Scaler.FromFuncResult(_Expressions[2].Evaluate(t, u, v), Bounds.ZMin, Bounds.ZMax);

                        if (DrawOneBlock())
                        {
                            ++count;
                        }

                        // if(TimeToEndBatch) {
                        //	 return count;
                        // }
                    }
                }
            }

            IsDone = true;

            return(count);
        }
コード例 #2
0
        // This method exists to box coords nicely as ref params.
        private int InternalDraw(ref int arg1, ref int arg2, ref int val, int min1, int max1, int min2, int max2, int minV, int maxV, int maxBlocksToDraw)
        {
            int exCount = 0;

            Count = 0;

            DrawFasePrepare(min1, max1, min2, max2);

            for (arg1 = min1; arg1 <= max1 && MathCommands.MaxCalculationExceptions >= exCount; ++arg1)
            {
                for (arg2 = min2; arg2 <= max2; ++arg2)
                {
                    try {
                        int fval =
                            _Scaler.FromFuncResult(
                                _Expression.Evaluate(_Scaler.ToFuncParam(arg1, min1, max1),
                                                     _Scaler.ToFuncParam(arg2, min2, max2)),
                                minV, maxV);

                        DrawFase1(fval, ref arg1, ref arg2, ref val, min1, max1, min2, max2, minV, maxV, maxBlocksToDraw);

                        // if(TimeToEndBatch) {
                        //	 return _count;
                        // }
                    } catch (Exception) {
                        // The exception here is kinda of normal, for functions(especially interesting ones)
                        // may have eg punctured points; we just have to keep an eye on the number, since producing 10000
                        // exceptions in the multiclient application is not the best idea.
                        if (++exCount > MathCommands.MaxCalculationExceptions)
                        {
                            Player.Message("Function drawing is interrupted: too many(>" +
                                           MathCommands.MaxCalculationExceptions +
                                           ") calculation exceptions.");

                            break;
                        }
                    }
                }
            }

            // The real drawing for the surface variant.
            DrawFase2(ref arg1, ref arg2, ref val, min1, max1, min2, max2, minV, maxV, maxBlocksToDraw);

            return(Count);
        }