diff --git a/FastNoise.cpp b/FastNoise.cpp index 0b13532..a4c0241 100644 --- a/FastNoise.cpp +++ b/FastNoise.cpp @@ -31,26 +31,26 @@ #include #include -const float GRAD_X[] = +const FN_DECIMAL GRAD_X[] = { 1, -1, 1, -1, 1, -1, 1, -1, 0, 0, 0, 0 }; -const float GRAD_Y[] = +const FN_DECIMAL GRAD_Y[] = { 1, 1, -1, -1, 0, 0, 0, 0, 1, -1, 1, -1 }; -const float GRAD_Z[] = +const FN_DECIMAL GRAD_Z[] = { 0, 0, 0, 0, 1, 1, -1, -1, 1, 1, -1, -1 }; -const float GRAD_4D[] = +const FN_DECIMAL GRAD_4D[] = { 0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1, 0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1, @@ -62,132 +62,132 @@ const float GRAD_4D[] = -1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0 }; -const float VAL_LUT[] = -{ - 0.3490196078f, 0.4352941176f, -0.4509803922f, 0.6392156863f, 0.5843137255f, -0.1215686275f, 0.7176470588f, -0.1058823529f, 0.3960784314f, 0.0431372549f, -0.03529411765f, 0.3176470588f, 0.7254901961f, 0.137254902f, 0.8588235294f, -0.8196078431f, - -0.7960784314f, -0.3333333333f, -0.6705882353f, -0.3882352941f, 0.262745098f, 0.3254901961f, -0.6470588235f, -0.9215686275f, -0.5294117647f, 0.5294117647f, -0.4666666667f, 0.8117647059f, 0.3803921569f, 0.662745098f, 0.03529411765f, -0.6156862745f, - -0.01960784314f, -0.3568627451f, -0.09019607843f, 0.7490196078f, 0.8352941176f, -0.4039215686f, -0.7490196078f, 0.9529411765f, -0.0431372549f, -0.9294117647f, -0.6549019608f, 0.9215686275f, -0.06666666667f, -0.4431372549f, 0.4117647059f, -0.4196078431f, - -0.7176470588f, -0.8117647059f, -0.2549019608f, 0.4901960784f, 0.9137254902f, 0.7882352941f, -1.0f, -0.4745098039f, 0.7960784314f, 0.8509803922f, -0.6784313725f, 0.4588235294f, 1.0f, -0.1843137255f, 0.4509803922f, 0.1450980392f, - -0.231372549f, -0.968627451f, -0.8588235294f, 0.4274509804f, 0.003921568627f, -0.003921568627f, 0.2156862745f, 0.5058823529f, 0.7647058824f, 0.2078431373f, -0.5921568627f, 0.5764705882f, -0.1921568627f, -0.937254902f, 0.08235294118f, -0.08235294118f, - 0.9058823529f, 0.8274509804f, 0.02745098039f, -0.168627451f, -0.7803921569f, 0.1137254902f, -0.9450980392f, 0.2f, 0.01960784314f, 0.5607843137f, 0.2705882353f, 0.4431372549f, -0.9607843137f, 0.6156862745f, 0.9294117647f, -0.07450980392f, - 0.3098039216f, 0.9921568627f, -0.9137254902f, -0.2941176471f, -0.3411764706f, -0.6235294118f, -0.7647058824f, -0.8901960784f, 0.05882352941f, 0.2392156863f, 0.7333333333f, 0.6549019608f, 0.2470588235f, 0.231372549f, -0.3960784314f, -0.05098039216f, - -0.2235294118f, -0.3725490196f, 0.6235294118f, 0.7019607843f, -0.8274509804f, 0.4196078431f, 0.07450980392f, 0.8666666667f, -0.537254902f, -0.5058823529f, -0.8039215686f, 0.09019607843f, -0.4823529412f, 0.6705882353f, -0.7882352941f, 0.09803921569f, - -0.6078431373f, 0.8039215686f, -0.6f, -0.3254901961f, -0.4117647059f, -0.01176470588f, 0.4823529412f, 0.168627451f, 0.8745098039f, -0.3647058824f, -0.1607843137f, 0.568627451f, -0.9921568627f, 0.9450980392f, 0.5137254902f, 0.01176470588f, - -0.1450980392f, -0.5529411765f, -0.5764705882f, -0.1137254902f, 0.5215686275f, 0.1607843137f, 0.3725490196f, -0.2f, -0.7254901961f, 0.631372549f, 0.7098039216f, -0.568627451f, 0.1294117647f, -0.3098039216f, 0.7411764706f, -0.8509803922f, - 0.2549019608f, -0.6392156863f, -0.5607843137f, -0.3176470588f, 0.937254902f, 0.9843137255f, 0.5921568627f, 0.6941176471f, 0.2862745098f, -0.5215686275f, 0.1764705882f, 0.537254902f, -0.4901960784f, -0.4588235294f, -0.2078431373f, -0.2156862745f, - 0.7725490196f, 0.3647058824f, -0.2392156863f, 0.2784313725f, -0.8823529412f, 0.8980392157f, 0.1215686275f, 0.1058823529f, -0.8745098039f, -0.9843137255f, -0.7019607843f, 0.9607843137f, 0.2941176471f, 0.3411764706f, 0.1529411765f, 0.06666666667f, - -0.9764705882f, 0.3019607843f, 0.6470588235f, -0.5843137255f, 0.05098039216f, -0.5137254902f, -0.137254902f, 0.3882352941f, -0.262745098f, -0.3019607843f, -0.1764705882f, -0.7568627451f, 0.1843137255f, -0.5450980392f, -0.4980392157f, -0.2784313725f, - -0.9529411765f, -0.09803921569f, 0.8901960784f, -0.2862745098f, -0.3803921569f, 0.5529411765f, 0.7803921569f, -0.8352941176f, 0.6862745098f, 0.7568627451f, 0.4980392157f, -0.6862745098f, -0.8980392157f, -0.7725490196f, -0.7098039216f, -0.2470588235f, - -0.9058823529f, 0.9764705882f, 0.1921568627f, 0.8431372549f, -0.05882352941f, 0.3568627451f, 0.6078431373f, 0.5450980392f, 0.4039215686f, -0.7333333333f, -0.4274509804f, 0.6f, 0.6784313725f, -0.631372549f, -0.02745098039f, -0.1294117647f, - 0.3333333333f, -0.8431372549f, 0.2235294118f, -0.3490196078f, -0.6941176471f, 0.8823529412f, 0.4745098039f, 0.4666666667f, -0.7411764706f, -0.2705882353f, 0.968627451f, 0.8196078431f, -0.662745098f, -0.4352941176f, -0.8666666667f, -0.1529411765f, +const FN_DECIMAL VAL_LUT[] = +{ + 0.3490196078, 0.4352941176, -0.4509803922, 0.6392156863, 0.5843137255, -0.1215686275, 0.7176470588, -0.1058823529, 0.3960784314, 0.0431372549, -0.03529411765, 0.3176470588, 0.7254901961, 0.137254902, 0.8588235294, -0.8196078431, + -0.7960784314, -0.3333333333, -0.6705882353, -0.3882352941, 0.262745098, 0.3254901961, -0.6470588235, -0.9215686275, -0.5294117647, 0.5294117647, -0.4666666667, 0.8117647059, 0.3803921569, 0.662745098, 0.03529411765, -0.6156862745, + -0.01960784314, -0.3568627451, -0.09019607843, 0.7490196078, 0.8352941176, -0.4039215686, -0.7490196078, 0.9529411765, -0.0431372549, -0.9294117647, -0.6549019608, 0.9215686275, -0.06666666667, -0.4431372549, 0.4117647059, -0.4196078431, + -0.7176470588, -0.8117647059, -0.2549019608, 0.4901960784, 0.9137254902, 0.7882352941, -1.0, -0.4745098039, 0.7960784314, 0.8509803922, -0.6784313725, 0.4588235294, 1.0, -0.1843137255, 0.4509803922, 0.1450980392, + -0.231372549, -0.968627451, -0.8588235294, 0.4274509804, 0.003921568627, -0.003921568627, 0.2156862745, 0.5058823529, 0.7647058824, 0.2078431373, -0.5921568627, 0.5764705882, -0.1921568627, -0.937254902, 0.08235294118, -0.08235294118, + 0.9058823529, 0.8274509804, 0.02745098039, -0.168627451, -0.7803921569, 0.1137254902, -0.9450980392, 0.2, 0.01960784314, 0.5607843137, 0.2705882353, 0.4431372549, -0.9607843137, 0.6156862745, 0.9294117647, -0.07450980392, + 0.3098039216, 0.9921568627, -0.9137254902, -0.2941176471, -0.3411764706, -0.6235294118, -0.7647058824, -0.8901960784, 0.05882352941, 0.2392156863, 0.7333333333, 0.6549019608, 0.2470588235, 0.231372549, -0.3960784314, -0.05098039216, + -0.2235294118, -0.3725490196, 0.6235294118, 0.7019607843, -0.8274509804, 0.4196078431, 0.07450980392, 0.8666666667, -0.537254902, -0.5058823529, -0.8039215686, 0.09019607843, -0.4823529412, 0.6705882353, -0.7882352941, 0.09803921569, + -0.6078431373, 0.8039215686, -0.6, -0.3254901961, -0.4117647059, -0.01176470588, 0.4823529412, 0.168627451, 0.8745098039, -0.3647058824, -0.1607843137, 0.568627451, -0.9921568627, 0.9450980392, 0.5137254902, 0.01176470588, + -0.1450980392, -0.5529411765, -0.5764705882, -0.1137254902, 0.5215686275, 0.1607843137, 0.3725490196, -0.2, -0.7254901961, 0.631372549, 0.7098039216, -0.568627451, 0.1294117647, -0.3098039216, 0.7411764706, -0.8509803922, + 0.2549019608, -0.6392156863, -0.5607843137, -0.3176470588, 0.937254902, 0.9843137255, 0.5921568627, 0.6941176471, 0.2862745098, -0.5215686275, 0.1764705882, 0.537254902, -0.4901960784, -0.4588235294, -0.2078431373, -0.2156862745, + 0.7725490196, 0.3647058824, -0.2392156863, 0.2784313725, -0.8823529412, 0.8980392157, 0.1215686275, 0.1058823529, -0.8745098039, -0.9843137255, -0.7019607843, 0.9607843137, 0.2941176471, 0.3411764706, 0.1529411765, 0.06666666667, + -0.9764705882, 0.3019607843, 0.6470588235, -0.5843137255, 0.05098039216, -0.5137254902, -0.137254902, 0.3882352941, -0.262745098, -0.3019607843, -0.1764705882, -0.7568627451, 0.1843137255, -0.5450980392, -0.4980392157, -0.2784313725, + -0.9529411765, -0.09803921569, 0.8901960784, -0.2862745098, -0.3803921569, 0.5529411765, 0.7803921569, -0.8352941176, 0.6862745098, 0.7568627451, 0.4980392157, -0.6862745098, -0.8980392157, -0.7725490196, -0.7098039216, -0.2470588235, + -0.9058823529, 0.9764705882, 0.1921568627, 0.8431372549, -0.05882352941, 0.3568627451, 0.6078431373, 0.5450980392, 0.4039215686, -0.7333333333, -0.4274509804, 0.6, 0.6784313725, -0.631372549, -0.02745098039, -0.1294117647, + 0.3333333333, -0.8431372549, 0.2235294118, -0.3490196078, -0.6941176471, 0.8823529412, 0.4745098039, 0.4666666667, -0.7411764706, -0.2705882353, 0.968627451, 0.8196078431, -0.662745098, -0.4352941176, -0.8666666667, -0.1529411765, }; -const float CELL_2D_X[] = -{ - -0.4313539279f, -0.1733316799f, -0.2821957395f, -0.2806473808f, 0.3125508975f, 0.3383018443f, -0.4393982022f, -0.4460443703f, -0.302223039f, -0.212681052f, -0.2991156529f, 0.2293323691f, 0.4475439151f, 0.1777518f, 0.1688522499f, -0.0976597166f, - 0.08450188373f, -0.4098760448f, 0.3476585782f, -0.3350670039f, 0.2298190031f, -0.01069924099f, -0.4460141246f, 0.3650293864f, -0.349479423f, -0.4122720642f, -0.267327811f, 0.322124041f, 0.2880445931f, 0.3892170926f, 0.4492085018f, -0.4497724772f, - 0.1278175387f, -0.03572100503f, -0.4297407068f, -0.3217817723f, -0.3057158873f, -0.414503978f, -0.3738139881f, 0.2236891408f, 0.002967775577f, 0.1747128327f, -0.4423772489f, -0.2763960987f, -0.4019385906f, 0.3871414161f, -0.430008727f, -0.03037574274f, - -0.3486181573f, 0.04553517144f, -0.0375802926f, 0.3266408905f, 0.06540017593f, 0.03409025829f, -0.4449193635f, -0.4255936157f, 0.449917292f, 0.05242606404f, -0.4495305179f, -0.1204775703f, -0.341986385f, 0.3865320182f, 0.04506097811f, -0.06283465979f, - 0.3932600341f, 0.4472261803f, 0.3753571011f, -0.273662295f, 0.1700461538f, 0.4102692229f, 0.323227187f, -0.2882310238f, 0.2050972664f, 0.4414085979f, -0.1684700334f, -0.003978032396f, -0.2055133639f, -0.006095674897f, -0.1196228124f, 0.3901528491f, - 0.01723531752f, -0.3015070339f, -0.01514262423f, -0.4142574071f, -0.1916377265f, 0.3749248747f, -0.2237774255f, -0.4166343106f, 0.3619171625f, 0.1891126846f, -0.3127425077f, -0.3281807787f, -0.2294806661f, -0.3445266136f, -0.4167095422f, -0.257890321f, - -0.3612037825f, 0.2267996491f, 0.207157062f, 0.08355176718f, -0.4312233307f, 0.3257055497f, 0.177701095f, -0.445182522f, 0.3955143435f, -0.4264613988f, -0.3793799665f, 0.04617599081f, -0.371405428f, 0.2563570295f, 0.03476646309f, -0.3065454405f, - -0.2256979823f, 0.4116448463f, -0.2907745828f, 0.2842278468f, 0.3114589359f, 0.4464155859f, -0.3037334033f, 0.4079607166f, -0.3486948919f, 0.3264821436f, 0.3211142406f, 0.01183382662f, 0.4333844092f, 0.3118668416f, -0.272753471f, -0.422228622f, - -0.1009700099f, -0.2741171231f, -0.1465125133f, 0.2302279044f, -0.3699435608f, 0.105700352f, -0.2646713633f, 0.3521828122f, -0.1864187807f, 0.1994492955f, 0.3937065066f, -0.3226158377f, 0.3796235338f, 0.1482921929f, -0.407400394f, 0.4212853031f, - -0.2621297173f, -0.2536986953f, -0.2100236383f, 0.3624152444f, -0.3645038479f, 0.2318486784f, -0.3260457004f, -0.2130045332f, 0.3814998766f, -0.342977305f, -0.4355865605f, -0.2104679605f, 0.3348364681f, 0.3430468811f, -0.2291836801f, 0.2547707298f, - 0.4236174945f, -0.15387742f, -0.4407449312f, -0.06805276192f, 0.4453517192f, 0.2562464609f, 0.3278198355f, -0.4122774207f, 0.3354090914f, 0.446632869f, -0.1608953296f, -0.09463954939f, -0.02637688324f, 0.447102804f, -0.4365670908f, -0.3959858651f, - -0.4240048207f, -0.3882794568f, -0.4283652566f, 0.3303888091f, 0.3321434919f, -0.413021046f, 0.08403060337f, -0.3822882919f, -0.3712395594f, 0.4472363971f, -0.4466591209f, 0.0486272539f, -0.4203101295f, 0.2205360833f, -0.3624900666f, -0.4036086833f, - 0.2152727807f, -0.4359392962f, 0.4178354266f, 0.2007630161f, -0.07278067175f, 0.3644748615f, -0.4317451775f, -0.297436456f, -0.2998672222f, -0.2673674124f, 0.2808423357f, 0.3498946567f, -0.2229685561f, 0.3305823267f, -0.2436681211f, -0.03402776529f, - -0.319358823f, 0.4454633477f, 0.4483504221f, -0.4427358436f, 0.05452298565f, -0.2812560807f, 0.1266696921f, -0.3735981243f, 0.2959708351f, -0.3714377181f, -0.404467102f, 0.1636165687f, 0.3289185495f, -0.2494824991f, 0.03283133272f, -0.166306057f, - -0.106833179f, 0.06440260376f, -0.4483230967f, -0.421377757f, 0.05097920662f, 0.2050584153f, 0.4178098529f, -0.3565189504f, 0.4478398129f, -0.3399999602f, 0.3767121994f, -0.3138934434f, -0.1462001792f, 0.3970290489f, 0.4459149305f, -0.4104889426f, - 0.1475103971f, 0.09258030352f, -0.1589664637f, 0.2482445008f, 0.4383624232f, 0.06242802956f, 0.2846591015f, -0.344202744f, 0.1198188883f, -0.243590703f, 0.2958191174f, -0.1164007991f, 0.1274037151f, 0.368047306f, 0.2451436949f, -0.4314509715f, +const FN_DECIMAL CELL_2D_X[] = +{ + -0.4313539279, -0.1733316799, -0.2821957395, -0.2806473808, 0.3125508975, 0.3383018443, -0.4393982022, -0.4460443703, -0.302223039, -0.212681052, -0.2991156529, 0.2293323691, 0.4475439151, 0.1777518, 0.1688522499, -0.0976597166, + 0.08450188373, -0.4098760448, 0.3476585782, -0.3350670039, 0.2298190031, -0.01069924099, -0.4460141246, 0.3650293864, -0.349479423, -0.4122720642, -0.267327811, 0.322124041, 0.2880445931, 0.3892170926, 0.4492085018, -0.4497724772, + 0.1278175387, -0.03572100503, -0.4297407068, -0.3217817723, -0.3057158873, -0.414503978, -0.3738139881, 0.2236891408, 0.002967775577, 0.1747128327, -0.4423772489, -0.2763960987, -0.4019385906, 0.3871414161, -0.430008727, -0.03037574274, + -0.3486181573, 0.04553517144, -0.0375802926, 0.3266408905, 0.06540017593, 0.03409025829, -0.4449193635, -0.4255936157, 0.449917292, 0.05242606404, -0.4495305179, -0.1204775703, -0.341986385, 0.3865320182, 0.04506097811, -0.06283465979, + 0.3932600341, 0.4472261803, 0.3753571011, -0.273662295, 0.1700461538, 0.4102692229, 0.323227187, -0.2882310238, 0.2050972664, 0.4414085979, -0.1684700334, -0.003978032396, -0.2055133639, -0.006095674897, -0.1196228124, 0.3901528491, + 0.01723531752, -0.3015070339, -0.01514262423, -0.4142574071, -0.1916377265, 0.3749248747, -0.2237774255, -0.4166343106, 0.3619171625, 0.1891126846, -0.3127425077, -0.3281807787, -0.2294806661, -0.3445266136, -0.4167095422, -0.257890321, + -0.3612037825, 0.2267996491, 0.207157062, 0.08355176718, -0.4312233307, 0.3257055497, 0.177701095, -0.445182522, 0.3955143435, -0.4264613988, -0.3793799665, 0.04617599081, -0.371405428, 0.2563570295, 0.03476646309, -0.3065454405, + -0.2256979823, 0.4116448463, -0.2907745828, 0.2842278468, 0.3114589359, 0.4464155859, -0.3037334033, 0.4079607166, -0.3486948919, 0.3264821436, 0.3211142406, 0.01183382662, 0.4333844092, 0.3118668416, -0.272753471, -0.422228622, + -0.1009700099, -0.2741171231, -0.1465125133, 0.2302279044, -0.3699435608, 0.105700352, -0.2646713633, 0.3521828122, -0.1864187807, 0.1994492955, 0.3937065066, -0.3226158377, 0.3796235338, 0.1482921929, -0.407400394, 0.4212853031, + -0.2621297173, -0.2536986953, -0.2100236383, 0.3624152444, -0.3645038479, 0.2318486784, -0.3260457004, -0.2130045332, 0.3814998766, -0.342977305, -0.4355865605, -0.2104679605, 0.3348364681, 0.3430468811, -0.2291836801, 0.2547707298, + 0.4236174945, -0.15387742, -0.4407449312, -0.06805276192, 0.4453517192, 0.2562464609, 0.3278198355, -0.4122774207, 0.3354090914, 0.446632869, -0.1608953296, -0.09463954939, -0.02637688324, 0.447102804, -0.4365670908, -0.3959858651, + -0.4240048207, -0.3882794568, -0.4283652566, 0.3303888091, 0.3321434919, -0.413021046, 0.08403060337, -0.3822882919, -0.3712395594, 0.4472363971, -0.4466591209, 0.0486272539, -0.4203101295, 0.2205360833, -0.3624900666, -0.4036086833, + 0.2152727807, -0.4359392962, 0.4178354266, 0.2007630161, -0.07278067175, 0.3644748615, -0.4317451775, -0.297436456, -0.2998672222, -0.2673674124, 0.2808423357, 0.3498946567, -0.2229685561, 0.3305823267, -0.2436681211, -0.03402776529, + -0.319358823, 0.4454633477, 0.4483504221, -0.4427358436, 0.05452298565, -0.2812560807, 0.1266696921, -0.3735981243, 0.2959708351, -0.3714377181, -0.404467102, 0.1636165687, 0.3289185495, -0.2494824991, 0.03283133272, -0.166306057, + -0.106833179, 0.06440260376, -0.4483230967, -0.421377757, 0.05097920662, 0.2050584153, 0.4178098529, -0.3565189504, 0.4478398129, -0.3399999602, 0.3767121994, -0.3138934434, -0.1462001792, 0.3970290489, 0.4459149305, -0.4104889426, + 0.1475103971, 0.09258030352, -0.1589664637, 0.2482445008, 0.4383624232, 0.06242802956, 0.2846591015, -0.344202744, 0.1198188883, -0.243590703, 0.2958191174, -0.1164007991, 0.1274037151, 0.368047306, 0.2451436949, -0.4314509715, }; -const float CELL_2D_Y[] = -{ - 0.1281943404f, 0.415278375f, -0.3505218461f, 0.3517627718f, -0.3237467165f, -0.2967353402f, -0.09710417025f, -0.05953502905f, 0.3334085102f, -0.3965687458f, 0.3361990872f, 0.3871778202f, -0.04695150755f, 0.41340573f, -0.4171197882f, 0.4392750616f, - 0.4419948321f, -0.1857461384f, -0.2857157906f, -0.30038326f, -0.3868891648f, 0.449872789f, -0.05976119672f, 0.2631606867f, 0.2834856838f, 0.1803655873f, 0.3619887311f, -0.3142230135f, -0.3457315612f, -0.2258540565f, -0.02667811596f, 0.01430799601f, - -0.4314657307f, 0.4485799926f, -0.1335025276f, 0.3145735065f, 0.3302087162f, 0.1751754899f, 0.2505256519f, -0.3904653228f, -0.4499902136f, -0.4146991995f, -0.08247647938f, -0.355112935f, -0.2023496216f, -0.2293938184f, 0.1326367019f, -0.4489736231f, - 0.2845441624f, -0.4476902368f, 0.4484280562f, 0.3095250049f, -0.4452222108f, 0.448706869f, 0.06742966669f, -0.1461850686f, 0.008627302568f, 0.4469356864f, -0.02055026661f, 0.4335725488f, -0.2924813028f, 0.2304191809f, -0.447738214f, 0.4455915232f, - -0.2187385324f, -0.04988730975f, -0.2482076684f, 0.357223947f, 0.4166344988f, 0.1848760794f, -0.3130881435f, -0.3455761521f, 0.4005435199f, -0.08751256895f, 0.4172743077f, 0.4499824166f, 0.4003301853f, -0.4499587123f, -0.4338091548f, -0.2242337048f, - 0.4496698165f, 0.3340561458f, -0.4497451511f, -0.1757577897f, -0.4071547394f, 0.2488600778f, 0.3904147331f, -0.1700466149f, 0.267424695f, -0.4083336779f, 0.323561623f, 0.307891826f, 0.3870899429f, 0.2894847362f, -0.1698621719f, -0.3687717212f, - 0.2683874578f, 0.3886668486f, 0.3994821043f, -0.4421754202f, 0.1286329626f, 0.3105090899f, -0.4134275279f, 0.06566979625f, 0.2146355146f, 0.1436338239f, -0.2420141339f, -0.4476245948f, -0.2540826796f, -0.3698392535f, 0.4486549822f, 0.3294387544f, - 0.3893076172f, -0.1817925206f, -0.3434387019f, -0.348876097f, -0.3247973695f, -0.0566844308f, -0.3320331606f, 0.1899159123f, -0.2844501228f, 0.3096924441f, 0.3152548881f, 0.4498443737f, 0.1211526057f, 0.324405723f, 0.3579183483f, -0.1556373694f, - -0.4385260051f, -0.3568750521f, 0.4254810025f, -0.3866459777f, 0.2562064828f, -0.4374099171f, 0.3639355292f, 0.2801200935f, -0.4095705534f, -0.4033856449f, 0.2179339044f, 0.3137180602f, 0.2416318948f, 0.4248640083f, 0.1911149365f, 0.1581729856f, - 0.3657704353f, -0.3716678248f, 0.3979825013f, 0.2667493029f, -0.2638881295f, 0.3856762766f, 0.3101519002f, -0.3963950918f, -0.2386584257f, 0.2913186713f, 0.1129794154f, 0.3977477059f, -0.3006402163f, 0.2912367377f, -0.3872658529f, -0.3709337882f, - -0.151816397f, 0.4228731957f, 0.09079595574f, -0.444824484f, -0.06451237284f, -0.3699158705f, -0.3082761026f, -0.1803533432f, -0.3000012356f, -0.05494615882f, 0.4202531296f, 0.4399356268f, -0.4492262904f, -0.05098119915f, 0.1091291678f, 0.2137643437f, - -0.1507312575f, 0.2274622243f, -0.1378521198f, 0.305521251f, -0.3036127481f, -0.1786438231f, -0.4420846725f, 0.2373934748f, -0.2543249683f, -0.04979563372f, 0.05473234629f, -0.4473649407f, -0.1607463688f, 0.39225481f, 0.2666476169f, -0.1989975647f, - 0.3951678503f, -0.1116106179f, 0.1670735057f, 0.4027334247f, -0.4440754146f, -0.2639281632f, 0.126870413f, 0.3376855855f, 0.3355289094f, 0.3619594822f, 0.3516071423f, 0.2829730186f, 0.390877248f, 0.3053118493f, -0.3783197679f, 0.4487116125f, - 0.3170330301f, -0.06373700535f, 0.03849544189f, -0.08052932871f, 0.4466847255f, 0.3512762688f, 0.4318041097f, 0.2508474468f, -0.3389708908f, 0.254035473f, -0.1972469604f, -0.419201167f, -0.3071035458f, -0.3745109914f, 0.4488007393f, -0.4181414777f, - 0.4371346153f, -0.4453676062f, 0.03881238203f, -0.1579265206f, -0.4471030312f, -0.4005634111f, -0.167137449f, -0.2745801121f, 0.04403977727f, -0.2947881053f, 0.2461461331f, 0.3224451987f, -0.4255884251f, -0.2118205239f, -0.06049689889f, -0.1843877112f, - -0.4251360756f, 0.4403735771f, -0.4209865359f, 0.3753327428f, -0.1016778537f, 0.4456486745f, -0.3485243118f, -0.2898697484f, -0.4337550392f, 0.3783696201f, -0.3391033025f, 0.4346847754f, -0.4315881062f, 0.2589231171f, 0.3773652989f, 0.12786735f, +const FN_DECIMAL CELL_2D_Y[] = +{ + 0.1281943404, 0.415278375, -0.3505218461, 0.3517627718, -0.3237467165, -0.2967353402, -0.09710417025, -0.05953502905, 0.3334085102, -0.3965687458, 0.3361990872, 0.3871778202, -0.04695150755, 0.41340573, -0.4171197882, 0.4392750616, + 0.4419948321, -0.1857461384, -0.2857157906, -0.30038326, -0.3868891648, 0.449872789, -0.05976119672, 0.2631606867, 0.2834856838, 0.1803655873, 0.3619887311, -0.3142230135, -0.3457315612, -0.2258540565, -0.02667811596, 0.01430799601, + -0.4314657307, 0.4485799926, -0.1335025276, 0.3145735065, 0.3302087162, 0.1751754899, 0.2505256519, -0.3904653228, -0.4499902136, -0.4146991995, -0.08247647938, -0.355112935, -0.2023496216, -0.2293938184, 0.1326367019, -0.4489736231, + 0.2845441624, -0.4476902368, 0.4484280562, 0.3095250049, -0.4452222108, 0.448706869, 0.06742966669, -0.1461850686, 0.008627302568, 0.4469356864, -0.02055026661, 0.4335725488, -0.2924813028, 0.2304191809, -0.447738214, 0.4455915232, + -0.2187385324, -0.04988730975, -0.2482076684, 0.357223947, 0.4166344988, 0.1848760794, -0.3130881435, -0.3455761521, 0.4005435199, -0.08751256895, 0.4172743077, 0.4499824166, 0.4003301853, -0.4499587123, -0.4338091548, -0.2242337048, + 0.4496698165, 0.3340561458, -0.4497451511, -0.1757577897, -0.4071547394, 0.2488600778, 0.3904147331, -0.1700466149, 0.267424695, -0.4083336779, 0.323561623, 0.307891826, 0.3870899429, 0.2894847362, -0.1698621719, -0.3687717212, + 0.2683874578, 0.3886668486, 0.3994821043, -0.4421754202, 0.1286329626, 0.3105090899, -0.4134275279, 0.06566979625, 0.2146355146, 0.1436338239, -0.2420141339, -0.4476245948, -0.2540826796, -0.3698392535, 0.4486549822, 0.3294387544, + 0.3893076172, -0.1817925206, -0.3434387019, -0.348876097, -0.3247973695, -0.0566844308, -0.3320331606, 0.1899159123, -0.2844501228, 0.3096924441, 0.3152548881, 0.4498443737, 0.1211526057, 0.324405723, 0.3579183483, -0.1556373694, + -0.4385260051, -0.3568750521, 0.4254810025, -0.3866459777, 0.2562064828, -0.4374099171, 0.3639355292, 0.2801200935, -0.4095705534, -0.4033856449, 0.2179339044, 0.3137180602, 0.2416318948, 0.4248640083, 0.1911149365, 0.1581729856, + 0.3657704353, -0.3716678248, 0.3979825013, 0.2667493029, -0.2638881295, 0.3856762766, 0.3101519002, -0.3963950918, -0.2386584257, 0.2913186713, 0.1129794154, 0.3977477059, -0.3006402163, 0.2912367377, -0.3872658529, -0.3709337882, + -0.151816397, 0.4228731957, 0.09079595574, -0.444824484, -0.06451237284, -0.3699158705, -0.3082761026, -0.1803533432, -0.3000012356, -0.05494615882, 0.4202531296, 0.4399356268, -0.4492262904, -0.05098119915, 0.1091291678, 0.2137643437, + -0.1507312575, 0.2274622243, -0.1378521198, 0.305521251, -0.3036127481, -0.1786438231, -0.4420846725, 0.2373934748, -0.2543249683, -0.04979563372, 0.05473234629, -0.4473649407, -0.1607463688, 0.39225481, 0.2666476169, -0.1989975647, + 0.3951678503, -0.1116106179, 0.1670735057, 0.4027334247, -0.4440754146, -0.2639281632, 0.126870413, 0.3376855855, 0.3355289094, 0.3619594822, 0.3516071423, 0.2829730186, 0.390877248, 0.3053118493, -0.3783197679, 0.4487116125, + 0.3170330301, -0.06373700535, 0.03849544189, -0.08052932871, 0.4466847255, 0.3512762688, 0.4318041097, 0.2508474468, -0.3389708908, 0.254035473, -0.1972469604, -0.419201167, -0.3071035458, -0.3745109914, 0.4488007393, -0.4181414777, + 0.4371346153, -0.4453676062, 0.03881238203, -0.1579265206, -0.4471030312, -0.4005634111, -0.167137449, -0.2745801121, 0.04403977727, -0.2947881053, 0.2461461331, 0.3224451987, -0.4255884251, -0.2118205239, -0.06049689889, -0.1843877112, + -0.4251360756, 0.4403735771, -0.4209865359, 0.3753327428, -0.1016778537, 0.4456486745, -0.3485243118, -0.2898697484, -0.4337550392, 0.3783696201, -0.3391033025, 0.4346847754, -0.4315881062, 0.2589231171, 0.3773652989, 0.12786735, }; -const float CELL_3D_X[] = -{ - 0.1453787434f, -0.01242829687f, 0.2877979582f, -0.07732986802f, 0.1107205875f, 0.2755209141f, 0.294168941f, 0.4000921098f, -0.1697304074f, -0.1483224484f, 0.2623596946f, -0.2709003183f, -0.03516550699f, -0.1267712655f, 0.02952021915f, -0.2806854217f, - -0.171159547f, 0.2113227183f, -0.1024352839f, -0.3304249877f, 0.2091111325f, 0.344678154f, 0.1984478035f, -0.2929008603f, -0.1617332831f, -0.3582060271f, -0.1852067326f, 0.3046301062f, -0.03816768434f, -0.4084952196f, -0.02687443361f, -0.03801098351f, - 0.2371120802f, 0.4447660503f, 0.01985147278f, 0.4274339143f, -0.2072988631f, -0.3791240978f, -0.2098721267f, 0.01582798878f, -0.1888129464f, 0.1612988974f, -0.08974491322f, 0.07041229526f, -0.1082925611f, 0.2474100658f, -0.1068836661f, 0.2396452163f, - -0.3063886072f, 0.1593342891f, 0.2709690528f, -0.1519780427f, 0.1699773681f, -0.1986155616f, -0.1887482106f, 0.2659103394f, -0.08838976154f, -0.04201869311f, -0.3230334656f, 0.2612720941f, 0.385713046f, 0.07654967953f, 0.4317038818f, -0.2890436293f, - -0.2201947582f, 0.4161322773f, 0.2204718095f, -0.1040307469f, -0.1432122615f, 0.3978380468f, -0.2599274663f, 0.4032618332f, -0.08953470255f, 0.118937202f, 0.02167047076f, -0.3411343612f, 0.3162964612f, 0.2355138889f, -0.02874541518f, -0.2461455173f, - 0.04208029445f, 0.2727458746f, -0.1347522818f, 0.3829624424f, -0.3547613644f, 0.2305790207f, -0.08323845599f, 0.2993663085f, -0.2154865723f, 0.01683355354f, 0.05240429123f, 0.00940104872f, 0.3465688735f, -0.3706867948f, 0.2741169781f, 0.06413433865f, - -0.388187972f, 0.06419469312f, -0.1986120739f, -0.203203009f, -0.1389736354f, -0.06555641638f, -0.2529246486f, 0.1444476522f, -0.3643780054f, 0.4286142488f, 0.165872923f, 0.2219610524f, 0.04322940318f, -0.08481269795f, 0.1822082075f, -0.3269323334f, - -0.4080485344f, 0.2676025294f, 0.3024892441f, 0.1448494052f, 0.4198402157f, -0.3008872161f, 0.3639310428f, 0.3295806598f, 0.2776259487f, 0.4149000507f, 0.145016715f, 0.09299023471f, 0.1028907093f, 0.2683057049f, -0.4227307273f, -0.1781224702f, - 0.4390788626f, 0.2972583585f, -0.1707002821f, 0.3806686614f, -0.1751445661f, -0.2227237566f, 0.1369633021f, -0.3529503428f, -0.2590744185f, -0.3784019401f, -0.05635805671f, 0.3251428613f, -0.4190995804f, -0.3253150961f, 0.2857945863f, -0.2733604046f, - 0.219003657f, 0.3182767252f, -0.03222023115f, -0.3087780231f, -0.06487611647f, 0.3921171432f, -0.1606404506f, -0.03767771199f, 0.1394866832f, -0.4345093872f, -0.1044637494f, 0.2658727501f, 0.2051461999f, -0.266085566f, 0.07849405464f, -0.2160686338f, - -0.185779186f, 0.02492421743f, -0.120167831f, -0.02160084693f, 0.2597670064f, -0.1611553854f, -0.3278896792f, 0.2822734956f, 0.03169341113f, 0.2202613604f, 0.2933396046f, -0.3194922995f, -0.3441586045f, 0.2703645948f, 0.2298568861f, 0.09326603877f, - -0.1116165319f, 0.2172907365f, 0.1991339479f, -0.0541918155f, 0.08871336998f, 0.2787673278f, -0.322166438f, -0.4277366384f, 0.240131882f, 0.1448607981f, -0.3837065682f, -0.4382627882f, -0.37728353f, 0.1259579313f, -0.1406285511f, -0.1580694418f, - 0.2477612106f, 0.2916132853f, 0.07365265219f, -0.26126526f, -0.3721862032f, -0.3691191571f, 0.2278441737f, 0.363398169f, -0.304231482f, -0.3199312232f, 0.2874852279f, -0.1451096801f, 0.3220090754f, -0.1247400865f, -0.2829555867f, 0.1069384374f, - -0.1420661144f, -0.250548338f, 0.3265787872f, 0.07646097258f, 0.3451771584f, 0.298137964f, 0.2812250376f, 0.4390345476f, 0.2148373234f, 0.2595421179f, 0.3182823114f, -0.4089859285f, -0.2826749061f, 0.3483864637f, -0.3226415069f, 0.4330734858f, - -0.08717822568f, -0.2149678299f, -0.2687330705f, 0.2105665099f, 0.4361845915f, 0.05333333359f, -0.05986216652f, 0.3664988455f, -0.2341015558f, -0.04730947785f, -0.2391566239f, -0.1242081035f, 0.2614832715f, -0.2728794681f, 0.007892900508f, -0.01730330376f, - 0.2054835762f, -0.3231994983f, -0.2669545963f, -0.05554372779f, -0.2083935713f, 0.06989323478f, 0.3847566193f, -0.3026215288f, 0.3450735512f, 0.1814473292f, -0.03855010448f, 0.3533670318f, -0.007945601311f, 0.4063099273f, -0.2016773589f, -0.07527055435f, +const FN_DECIMAL CELL_3D_X[] = +{ + 0.1453787434, -0.01242829687, 0.2877979582, -0.07732986802, 0.1107205875, 0.2755209141, 0.294168941, 0.4000921098, -0.1697304074, -0.1483224484, 0.2623596946, -0.2709003183, -0.03516550699, -0.1267712655, 0.02952021915, -0.2806854217, + -0.171159547, 0.2113227183, -0.1024352839, -0.3304249877, 0.2091111325, 0.344678154, 0.1984478035, -0.2929008603, -0.1617332831, -0.3582060271, -0.1852067326, 0.3046301062, -0.03816768434, -0.4084952196, -0.02687443361, -0.03801098351, + 0.2371120802, 0.4447660503, 0.01985147278, 0.4274339143, -0.2072988631, -0.3791240978, -0.2098721267, 0.01582798878, -0.1888129464, 0.1612988974, -0.08974491322, 0.07041229526, -0.1082925611, 0.2474100658, -0.1068836661, 0.2396452163, + -0.3063886072, 0.1593342891, 0.2709690528, -0.1519780427, 0.1699773681, -0.1986155616, -0.1887482106, 0.2659103394, -0.08838976154, -0.04201869311, -0.3230334656, 0.2612720941, 0.385713046, 0.07654967953, 0.4317038818, -0.2890436293, + -0.2201947582, 0.4161322773, 0.2204718095, -0.1040307469, -0.1432122615, 0.3978380468, -0.2599274663, 0.4032618332, -0.08953470255, 0.118937202, 0.02167047076, -0.3411343612, 0.3162964612, 0.2355138889, -0.02874541518, -0.2461455173, + 0.04208029445, 0.2727458746, -0.1347522818, 0.3829624424, -0.3547613644, 0.2305790207, -0.08323845599, 0.2993663085, -0.2154865723, 0.01683355354, 0.05240429123, 0.00940104872, 0.3465688735, -0.3706867948, 0.2741169781, 0.06413433865, + -0.388187972, 0.06419469312, -0.1986120739, -0.203203009, -0.1389736354, -0.06555641638, -0.2529246486, 0.1444476522, -0.3643780054, 0.4286142488, 0.165872923, 0.2219610524, 0.04322940318, -0.08481269795, 0.1822082075, -0.3269323334, + -0.4080485344, 0.2676025294, 0.3024892441, 0.1448494052, 0.4198402157, -0.3008872161, 0.3639310428, 0.3295806598, 0.2776259487, 0.4149000507, 0.145016715, 0.09299023471, 0.1028907093, 0.2683057049, -0.4227307273, -0.1781224702, + 0.4390788626, 0.2972583585, -0.1707002821, 0.3806686614, -0.1751445661, -0.2227237566, 0.1369633021, -0.3529503428, -0.2590744185, -0.3784019401, -0.05635805671, 0.3251428613, -0.4190995804, -0.3253150961, 0.2857945863, -0.2733604046, + 0.219003657, 0.3182767252, -0.03222023115, -0.3087780231, -0.06487611647, 0.3921171432, -0.1606404506, -0.03767771199, 0.1394866832, -0.4345093872, -0.1044637494, 0.2658727501, 0.2051461999, -0.266085566, 0.07849405464, -0.2160686338, + -0.185779186, 0.02492421743, -0.120167831, -0.02160084693, 0.2597670064, -0.1611553854, -0.3278896792, 0.2822734956, 0.03169341113, 0.2202613604, 0.2933396046, -0.3194922995, -0.3441586045, 0.2703645948, 0.2298568861, 0.09326603877, + -0.1116165319, 0.2172907365, 0.1991339479, -0.0541918155, 0.08871336998, 0.2787673278, -0.322166438, -0.4277366384, 0.240131882, 0.1448607981, -0.3837065682, -0.4382627882, -0.37728353, 0.1259579313, -0.1406285511, -0.1580694418, + 0.2477612106, 0.2916132853, 0.07365265219, -0.26126526, -0.3721862032, -0.3691191571, 0.2278441737, 0.363398169, -0.304231482, -0.3199312232, 0.2874852279, -0.1451096801, 0.3220090754, -0.1247400865, -0.2829555867, 0.1069384374, + -0.1420661144, -0.250548338, 0.3265787872, 0.07646097258, 0.3451771584, 0.298137964, 0.2812250376, 0.4390345476, 0.2148373234, 0.2595421179, 0.3182823114, -0.4089859285, -0.2826749061, 0.3483864637, -0.3226415069, 0.4330734858, + -0.08717822568, -0.2149678299, -0.2687330705, 0.2105665099, 0.4361845915, 0.05333333359, -0.05986216652, 0.3664988455, -0.2341015558, -0.04730947785, -0.2391566239, -0.1242081035, 0.2614832715, -0.2728794681, 0.007892900508, -0.01730330376, + 0.2054835762, -0.3231994983, -0.2669545963, -0.05554372779, -0.2083935713, 0.06989323478, 0.3847566193, -0.3026215288, 0.3450735512, 0.1814473292, -0.03855010448, 0.3533670318, -0.007945601311, 0.4063099273, -0.2016773589, -0.07527055435, }; -const float CELL_3D_Y[] = -{ - -0.4149781685f, -0.1457918398f, -0.02606483451f, 0.2377094325f, -0.3552302079f, 0.2640521179f, 0.1526064594f, -0.2034056362f, 0.3970864695f, -0.3859694688f, -0.2354852944f, 0.3505271138f, 0.3885234328f, 0.1920044036f, 0.4409685861f, -0.266996757f, - 0.2141185563f, 0.3902405947f, 0.2128044156f, -0.1566986703f, 0.3133278055f, -0.1944240454f, -0.3214342325f, 0.2262915116f, 0.006314769776f, -0.148303178f, -0.3454119342f, 0.1026310383f, -0.2551766358f, 0.1805950793f, -0.2749741471f, 0.3277859044f, - 0.2900386767f, 0.03946930643f, -0.01503183293f, 0.03345994256f, 0.2871414597f, 0.1281177671f, -0.1007087278f, 0.4263894424f, -0.3160996813f, -0.1974805082f, 0.229148752f, 0.4150230285f, -0.1586061639f, -0.3309414609f, -0.2701644537f, 0.06803600538f, - 0.2597428179f, -0.3114350249f, 0.1412648683f, 0.3623355133f, 0.3456012883f, 0.3836276443f, -0.2050154888f, 0.3015631259f, -0.4288819642f, 0.3099592485f, 0.201549922f, 0.2759854499f, 0.2193460345f, 0.3721732183f, -0.02577753072f, -0.3418179959f, - 0.383023377f, -0.1669634289f, 0.02654238946f, 0.3890079625f, 0.371614387f, -0.06206669342f, 0.2616724959f, -0.1124593585f, -0.3048244735f, -0.2875221847f, -0.03284630549f, 0.2500031105f, 0.3082064153f, -0.3439334267f, -0.3955933019f, 0.02020282325f, - -0.4470439576f, 0.2288471896f, -0.02720848277f, 0.1231931484f, 0.1271702173f, 0.3063895591f, -0.1922245118f, -0.2619918095f, 0.2706747713f, -0.2680655787f, 0.4335128183f, -0.4472890582f, 0.01141914583f, -0.2551104378f, 0.2139972417f, 0.1708718512f, - -0.03973280434f, -0.2803682491f, -0.3391173584f, -0.3871641506f, -0.2775901578f, 0.342253257f, -0.2904227915f, 0.1069184044f, -0.2447099973f, -0.1358496089f, -0.3136808464f, -0.3658139958f, -0.3832730794f, -0.4404869674f, -0.3953259299f, 0.3036542563f, - 0.04227858267f, -0.01299671652f, -0.1009990293f, 0.425921681f, 0.08062320474f, -0.333040905f, -0.1291284382f, 0.0184175994f, -0.2974929052f, -0.144793182f, -0.0398992945f, -0.299732164f, -0.361266869f, -0.07076041213f, -0.07933161816f, 0.1806857196f, - -0.02841848598f, 0.2382799621f, 0.2215845691f, 0.1471852559f, -0.274887877f, -0.2316778837f, 0.1341343041f, -0.2472893463f, -0.2985577559f, 0.2199816631f, 0.1485737441f, 0.09666046873f, 0.1406751354f, -0.3080335042f, -0.05796152095f, 0.1973770973f, - 0.2410037886f, -0.271342949f, -0.3331161506f, 0.1992794134f, -0.4311322747f, -0.06294284106f, -0.358928121f, -0.2290351443f, -0.3602213994f, 0.005751117145f, 0.4168128432f, 0.2551943237f, 0.1975390727f, 0.23483312f, -0.3300346342f, 0.05376451292f, - 0.2148499206f, -0.3229954284f, 0.4017266681f, -0.06885389554f, 0.3096300784f, -0.09823036005f, 0.1461670309f, 0.03754421121f, 0.347405252f, -0.3460788041f, 0.3031973659f, 0.2453752201f, -0.1698856132f, -0.3574277231f, 0.3744156221f, -0.3170108894f, - -0.2985018719f, -0.3460005203f, 0.3820341668f, -0.2103145071f, 0.2012117383f, 0.3505404674f, 0.3067213525f, 0.132066775f, -0.1612516055f, -0.2387819045f, -0.2206398454f, -0.09082753406f, 0.05445141085f, 0.348394558f, -0.270877371f, 0.4162931958f, - -0.2927867412f, 0.3312535401f, -0.1666159848f, -0.2422237692f, 0.252790166f, -0.255281188f, -0.3358364886f, -0.2310190248f, -0.2698452035f, 0.316332536f, 0.1642275508f, 0.3277541114f, 0.0511344108f, -0.04333605335f, -0.3056190617f, 0.3491024667f, - -0.3055376754f, 0.3156466809f, 0.1871229129f, -0.3026690852f, 0.2757120714f, 0.2852657134f, 0.3466716415f, -0.09790429955f, 0.1850172527f, -0.07946825393f, -0.307355516f, -0.04647718411f, 0.07417482322f, 0.225442246f, -0.1420585388f, -0.118868561f, - -0.3909896417f, 0.3939973956f, 0.322686276f, -0.1961317136f, -0.1105517485f, -0.313639498f, 0.1361029153f, 0.2550543014f, -0.182405731f, -0.4222150243f, -0.2577696514f, 0.4256953395f, -0.3650179274f, -0.3499628774f, -0.1672771315f, 0.2978486637f, - -0.3252600376f, 0.1564282844f, 0.2599343665f, 0.3170813944f, -0.310922837f, -0.3156141536f, -0.1605309138f, -0.3001537679f, 0.08611519592f, -0.2788782453f, 0.09795110726f, 0.2665752752f, 0.140359426f, -0.1491768253f, 0.008816271194f, -0.425643481f, +const FN_DECIMAL CELL_3D_Y[] = +{ + -0.4149781685, -0.1457918398, -0.02606483451, 0.2377094325, -0.3552302079, 0.2640521179, 0.1526064594, -0.2034056362, 0.3970864695, -0.3859694688, -0.2354852944, 0.3505271138, 0.3885234328, 0.1920044036, 0.4409685861, -0.266996757, + 0.2141185563, 0.3902405947, 0.2128044156, -0.1566986703, 0.3133278055, -0.1944240454, -0.3214342325, 0.2262915116, 0.006314769776, -0.148303178, -0.3454119342, 0.1026310383, -0.2551766358, 0.1805950793, -0.2749741471, 0.3277859044, + 0.2900386767, 0.03946930643, -0.01503183293, 0.03345994256, 0.2871414597, 0.1281177671, -0.1007087278, 0.4263894424, -0.3160996813, -0.1974805082, 0.229148752, 0.4150230285, -0.1586061639, -0.3309414609, -0.2701644537, 0.06803600538, + 0.2597428179, -0.3114350249, 0.1412648683, 0.3623355133, 0.3456012883, 0.3836276443, -0.2050154888, 0.3015631259, -0.4288819642, 0.3099592485, 0.201549922, 0.2759854499, 0.2193460345, 0.3721732183, -0.02577753072, -0.3418179959, + 0.383023377, -0.1669634289, 0.02654238946, 0.3890079625, 0.371614387, -0.06206669342, 0.2616724959, -0.1124593585, -0.3048244735, -0.2875221847, -0.03284630549, 0.2500031105, 0.3082064153, -0.3439334267, -0.3955933019, 0.02020282325, + -0.4470439576, 0.2288471896, -0.02720848277, 0.1231931484, 0.1271702173, 0.3063895591, -0.1922245118, -0.2619918095, 0.2706747713, -0.2680655787, 0.4335128183, -0.4472890582, 0.01141914583, -0.2551104378, 0.2139972417, 0.1708718512, + -0.03973280434, -0.2803682491, -0.3391173584, -0.3871641506, -0.2775901578, 0.342253257, -0.2904227915, 0.1069184044, -0.2447099973, -0.1358496089, -0.3136808464, -0.3658139958, -0.3832730794, -0.4404869674, -0.3953259299, 0.3036542563, + 0.04227858267, -0.01299671652, -0.1009990293, 0.425921681, 0.08062320474, -0.333040905, -0.1291284382, 0.0184175994, -0.2974929052, -0.144793182, -0.0398992945, -0.299732164, -0.361266869, -0.07076041213, -0.07933161816, 0.1806857196, + -0.02841848598, 0.2382799621, 0.2215845691, 0.1471852559, -0.274887877, -0.2316778837, 0.1341343041, -0.2472893463, -0.2985577559, 0.2199816631, 0.1485737441, 0.09666046873, 0.1406751354, -0.3080335042, -0.05796152095, 0.1973770973, + 0.2410037886, -0.271342949, -0.3331161506, 0.1992794134, -0.4311322747, -0.06294284106, -0.358928121, -0.2290351443, -0.3602213994, 0.005751117145, 0.4168128432, 0.2551943237, 0.1975390727, 0.23483312, -0.3300346342, 0.05376451292, + 0.2148499206, -0.3229954284, 0.4017266681, -0.06885389554, 0.3096300784, -0.09823036005, 0.1461670309, 0.03754421121, 0.347405252, -0.3460788041, 0.3031973659, 0.2453752201, -0.1698856132, -0.3574277231, 0.3744156221, -0.3170108894, + -0.2985018719, -0.3460005203, 0.3820341668, -0.2103145071, 0.2012117383, 0.3505404674, 0.3067213525, 0.132066775, -0.1612516055, -0.2387819045, -0.2206398454, -0.09082753406, 0.05445141085, 0.348394558, -0.270877371, 0.4162931958, + -0.2927867412, 0.3312535401, -0.1666159848, -0.2422237692, 0.252790166, -0.255281188, -0.3358364886, -0.2310190248, -0.2698452035, 0.316332536, 0.1642275508, 0.3277541114, 0.0511344108, -0.04333605335, -0.3056190617, 0.3491024667, + -0.3055376754, 0.3156466809, 0.1871229129, -0.3026690852, 0.2757120714, 0.2852657134, 0.3466716415, -0.09790429955, 0.1850172527, -0.07946825393, -0.307355516, -0.04647718411, 0.07417482322, 0.225442246, -0.1420585388, -0.118868561, + -0.3909896417, 0.3939973956, 0.322686276, -0.1961317136, -0.1105517485, -0.313639498, 0.1361029153, 0.2550543014, -0.182405731, -0.4222150243, -0.2577696514, 0.4256953395, -0.3650179274, -0.3499628774, -0.1672771315, 0.2978486637, + -0.3252600376, 0.1564282844, 0.2599343665, 0.3170813944, -0.310922837, -0.3156141536, -0.1605309138, -0.3001537679, 0.08611519592, -0.2788782453, 0.09795110726, 0.2665752752, 0.140359426, -0.1491768253, 0.008816271194, -0.425643481, }; -const float CELL_3D_Z[] = -{ - -0.0956981749f, -0.4255470325f, -0.3449535616f, 0.3741848704f, -0.2530858567f, -0.238463215f, 0.3044271714f, 0.03244149937f, -0.1265461359f, 0.1775613147f, 0.2796677792f, -0.07901746678f, 0.2243054374f, 0.3867342179f, 0.08470692262f, 0.2289725438f, - 0.3568720405f, -0.07453178509f, -0.3830421561f, 0.2622305365f, -0.2461670583f, -0.2142341261f, -0.2445373252f, 0.2559320961f, -0.4198838754f, -0.2284613961f, -0.2211087107f, 0.314908508f, -0.3686842991f, 0.05492788837f, 0.3551999201f, 0.3059600725f, - -0.2493099024f, 0.05590469027f, -0.4493105419f, -0.1366772882f, -0.2776273824f, 0.2057929936f, -0.3851122467f, 0.1429738373f, -0.2587096108f, -0.3707885038f, -0.3767448739f, -0.1590534329f, 0.4069604477f, 0.1782302128f, -0.3436379634f, -0.3747549496f, - 0.2028785103f, -0.2830561951f, -0.3303331794f, 0.2193527988f, 0.2327390037f, -0.1260225743f, -0.353330953f, -0.2021172246f, -0.1036702021f, 0.3235115047f, -0.2398478873f, -0.2409749453f, 0.07491837764f, 0.241095919f, 0.1243675091f, -0.04598084447f, - -0.08548310451f, -0.03817251927f, -0.391391981f, -0.2008741118f, -0.2095065525f, 0.2009293758f, -0.2578084893f, 0.1650235939f, 0.3186935478f, 0.325092195f, -0.4482761547f, 0.1537068389f, -0.08640228117f, -0.1695376245f, 0.2125550295f, -0.3761704803f, - 0.02968078139f, -0.2752065618f, -0.4284874806f, -0.2016512234f, 0.2459107769f, 0.2354968222f, 0.3982726409f, -0.2103333191f, 0.287751117f, -0.3610505186f, -0.1087217856f, 0.04841609928f, -0.2868093776f, 0.003156692623f, -0.2855959784f, 0.4113266307f, - -0.2241236325f, 0.3460819069f, 0.2192091725f, 0.1063600375f, -0.3257760473f, -0.2847192729f, 0.2327739768f, 0.4125570634f, -0.09922543227f, -0.01829506817f, -0.2767498872f, 0.1393320198f, 0.2318037215f, -0.03574965489f, 0.1140946023f, 0.05838957105f, - -0.184956522f, 0.36155217f, -0.3174892964f, -0.0104580805f, 0.1404780841f, -0.03241355801f, -0.2310412139f, -0.3058388149f, -0.1921504723f, -0.09691688386f, 0.4241205002f, -0.3225111565f, 0.247789732f, -0.3542668666f, -0.1323073187f, -0.3716517945f, - -0.09435116353f, -0.2394997452f, 0.3525077196f, -0.1895464869f, 0.3102596268f, 0.3149912482f, -0.4071228836f, -0.129514612f, -0.2150435121f, -0.1044989934f, 0.4210102279f, -0.2957006485f, -0.08405978803f, -0.04225456877f, 0.3427271751f, -0.2980207554f, - -0.3105713639f, 0.1660509868f, -0.300824678f, -0.2596995338f, 0.1114273361f, -0.2116183942f, -0.2187812825f, 0.3855169162f, 0.2308332918f, 0.1169124335f, -0.1336202785f, 0.2582393035f, 0.3484154868f, 0.2766800993f, -0.2956616708f, -0.3910546287f, - 0.3490352499f, -0.3123343347f, 0.1633259825f, 0.4441762538f, 0.1978643903f, 0.4085091653f, 0.2713366126f, -0.3484423997f, -0.2842624114f, -0.1849713341f, 0.1565989581f, -0.200538455f, -0.2349334659f, 0.04060059933f, 0.0973588921f, 0.3054595587f, - 0.3177080142f, -0.1885958001f, -0.1299829458f, 0.39412061f, 0.3926114802f, 0.04370535101f, 0.06804996813f, 0.04582286686f, 0.344723946f, 0.3528435224f, 0.08116235683f, -0.04664855374f, 0.2391488697f, 0.2554522098f, -0.3306796947f, -0.06491553533f, - -0.2353514536f, 0.08793624968f, 0.411478311f, 0.2748965434f, 0.008634938242f, 0.03290232422f, 0.1944244981f, 0.1306597909f, 0.1926830856f, -0.008816977938f, -0.304764754f, -0.2720669462f, 0.3101538769f, -0.4301882115f, -0.1703910946f, -0.2630430352f, - -0.2982682484f, -0.2002316239f, 0.2466400438f, 0.324106687f, -0.0856480183f, 0.179547284f, 0.05684409612f, -0.01278335452f, 0.3494474791f, 0.3589187731f, -0.08203022006f, 0.1818526372f, 0.3421885344f, -0.1740766085f, -0.2796816575f, -0.02859407492f, - -0.2050050172f, -0.03247898316f, -0.1617284888f, -0.3459683451f, 0.004616608544f, -0.3182543336f, -0.4247264031f, -0.05590974511f, 0.3382670703f, -0.1483114513f, -0.2808182972f, -0.07652336246f, 0.02980623099f, 0.07458404908f, 0.4176793787f, -0.3368779738f, - -0.2334146693f, -0.2712420987f, -0.2523278991f, -0.3144428146f, -0.2497981362f, 0.3130537363f, -0.1693876312f, -0.1443188342f, 0.2756962409f, -0.3029914042f, 0.4375151083f, 0.08105160988f, -0.4274764309f, -0.1231199324f, -0.4021797064f, -0.1251477955f, +const FN_DECIMAL CELL_3D_Z[] = +{ + -0.0956981749, -0.4255470325, -0.3449535616, 0.3741848704, -0.2530858567, -0.238463215, 0.3044271714, 0.03244149937, -0.1265461359, 0.1775613147, 0.2796677792, -0.07901746678, 0.2243054374, 0.3867342179, 0.08470692262, 0.2289725438, + 0.3568720405, -0.07453178509, -0.3830421561, 0.2622305365, -0.2461670583, -0.2142341261, -0.2445373252, 0.2559320961, -0.4198838754, -0.2284613961, -0.2211087107, 0.314908508, -0.3686842991, 0.05492788837, 0.3551999201, 0.3059600725, + -0.2493099024, 0.05590469027, -0.4493105419, -0.1366772882, -0.2776273824, 0.2057929936, -0.3851122467, 0.1429738373, -0.2587096108, -0.3707885038, -0.3767448739, -0.1590534329, 0.4069604477, 0.1782302128, -0.3436379634, -0.3747549496, + 0.2028785103, -0.2830561951, -0.3303331794, 0.2193527988, 0.2327390037, -0.1260225743, -0.353330953, -0.2021172246, -0.1036702021, 0.3235115047, -0.2398478873, -0.2409749453, 0.07491837764, 0.241095919, 0.1243675091, -0.04598084447, + -0.08548310451, -0.03817251927, -0.391391981, -0.2008741118, -0.2095065525, 0.2009293758, -0.2578084893, 0.1650235939, 0.3186935478, 0.325092195, -0.4482761547, 0.1537068389, -0.08640228117, -0.1695376245, 0.2125550295, -0.3761704803, + 0.02968078139, -0.2752065618, -0.4284874806, -0.2016512234, 0.2459107769, 0.2354968222, 0.3982726409, -0.2103333191, 0.287751117, -0.3610505186, -0.1087217856, 0.04841609928, -0.2868093776, 0.003156692623, -0.2855959784, 0.4113266307, + -0.2241236325, 0.3460819069, 0.2192091725, 0.1063600375, -0.3257760473, -0.2847192729, 0.2327739768, 0.4125570634, -0.09922543227, -0.01829506817, -0.2767498872, 0.1393320198, 0.2318037215, -0.03574965489, 0.1140946023, 0.05838957105, + -0.184956522, 0.36155217, -0.3174892964, -0.0104580805, 0.1404780841, -0.03241355801, -0.2310412139, -0.3058388149, -0.1921504723, -0.09691688386, 0.4241205002, -0.3225111565, 0.247789732, -0.3542668666, -0.1323073187, -0.3716517945, + -0.09435116353, -0.2394997452, 0.3525077196, -0.1895464869, 0.3102596268, 0.3149912482, -0.4071228836, -0.129514612, -0.2150435121, -0.1044989934, 0.4210102279, -0.2957006485, -0.08405978803, -0.04225456877, 0.3427271751, -0.2980207554, + -0.3105713639, 0.1660509868, -0.300824678, -0.2596995338, 0.1114273361, -0.2116183942, -0.2187812825, 0.3855169162, 0.2308332918, 0.1169124335, -0.1336202785, 0.2582393035, 0.3484154868, 0.2766800993, -0.2956616708, -0.3910546287, + 0.3490352499, -0.3123343347, 0.1633259825, 0.4441762538, 0.1978643903, 0.4085091653, 0.2713366126, -0.3484423997, -0.2842624114, -0.1849713341, 0.1565989581, -0.200538455, -0.2349334659, 0.04060059933, 0.0973588921, 0.3054595587, + 0.3177080142, -0.1885958001, -0.1299829458, 0.39412061, 0.3926114802, 0.04370535101, 0.06804996813, 0.04582286686, 0.344723946, 0.3528435224, 0.08116235683, -0.04664855374, 0.2391488697, 0.2554522098, -0.3306796947, -0.06491553533, + -0.2353514536, 0.08793624968, 0.411478311, 0.2748965434, 0.008634938242, 0.03290232422, 0.1944244981, 0.1306597909, 0.1926830856, -0.008816977938, -0.304764754, -0.2720669462, 0.3101538769, -0.4301882115, -0.1703910946, -0.2630430352, + -0.2982682484, -0.2002316239, 0.2466400438, 0.324106687, -0.0856480183, 0.179547284, 0.05684409612, -0.01278335452, 0.3494474791, 0.3589187731, -0.08203022006, 0.1818526372, 0.3421885344, -0.1740766085, -0.2796816575, -0.02859407492, + -0.2050050172, -0.03247898316, -0.1617284888, -0.3459683451, 0.004616608544, -0.3182543336, -0.4247264031, -0.05590974511, 0.3382670703, -0.1483114513, -0.2808182972, -0.07652336246, 0.02980623099, 0.07458404908, 0.4176793787, -0.3368779738, + -0.2334146693, -0.2712420987, -0.2523278991, -0.3144428146, -0.2497981362, 0.3130537363, -0.1693876312, -0.1443188342, 0.2756962409, -0.3029914042, 0.4375151083, 0.08105160988, -0.4274764309, -0.1231199324, -0.4021797064, -0.1251477955, }; -static int FastFloor(float f) { return (f >= 0.0f ? (int)f : (int)f - 1); } -static int FastRound(float f) { return (f >= 0.0f) ? (int)(f + 0.5f) : (int)(f - 0.5f); } -static float FastAbs(float f) { return fabsf(f); } +static int FastFloor(FN_DECIMAL f) { return (f >= 0 ? (int)f : (int)f - 1); } +static int FastRound(FN_DECIMAL f) { return (f >= 0) ? (int)(f + FN_DECIMAL(0.5)) : (int)(f - FN_DECIMAL(0.5)); } static int FastAbs(int i) { return abs(i); } -static float Lerp(float a, float b, float t) { return a + t * (b - a); } -static float InterpHermiteFunc(float t) { return t*t*(3 - 2 * t); } -static float InterpQuinticFunc(float t) { return t*t*t*(t*(t * 6 - 15) + 10); } -static float CubicLerp(float a, float b, float c, float d, float t) +static FN_DECIMAL FastAbs(FN_DECIMAL f) { return fabs(f); } +static FN_DECIMAL Lerp(FN_DECIMAL a, FN_DECIMAL b, FN_DECIMAL t) { return a + t * (b - a); } +static FN_DECIMAL InterpHermiteFunc(FN_DECIMAL t) { return t*t*(3 - 2 * t); } +static FN_DECIMAL InterpQuinticFunc(FN_DECIMAL t) { return t*t*t*(t*(t * 6 - 15) + 10); } +static FN_DECIMAL CubicLerp(FN_DECIMAL a, FN_DECIMAL b, FN_DECIMAL c, FN_DECIMAL d, FN_DECIMAL t) { - float p = (d - c) - (a - b); + FN_DECIMAL p = (d - c) - (a - b); return t * t * t * p + t * t * ((a - b) - p) + t * (c - a) + b; } void FastNoise::SetSeed(int seed) @@ -241,24 +241,24 @@ unsigned char FastNoise::Index4D_256(unsigned char offset, int x, int y, int z, #define Z_PRIME 6971 #define W_PRIME 1013 -static float ValCoord2D(int seed, int x, int y) +static FN_DECIMAL ValCoord2D(int seed, int x, int y) { int n = seed; n ^= X_PRIME * x; n ^= Y_PRIME * y; - return (n * n * n * 60493) / 2147483648.f; + return (n * n * n * 60493) / FN_DECIMAL(2147483648); } -static float ValCoord3D(int seed, int x, int y, int z) +static FN_DECIMAL ValCoord3D(int seed, int x, int y, int z) { int n = seed; n ^= X_PRIME * x; n ^= Y_PRIME * y; n ^= Z_PRIME * z; - return (n * n * n * 60493) / 2147483648.f; + return (n * n * n * 60493) / FN_DECIMAL(2147483648); } -static float ValCoord4D(int seed, int x, int y, int z, int w) +static FN_DECIMAL ValCoord4D(int seed, int x, int y, int z, int w) { int n = seed; n ^= X_PRIME * x; @@ -266,38 +266,38 @@ static float ValCoord4D(int seed, int x, int y, int z, int w) n ^= Z_PRIME * z; n ^= W_PRIME * w; - return (n * n * n * 60493) / 2147483648.f; + return (n * n * n * 60493) / FN_DECIMAL(2147483648); } -float FastNoise::ValCoord2DFast(unsigned char offset, int x, int y) +FN_DECIMAL FastNoise::ValCoord2DFast(unsigned char offset, int x, int y) { return VAL_LUT[Index2D_256(offset, x, y)]; } -float FastNoise::ValCoord3DFast(unsigned char offset, int x, int y, int z) +FN_DECIMAL FastNoise::ValCoord3DFast(unsigned char offset, int x, int y, int z) { return VAL_LUT[Index3D_256(offset, x, y, z)]; } -float FastNoise::GradCoord2D(unsigned char offset, int x, int y, float xd, float yd) +FN_DECIMAL FastNoise::GradCoord2D(unsigned char offset, int x, int y, FN_DECIMAL xd, FN_DECIMAL yd) { unsigned char lutPos = Index2D_12(offset, x, y); return xd*GRAD_X[lutPos] + yd*GRAD_Y[lutPos]; } -float FastNoise::GradCoord3D(unsigned char offset, int x, int y, int z, float xd, float yd, float zd) +FN_DECIMAL FastNoise::GradCoord3D(unsigned char offset, int x, int y, int z, FN_DECIMAL xd, FN_DECIMAL yd, FN_DECIMAL zd) { unsigned char lutPos = Index3D_12(offset, x, y, z); return xd*GRAD_X[lutPos] + yd*GRAD_Y[lutPos] + zd*GRAD_Z[lutPos]; } -float FastNoise::GradCoord4D(unsigned char offset, int x, int y, int z, int w, float xd, float yd, float zd, float wd) +FN_DECIMAL FastNoise::GradCoord4D(unsigned char offset, int x, int y, int z, int w, FN_DECIMAL xd, FN_DECIMAL yd, FN_DECIMAL zd, FN_DECIMAL wd) { unsigned char lutPos = Index4D_32(offset, x, y, z, w) << 2; return xd*GRAD_4D[lutPos] + yd*GRAD_4D[lutPos + 1] + zd*GRAD_4D[lutPos + 2] + wd*GRAD_4D[lutPos + 3]; } -float FastNoise::GetNoise(float x, float y, float z) +FN_DECIMAL FastNoise::GetNoise(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { x *= m_frequency; y *= m_frequency; @@ -317,7 +317,7 @@ float FastNoise::GetNoise(float x, float y, float z) case RigidMulti: return SingleValueFractalRigidMulti(x, y, z); default: - return 0.0f; + return 0; } case Perlin: return SinglePerlin(0, x, y, z); @@ -331,7 +331,7 @@ float FastNoise::GetNoise(float x, float y, float z) case RigidMulti: return SinglePerlinFractalRigidMulti(x, y, z); default: - return 0.0f; + return 0; } case Simplex: return SingleSimplex(0, x, y, z); @@ -345,7 +345,7 @@ float FastNoise::GetNoise(float x, float y, float z) case RigidMulti: return SingleSimplexFractalRigidMulti(x, y, z); default: - return 0.0f; + return 0; } case Cellular: switch (m_cellularReturnType) @@ -372,11 +372,11 @@ float FastNoise::GetNoise(float x, float y, float z) return SingleCubicFractalRigidMulti(x, y, z); } default: - return 0.0f; + return 0; } } -float FastNoise::GetNoise(float x, float y) +FN_DECIMAL FastNoise::GetNoise(FN_DECIMAL x, FN_DECIMAL y) { x *= m_frequency; y *= m_frequency; @@ -444,11 +444,11 @@ float FastNoise::GetNoise(float x, float y) return SingleCubicFractalRigidMulti(x, y); } } - return 0.0f; + return 0; } // White Noise -float FastNoise::GetWhiteNoise(float x, float y, float z, float w) +FN_DECIMAL FastNoise::GetWhiteNoise(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z, FN_DECIMAL w) { return ValCoord4D(m_seed, *reinterpret_cast(&x) ^ (*reinterpret_cast(&x) >> 16), @@ -457,7 +457,7 @@ float FastNoise::GetWhiteNoise(float x, float y, float z, float w) *reinterpret_cast(&w) ^ (*reinterpret_cast(&w) >> 16)); } -float FastNoise::GetWhiteNoise(float x, float y, float z) +FN_DECIMAL FastNoise::GetWhiteNoise(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { return ValCoord3D(m_seed, *reinterpret_cast(&x) ^ (*reinterpret_cast(&x) >> 16), @@ -465,30 +465,30 @@ float FastNoise::GetWhiteNoise(float x, float y, float z) *reinterpret_cast(&z) ^ (*reinterpret_cast(&z) >> 16)); } -float FastNoise::GetWhiteNoise(float x, float y) +FN_DECIMAL FastNoise::GetWhiteNoise(FN_DECIMAL x, FN_DECIMAL y) { return ValCoord2D(m_seed, *reinterpret_cast(&x) ^ (*reinterpret_cast(&x) >> 16), *reinterpret_cast(&y) ^ (*reinterpret_cast(&y) >> 16)); } -float FastNoise::GetWhiteNoiseInt(int x, int y, int z, int w) +FN_DECIMAL FastNoise::GetWhiteNoiseInt(int x, int y, int z, int w) { return ValCoord4D(m_seed, x, y, z, w); } -float FastNoise::GetWhiteNoiseInt(int x, int y, int z) +FN_DECIMAL FastNoise::GetWhiteNoiseInt(int x, int y, int z) { return ValCoord3D(m_seed, x, y, z); } -float FastNoise::GetWhiteNoiseInt(int x, int y) +FN_DECIMAL FastNoise::GetWhiteNoiseInt(int x, int y) { return ValCoord2D(m_seed, x, y); } // Value Noise -float FastNoise::GetValueFractal(float x, float y, float z) +FN_DECIMAL FastNoise::GetValueFractal(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { x *= m_frequency; y *= m_frequency; @@ -503,14 +503,14 @@ float FastNoise::GetValueFractal(float x, float y, float z) case RigidMulti: return SingleValueFractalRigidMulti(x, y, z); default: - return 0.0f; + return 0; } } -float FastNoise::SingleValueFractalFBM(float x, float y, float z) +FN_DECIMAL FastNoise::SingleValueFractalFBM(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { - float sum = SingleValue(m_perm[0], x, y, z); - float amp = 1.0f; + FN_DECIMAL sum = SingleValue(m_perm[0], x, y, z); + FN_DECIMAL amp = 1; int i = 0; while (++i < m_octaves) @@ -526,10 +526,10 @@ float FastNoise::SingleValueFractalFBM(float x, float y, float z) return sum * m_fractalBounding; } -float FastNoise::SingleValueFractalBillow(float x, float y, float z) +FN_DECIMAL FastNoise::SingleValueFractalBillow(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { - float sum = FastAbs(SingleValue(m_perm[0], x, y, z)) * 2.0f - 1.0f; - float amp = 1.0f; + FN_DECIMAL sum = FastAbs(SingleValue(m_perm[0], x, y, z)) * 2 - 1; + FN_DECIMAL amp = 1; int i = 0; while (++i < m_octaves) @@ -539,16 +539,16 @@ float FastNoise::SingleValueFractalBillow(float x, float y, float z) z *= m_lacunarity; amp *= m_gain; - sum += (FastAbs(SingleValue(m_perm[i], x, y, z)) * 2.0f - 1.0f) * amp; + sum += (FastAbs(SingleValue(m_perm[i], x, y, z)) * 2 - 1) * amp; } return sum * m_fractalBounding; } -float FastNoise::SingleValueFractalRigidMulti(float x, float y, float z) +FN_DECIMAL FastNoise::SingleValueFractalRigidMulti(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { - float sum = 1.0f - FastAbs(SingleValue(m_perm[0], x, y, z)); - float amp = 1.0f; + FN_DECIMAL sum = 1 - FastAbs(SingleValue(m_perm[0], x, y, z)); + FN_DECIMAL amp = 1; int i = 0; while (++i < m_octaves) @@ -558,18 +558,18 @@ float FastNoise::SingleValueFractalRigidMulti(float x, float y, float z) z *= m_lacunarity; amp *= m_gain; - sum -= (1.0f - FastAbs(SingleValue(m_perm[i], x, y, z))) * amp; + sum -= (1 - FastAbs(SingleValue(m_perm[i], x, y, z))) * amp; } return sum; } -float FastNoise::GetValue(float x, float y, float z) +FN_DECIMAL FastNoise::GetValue(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { return SingleValue(0, x * m_frequency, y * m_frequency, z * m_frequency); } -float FastNoise::SingleValue(unsigned char offset, float x, float y, float z) +FN_DECIMAL FastNoise::SingleValue(unsigned char offset, FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { int x0 = FastFloor(x); int y0 = FastFloor(y); @@ -578,38 +578,38 @@ float FastNoise::SingleValue(unsigned char offset, float x, float y, float z) int y1 = y0 + 1; int z1 = z0 + 1; - float xs, ys, zs; + FN_DECIMAL xs, ys, zs; switch (m_interp) { case Linear: - xs = x - (float)x0; - ys = y - (float)y0; - zs = z - (float)z0; + xs = x - (FN_DECIMAL)x0; + ys = y - (FN_DECIMAL)y0; + zs = z - (FN_DECIMAL)z0; break; case Hermite: - xs = InterpHermiteFunc(x - (float)x0); - ys = InterpHermiteFunc(y - (float)y0); - zs = InterpHermiteFunc(z - (float)z0); + xs = InterpHermiteFunc(x - (FN_DECIMAL)x0); + ys = InterpHermiteFunc(y - (FN_DECIMAL)y0); + zs = InterpHermiteFunc(z - (FN_DECIMAL)z0); break; case Quintic: - xs = InterpQuinticFunc(x - (float)x0); - ys = InterpQuinticFunc(y - (float)y0); - zs = InterpQuinticFunc(z - (float)z0); + xs = InterpQuinticFunc(x - (FN_DECIMAL)x0); + ys = InterpQuinticFunc(y - (FN_DECIMAL)y0); + zs = InterpQuinticFunc(z - (FN_DECIMAL)z0); break; } - float xf00 = Lerp(ValCoord3DFast(offset, x0, y0, z0), ValCoord3DFast(offset, x1, y0, z0), xs); - float xf10 = Lerp(ValCoord3DFast(offset, x0, y1, z0), ValCoord3DFast(offset, x1, y1, z0), xs); - float xf01 = Lerp(ValCoord3DFast(offset, x0, y0, z1), ValCoord3DFast(offset, x1, y0, z1), xs); - float xf11 = Lerp(ValCoord3DFast(offset, x0, y1, z1), ValCoord3DFast(offset, x1, y1, z1), xs); + FN_DECIMAL xf00 = Lerp(ValCoord3DFast(offset, x0, y0, z0), ValCoord3DFast(offset, x1, y0, z0), xs); + FN_DECIMAL xf10 = Lerp(ValCoord3DFast(offset, x0, y1, z0), ValCoord3DFast(offset, x1, y1, z0), xs); + FN_DECIMAL xf01 = Lerp(ValCoord3DFast(offset, x0, y0, z1), ValCoord3DFast(offset, x1, y0, z1), xs); + FN_DECIMAL xf11 = Lerp(ValCoord3DFast(offset, x0, y1, z1), ValCoord3DFast(offset, x1, y1, z1), xs); - float yf0 = Lerp(xf00, xf10, ys); - float yf1 = Lerp(xf01, xf11, ys); + FN_DECIMAL yf0 = Lerp(xf00, xf10, ys); + FN_DECIMAL yf1 = Lerp(xf01, xf11, ys); return Lerp(yf0, yf1, zs); } -float FastNoise::GetValueFractal(float x, float y) +FN_DECIMAL FastNoise::GetValueFractal(FN_DECIMAL x, FN_DECIMAL y) { x *= m_frequency; y *= m_frequency; @@ -623,14 +623,14 @@ float FastNoise::GetValueFractal(float x, float y) case RigidMulti: return SingleValueFractalRigidMulti(x, y); default: - return 0.0f; + return 0; } } -float FastNoise::SingleValueFractalFBM(float x, float y) +FN_DECIMAL FastNoise::SingleValueFractalFBM(FN_DECIMAL x, FN_DECIMAL y) { - float sum = SingleValue(m_perm[0], x, y); - float amp = 1.0f; + FN_DECIMAL sum = SingleValue(m_perm[0], x, y); + FN_DECIMAL amp = 1; int i = 0; while (++i < m_octaves) @@ -645,10 +645,10 @@ float FastNoise::SingleValueFractalFBM(float x, float y) return sum * m_fractalBounding; } -float FastNoise::SingleValueFractalBillow(float x, float y) +FN_DECIMAL FastNoise::SingleValueFractalBillow(FN_DECIMAL x, FN_DECIMAL y) { - float sum = FastAbs(SingleValue(m_perm[0], x, y)) * 2.0f - 1.0f; - float amp = 1.0f; + FN_DECIMAL sum = FastAbs(SingleValue(m_perm[0], x, y)) * 2 - 1; + FN_DECIMAL amp = 1; int i = 0; while (++i < m_octaves) @@ -656,16 +656,16 @@ float FastNoise::SingleValueFractalBillow(float x, float y) x *= m_lacunarity; y *= m_lacunarity; amp *= m_gain; - sum += (FastAbs(SingleValue(m_perm[i], x, y)) * 2.0f - 1.0f) * amp; + sum += (FastAbs(SingleValue(m_perm[i], x, y)) * 2 - 1) * amp; } return sum * m_fractalBounding; } -float FastNoise::SingleValueFractalRigidMulti(float x, float y) +FN_DECIMAL FastNoise::SingleValueFractalRigidMulti(FN_DECIMAL x, FN_DECIMAL y) { - float sum = 1.0f - FastAbs(SingleValue(m_perm[0], x, y)); - float amp = 1.0f; + FN_DECIMAL sum = 1 - FastAbs(SingleValue(m_perm[0], x, y)); + FN_DECIMAL amp = 1; int i = 0; while (++i < m_octaves) @@ -674,49 +674,49 @@ float FastNoise::SingleValueFractalRigidMulti(float x, float y) y *= m_lacunarity; amp *= m_gain; - sum -= (1.0f - FastAbs(SingleValue(m_perm[i], x, y))) * amp; + sum -= (1 - FastAbs(SingleValue(m_perm[i], x, y))) * amp; } return sum; } -float FastNoise::GetValue(float x, float y) +FN_DECIMAL FastNoise::GetValue(FN_DECIMAL x, FN_DECIMAL y) { return SingleValue(0, x * m_frequency, y * m_frequency); } -float FastNoise::SingleValue(unsigned char offset, float x, float y) +FN_DECIMAL FastNoise::SingleValue(unsigned char offset, FN_DECIMAL x, FN_DECIMAL y) { int x0 = FastFloor(x); int y0 = FastFloor(y); int x1 = x0 + 1; int y1 = y0 + 1; - float xs, ys; + FN_DECIMAL xs, ys; switch (m_interp) { case Linear: - xs = x - (float)x0; - ys = y - (float)y0; + xs = x - (FN_DECIMAL)x0; + ys = y - (FN_DECIMAL)y0; break; case Hermite: - xs = InterpHermiteFunc(x - (float)x0); - ys = InterpHermiteFunc(y - (float)y0); + xs = InterpHermiteFunc(x - (FN_DECIMAL)x0); + ys = InterpHermiteFunc(y - (FN_DECIMAL)y0); break; case Quintic: - xs = InterpQuinticFunc(x - (float)x0); - ys = InterpQuinticFunc(y - (float)y0); + xs = InterpQuinticFunc(x - (FN_DECIMAL)x0); + ys = InterpQuinticFunc(y - (FN_DECIMAL)y0); break; } - float xf0 = Lerp(ValCoord2DFast(offset, x0, y0), ValCoord2DFast(offset, x1, y0), xs); - float xf1 = Lerp(ValCoord2DFast(offset, x0, y1), ValCoord2DFast(offset, x1, y1), xs); + FN_DECIMAL xf0 = Lerp(ValCoord2DFast(offset, x0, y0), ValCoord2DFast(offset, x1, y0), xs); + FN_DECIMAL xf1 = Lerp(ValCoord2DFast(offset, x0, y1), ValCoord2DFast(offset, x1, y1), xs); return Lerp(xf0, xf1, ys); } // Perlin Noise -float FastNoise::GetPerlinFractal(float x, float y, float z) +FN_DECIMAL FastNoise::GetPerlinFractal(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { x *= m_frequency; y *= m_frequency; @@ -731,14 +731,14 @@ float FastNoise::GetPerlinFractal(float x, float y, float z) case RigidMulti: return SinglePerlinFractalRigidMulti(x, y, z); default: - return 0.0f; + return 0; } } -float FastNoise::SinglePerlinFractalFBM(float x, float y, float z) +FN_DECIMAL FastNoise::SinglePerlinFractalFBM(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { - float sum = SinglePerlin(m_perm[0], x, y, z); - float amp = 1.0f; + FN_DECIMAL sum = SinglePerlin(m_perm[0], x, y, z); + FN_DECIMAL amp = 1; int i = 0; while (++i < m_octaves) @@ -754,10 +754,10 @@ float FastNoise::SinglePerlinFractalFBM(float x, float y, float z) return sum * m_fractalBounding; } -float FastNoise::SinglePerlinFractalBillow(float x, float y, float z) +FN_DECIMAL FastNoise::SinglePerlinFractalBillow(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { - float sum = FastAbs(SinglePerlin(m_perm[0], x, y, z)) * 2.0f - 1.0f; - float amp = 1.0f; + FN_DECIMAL sum = FastAbs(SinglePerlin(m_perm[0], x, y, z)) * 2 - 1; + FN_DECIMAL amp = 1; int i = 0; while (++i < m_octaves) @@ -767,16 +767,16 @@ float FastNoise::SinglePerlinFractalBillow(float x, float y, float z) z *= m_lacunarity; amp *= m_gain; - sum += (FastAbs(SinglePerlin(m_perm[i], x, y, z)) * 2.0f - 1.0f) * amp; + sum += (FastAbs(SinglePerlin(m_perm[i], x, y, z)) * 2 - 1) * amp; } return sum * m_fractalBounding; } -float FastNoise::SinglePerlinFractalRigidMulti(float x, float y, float z) +FN_DECIMAL FastNoise::SinglePerlinFractalRigidMulti(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { - float sum = 1.0f - FastAbs(SinglePerlin(m_perm[0], x, y, z)); - float amp = 1.0f; + FN_DECIMAL sum = 1 - FastAbs(SinglePerlin(m_perm[0], x, y, z)); + FN_DECIMAL amp = 1; int i = 0; while (++i < m_octaves) @@ -786,18 +786,18 @@ float FastNoise::SinglePerlinFractalRigidMulti(float x, float y, float z) z *= m_lacunarity; amp *= m_gain; - sum -= (1.0f - FastAbs(SinglePerlin(m_perm[i], x, y, z))) * amp; + sum -= (1 - FastAbs(SinglePerlin(m_perm[i], x, y, z))) * amp; } return sum; } -float FastNoise::GetPerlin(float x, float y, float z) +FN_DECIMAL FastNoise::GetPerlin(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { return SinglePerlin(0, x * m_frequency, y * m_frequency, z * m_frequency); } -float FastNoise::SinglePerlin(unsigned char offset, float x, float y, float z) +FN_DECIMAL FastNoise::SinglePerlin(unsigned char offset, FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { int x0 = FastFloor(x); int y0 = FastFloor(y); @@ -806,45 +806,45 @@ float FastNoise::SinglePerlin(unsigned char offset, float x, float y, float z) int y1 = y0 + 1; int z1 = z0 + 1; - float xs, ys, zs; + FN_DECIMAL xs, ys, zs; switch (m_interp) { case Linear: - xs = x - (float)x0; - ys = y - (float)y0; - zs = z - (float)z0; + xs = x - (FN_DECIMAL)x0; + ys = y - (FN_DECIMAL)y0; + zs = z - (FN_DECIMAL)z0; break; case Hermite: - xs = InterpHermiteFunc(x - (float)x0); - ys = InterpHermiteFunc(y - (float)y0); - zs = InterpHermiteFunc(z - (float)z0); + xs = InterpHermiteFunc(x - (FN_DECIMAL)x0); + ys = InterpHermiteFunc(y - (FN_DECIMAL)y0); + zs = InterpHermiteFunc(z - (FN_DECIMAL)z0); break; case Quintic: - xs = InterpQuinticFunc(x - (float)x0); - ys = InterpQuinticFunc(y - (float)y0); - zs = InterpQuinticFunc(z - (float)z0); + xs = InterpQuinticFunc(x - (FN_DECIMAL)x0); + ys = InterpQuinticFunc(y - (FN_DECIMAL)y0); + zs = InterpQuinticFunc(z - (FN_DECIMAL)z0); break; } - float xd0 = x - (float)x0; - float yd0 = y - (float)y0; - float zd0 = z - (float)z0; - float xd1 = xd0 - 1.0f; - float yd1 = yd0 - 1.0f; - float zd1 = zd0 - 1.0f; + FN_DECIMAL xd0 = x - (FN_DECIMAL)x0; + FN_DECIMAL yd0 = y - (FN_DECIMAL)y0; + FN_DECIMAL zd0 = z - (FN_DECIMAL)z0; + FN_DECIMAL xd1 = xd0 - 1; + FN_DECIMAL yd1 = yd0 - 1; + FN_DECIMAL zd1 = zd0 - 1; - float xf00 = Lerp(GradCoord3D(offset, x0, y0, z0, xd0, yd0, zd0), GradCoord3D(offset, x1, y0, z0, xd1, yd0, zd0), xs); - float xf10 = Lerp(GradCoord3D(offset, x0, y1, z0, xd0, yd1, zd0), GradCoord3D(offset, x1, y1, z0, xd1, yd1, zd0), xs); - float xf01 = Lerp(GradCoord3D(offset, x0, y0, z1, xd0, yd0, zd1), GradCoord3D(offset, x1, y0, z1, xd1, yd0, zd1), xs); - float xf11 = Lerp(GradCoord3D(offset, x0, y1, z1, xd0, yd1, zd1), GradCoord3D(offset, x1, y1, z1, xd1, yd1, zd1), xs); + FN_DECIMAL xf00 = Lerp(GradCoord3D(offset, x0, y0, z0, xd0, yd0, zd0), GradCoord3D(offset, x1, y0, z0, xd1, yd0, zd0), xs); + FN_DECIMAL xf10 = Lerp(GradCoord3D(offset, x0, y1, z0, xd0, yd1, zd0), GradCoord3D(offset, x1, y1, z0, xd1, yd1, zd0), xs); + FN_DECIMAL xf01 = Lerp(GradCoord3D(offset, x0, y0, z1, xd0, yd0, zd1), GradCoord3D(offset, x1, y0, z1, xd1, yd0, zd1), xs); + FN_DECIMAL xf11 = Lerp(GradCoord3D(offset, x0, y1, z1, xd0, yd1, zd1), GradCoord3D(offset, x1, y1, z1, xd1, yd1, zd1), xs); - float yf0 = Lerp(xf00, xf10, ys); - float yf1 = Lerp(xf01, xf11, ys); + FN_DECIMAL yf0 = Lerp(xf00, xf10, ys); + FN_DECIMAL yf1 = Lerp(xf01, xf11, ys); return Lerp(yf0, yf1, zs); } -float FastNoise::GetPerlinFractal(float x, float y) +FN_DECIMAL FastNoise::GetPerlinFractal(FN_DECIMAL x, FN_DECIMAL y) { x *= m_frequency; y *= m_frequency; @@ -858,14 +858,14 @@ float FastNoise::GetPerlinFractal(float x, float y) case RigidMulti: return SinglePerlinFractalRigidMulti(x, y); default: - return 0.0f; + return 0; } } -float FastNoise::SinglePerlinFractalFBM(float x, float y) +FN_DECIMAL FastNoise::SinglePerlinFractalFBM(FN_DECIMAL x, FN_DECIMAL y) { - float sum = SinglePerlin(m_perm[0], x, y); - float amp = 1.0f; + FN_DECIMAL sum = SinglePerlin(m_perm[0], x, y); + FN_DECIMAL amp = 1; int i = 0; while (++i < m_octaves) @@ -880,10 +880,10 @@ float FastNoise::SinglePerlinFractalFBM(float x, float y) return sum * m_fractalBounding; } -float FastNoise::SinglePerlinFractalBillow(float x, float y) +FN_DECIMAL FastNoise::SinglePerlinFractalBillow(FN_DECIMAL x, FN_DECIMAL y) { - float sum = FastAbs(SinglePerlin(m_perm[0], x, y)) * 2.0f - 1.0f; - float amp = 1.0f; + FN_DECIMAL sum = FastAbs(SinglePerlin(m_perm[0], x, y)) * 2 - 1; + FN_DECIMAL amp = 1; int i = 0; while (++i < m_octaves) @@ -892,16 +892,16 @@ float FastNoise::SinglePerlinFractalBillow(float x, float y) y *= m_lacunarity; amp *= m_gain; - sum += (FastAbs(SinglePerlin(m_perm[i], x, y)) * 2.0f - 1.0f) * amp; + sum += (FastAbs(SinglePerlin(m_perm[i], x, y)) * 2 - 1) * amp; } return sum * m_fractalBounding; } -float FastNoise::SinglePerlinFractalRigidMulti(float x, float y) +FN_DECIMAL FastNoise::SinglePerlinFractalRigidMulti(FN_DECIMAL x, FN_DECIMAL y) { - float sum = 1.0f - FastAbs(SinglePerlin(m_perm[0], x, y)); - float amp = 1.0f; + FN_DECIMAL sum = 1 - FastAbs(SinglePerlin(m_perm[0], x, y)); + FN_DECIMAL amp = 1; int i = 0; while (++i < m_octaves) @@ -910,55 +910,55 @@ float FastNoise::SinglePerlinFractalRigidMulti(float x, float y) y *= m_lacunarity; amp *= m_gain; - sum -= (1.0f - FastAbs(SinglePerlin(m_perm[i], x, y))) * amp; + sum -= (1 - FastAbs(SinglePerlin(m_perm[i], x, y))) * amp; } return sum; } -float FastNoise::GetPerlin(float x, float y) +FN_DECIMAL FastNoise::GetPerlin(FN_DECIMAL x, FN_DECIMAL y) { return SinglePerlin(0, x * m_frequency, y * m_frequency); } -float FastNoise::SinglePerlin(unsigned char offset, float x, float y) +FN_DECIMAL FastNoise::SinglePerlin(unsigned char offset, FN_DECIMAL x, FN_DECIMAL y) { int x0 = FastFloor(x); int y0 = FastFloor(y); int x1 = x0 + 1; int y1 = y0 + 1; - float xs, ys; + FN_DECIMAL xs, ys; switch (m_interp) { case Linear: - xs = x - (float)x0; - ys = y - (float)y0; + xs = x - (FN_DECIMAL)x0; + ys = y - (FN_DECIMAL)y0; break; case Hermite: - xs = InterpHermiteFunc(x - (float)x0); - ys = InterpHermiteFunc(y - (float)y0); + xs = InterpHermiteFunc(x - (FN_DECIMAL)x0); + ys = InterpHermiteFunc(y - (FN_DECIMAL)y0); break; case Quintic: - xs = InterpQuinticFunc(x - (float)x0); - ys = InterpQuinticFunc(y - (float)y0); + xs = InterpQuinticFunc(x - (FN_DECIMAL)x0); + ys = InterpQuinticFunc(y - (FN_DECIMAL)y0); break; } - float xd0 = x - (float)x0; - float yd0 = y - (float)y0; - float xd1 = xd0 - 1.0f; - float yd1 = yd0 - 1.0f; + FN_DECIMAL xd0 = x - (FN_DECIMAL)x0; + FN_DECIMAL yd0 = y - (FN_DECIMAL)y0; + FN_DECIMAL xd1 = xd0 - 1; + FN_DECIMAL yd1 = yd0 - 1; - float xf0 = Lerp(GradCoord2D(offset, x0, y0, xd0, yd0), GradCoord2D(offset, x1, y0, xd1, yd0), xs); - float xf1 = Lerp(GradCoord2D(offset, x0, y1, xd0, yd1), GradCoord2D(offset, x1, y1, xd1, yd1), xs); + FN_DECIMAL xf0 = Lerp(GradCoord2D(offset, x0, y0, xd0, yd0), GradCoord2D(offset, x1, y0, xd1, yd0), xs); + FN_DECIMAL xf1 = Lerp(GradCoord2D(offset, x0, y1, xd0, yd1), GradCoord2D(offset, x1, y1, xd1, yd1), xs); return Lerp(xf0, xf1, ys); } // Simplex Noise -float FastNoise::GetSimplexFractal(float x, float y, float z) +FN_DECIMAL FastNoise::GetSimplexFractal(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { x *= m_frequency; y *= m_frequency; @@ -973,14 +973,14 @@ float FastNoise::GetSimplexFractal(float x, float y, float z) case RigidMulti: return SingleSimplexFractalRigidMulti(x, y, z); default: - return 0.0f; + return 0; } } -float FastNoise::SingleSimplexFractalFBM(float x, float y, float z) +FN_DECIMAL FastNoise::SingleSimplexFractalFBM(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { - float sum = SingleSimplex(m_perm[0], x, y, z); - float amp = 1.0f; + FN_DECIMAL sum = SingleSimplex(m_perm[0], x, y, z); + FN_DECIMAL amp = 1; int i = 0; while (++i < m_octaves) @@ -996,10 +996,10 @@ float FastNoise::SingleSimplexFractalFBM(float x, float y, float z) return sum * m_fractalBounding; } -float FastNoise::SingleSimplexFractalBillow(float x, float y, float z) +FN_DECIMAL FastNoise::SingleSimplexFractalBillow(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { - float sum = FastAbs(SingleSimplex(m_perm[0], x, y, z)) * 2.0f - 1.0f; - float amp = 1.0f; + FN_DECIMAL sum = FastAbs(SingleSimplex(m_perm[0], x, y, z)) * 2 - 1; + FN_DECIMAL amp = 1; int i = 0; while (++i < m_octaves) @@ -1009,16 +1009,16 @@ float FastNoise::SingleSimplexFractalBillow(float x, float y, float z) z *= m_lacunarity; amp *= m_gain; - sum += (FastAbs(SingleSimplex(m_perm[i], x, y, z)) * 2.0f - 1.0f) * amp; + sum += (FastAbs(SingleSimplex(m_perm[i], x, y, z)) * 2 - 1) * amp; } return sum * m_fractalBounding; } -float FastNoise::SingleSimplexFractalRigidMulti(float x, float y, float z) +FN_DECIMAL FastNoise::SingleSimplexFractalRigidMulti(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { - float sum = 1.0f - FastAbs(SingleSimplex(m_perm[0], x, y, z)); - float amp = 1.0f; + FN_DECIMAL sum = 1 - FastAbs(SingleSimplex(m_perm[0], x, y, z)); + FN_DECIMAL amp = 1; int i = 0; while (++i < m_octaves) @@ -1028,35 +1028,35 @@ float FastNoise::SingleSimplexFractalRigidMulti(float x, float y, float z) z *= m_lacunarity; amp *= m_gain; - sum -= (1.0f - FastAbs(SingleSimplex(m_perm[i], x, y, z))) * amp; + sum -= (1 - FastAbs(SingleSimplex(m_perm[i], x, y, z))) * amp; } return sum; } -float FastNoise::GetSimplex(float x, float y, float z) +FN_DECIMAL FastNoise::GetSimplex(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { return SingleSimplex(0, x * m_frequency, y * m_frequency, z * m_frequency); } -static const float F3 = 1.0f / 3.0f; -static const float G3 = 1.0f / 6.0f; +static const FN_DECIMAL F3 = 1 / FN_DECIMAL(3); +static const FN_DECIMAL G3 = 1 / FN_DECIMAL(6); -float FastNoise::SingleSimplex(unsigned char offset, float x, float y, float z) +FN_DECIMAL FastNoise::SingleSimplex(unsigned char offset, FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { - float t = (x + y + z) * F3; + FN_DECIMAL t = (x + y + z) * F3; int i = FastFloor(x + t); int j = FastFloor(y + t); int k = FastFloor(z + t); t = (i + j + k) * G3; - float X0 = i - t; - float Y0 = j - t; - float Z0 = k - t; + FN_DECIMAL X0 = i - t; + FN_DECIMAL Y0 = j - t; + FN_DECIMAL Z0 = k - t; - float x0 = x - X0; - float y0 = y - Y0; - float z0 = z - Z0; + FN_DECIMAL x0 = x - X0; + FN_DECIMAL y0 = y - Y0; + FN_DECIMAL z0 = z - Z0; int i1, j1, k1; int i2, j2, k2; @@ -1092,54 +1092,54 @@ float FastNoise::SingleSimplex(unsigned char offset, float x, float y, float z) } } - float x1 = x0 - i1 + G3; - float y1 = y0 - j1 + G3; - float z1 = z0 - k1 + G3; - float x2 = x0 - i2 + 2.0f*G3; - float y2 = y0 - j2 + 2.0f*G3; - float z2 = z0 - k2 + 2.0f*G3; - float x3 = x0 - 1.0f + 3.0f*G3; - float y3 = y0 - 1.0f + 3.0f*G3; - float z3 = z0 - 1.0f + 3.0f*G3; + FN_DECIMAL x1 = x0 - i1 + G3; + FN_DECIMAL y1 = y0 - j1 + G3; + FN_DECIMAL z1 = z0 - k1 + G3; + FN_DECIMAL x2 = x0 - i2 + 2*G3; + FN_DECIMAL y2 = y0 - j2 + 2*G3; + FN_DECIMAL z2 = z0 - k2 + 2*G3; + FN_DECIMAL x3 = x0 - 1 + 3*G3; + FN_DECIMAL y3 = y0 - 1 + 3*G3; + FN_DECIMAL z3 = z0 - 1 + 3*G3; - float n0, n1, n2, n3; + FN_DECIMAL n0, n1, n2, n3; - t = 0.6f - x0*x0 - y0*y0 - z0*z0; - if (t < 0.0f) n0 = 0.0f; + t = FN_DECIMAL(0.6) - x0*x0 - y0*y0 - z0*z0; + if (t < 0) n0 = 0; else { t *= t; n0 = t*t*GradCoord3D(offset, i, j, k, x0, y0, z0); } - t = 0.6f - x1*x1 - y1*y1 - z1*z1; - if (t < 0.0f) n1 = 0.0f; + t = FN_DECIMAL(0.6) - x1*x1 - y1*y1 - z1*z1; + if (t < 0) n1 = 0; else { t *= t; n1 = t*t*GradCoord3D(offset, i + i1, j + j1, k + k1, x1, y1, z1); } - t = 0.6f - x2*x2 - y2*y2 - z2*z2; - if (t < 0.0f) n2 = 0.0f; + t = FN_DECIMAL(0.6) - x2*x2 - y2*y2 - z2*z2; + if (t < 0) n2 = 0; else { t *= t; n2 = t*t*GradCoord3D(offset, i + i2, j + j2, k + k2, x2, y2, z2); } - t = 0.6f - x3*x3 - y3*y3 - z3*z3; - if (t < 0.0f) n3 = 0.0f; + t = FN_DECIMAL(0.6) - x3*x3 - y3*y3 - z3*z3; + if (t < 0) n3 = 0; else { t *= t; n3 = t*t*GradCoord3D(offset, i + 1, j + 1, k + 1, x3, y3, z3); } - return 32.0f * (n0 + n1 + n2 + n3); + return 32 * (n0 + n1 + n2 + n3); } -float FastNoise::GetSimplexFractal(float x, float y) +FN_DECIMAL FastNoise::GetSimplexFractal(FN_DECIMAL x, FN_DECIMAL y) { x *= m_frequency; y *= m_frequency; @@ -1153,14 +1153,14 @@ float FastNoise::GetSimplexFractal(float x, float y) case RigidMulti: return SingleSimplexFractalRigidMulti(x, y); default: - return 0.0f; + return 0; } } -float FastNoise::SingleSimplexFractalFBM(float x, float y) +FN_DECIMAL FastNoise::SingleSimplexFractalFBM(FN_DECIMAL x, FN_DECIMAL y) { - float sum = SingleSimplex(m_perm[0], x, y); - float amp = 1.0f; + FN_DECIMAL sum = SingleSimplex(m_perm[0], x, y); + FN_DECIMAL amp = 1; int i = 0; while (++i < m_octaves) @@ -1175,10 +1175,10 @@ float FastNoise::SingleSimplexFractalFBM(float x, float y) return sum * m_fractalBounding; } -float FastNoise::SingleSimplexFractalBillow(float x, float y) +FN_DECIMAL FastNoise::SingleSimplexFractalBillow(FN_DECIMAL x, FN_DECIMAL y) { - float sum = FastAbs(SingleSimplex(m_perm[0], x, y)) * 2.0f - 1.0f; - float amp = 1.0f; + FN_DECIMAL sum = FastAbs(SingleSimplex(m_perm[0], x, y)) * 2 - 1; + FN_DECIMAL amp = 1; int i = 0; while (++i < m_octaves) @@ -1187,16 +1187,16 @@ float FastNoise::SingleSimplexFractalBillow(float x, float y) y *= m_lacunarity; amp *= m_gain; - sum += (FastAbs(SingleSimplex(m_perm[i], x, y)) * 2.0f - 1.0f) * amp; + sum += (FastAbs(SingleSimplex(m_perm[i], x, y)) * 2 - 1) * amp; } return sum * m_fractalBounding; } -float FastNoise::SingleSimplexFractalRigidMulti(float x, float y) +FN_DECIMAL FastNoise::SingleSimplexFractalRigidMulti(FN_DECIMAL x, FN_DECIMAL y) { - float sum = 1.0f - FastAbs(SingleSimplex(m_perm[0], x, y)); - float amp = 1.0f; + FN_DECIMAL sum = 1 - FastAbs(SingleSimplex(m_perm[0], x, y)); + FN_DECIMAL amp = 1; int i = 0; while (++i < m_octaves) @@ -1205,16 +1205,16 @@ float FastNoise::SingleSimplexFractalRigidMulti(float x, float y) y *= m_lacunarity; amp *= m_gain; - sum -= (1.0f - FastAbs(SingleSimplex(m_perm[i], x, y))) * amp; + sum -= (1 - FastAbs(SingleSimplex(m_perm[i], x, y))) * amp; } return sum; } -float FastNoise::SingleSimplexFractalBlend(float x, float y) +FN_DECIMAL FastNoise::SingleSimplexFractalBlend(FN_DECIMAL x, FN_DECIMAL y) { - float sum = SingleSimplex(m_perm[0], x, y); - float amp = 1.0f; + FN_DECIMAL sum = SingleSimplex(m_perm[0], x, y); + FN_DECIMAL amp = 1; int i = 0; while (++i < m_octaves) @@ -1223,32 +1223,32 @@ float FastNoise::SingleSimplexFractalBlend(float x, float y) y *= m_lacunarity; amp *= m_gain; - sum *= SingleSimplex(m_perm[i], x, y) * amp + 1.f; + sum *= SingleSimplex(m_perm[i], x, y) * amp + 1; } return sum * m_fractalBounding; } -float FastNoise::GetSimplex(float x, float y) +FN_DECIMAL FastNoise::GetSimplex(FN_DECIMAL x, FN_DECIMAL y) { return SingleSimplex(0, x * m_frequency, y * m_frequency); } -static const float F2 = 1.f / 2.f; -static const float G2 = 1.f / 4.f; +static const FN_DECIMAL F2 = 1 / FN_DECIMAL(2); +static const FN_DECIMAL G2 = 1 / FN_DECIMAL(4); -float FastNoise::SingleSimplex(unsigned char offset, float x, float y) +FN_DECIMAL FastNoise::SingleSimplex(unsigned char offset, FN_DECIMAL x, FN_DECIMAL y) { - float t = (x + y) * F2; + FN_DECIMAL t = (x + y) * F2; int i = FastFloor(x + t); int j = FastFloor(y + t); t = (i + j) * G2; - float X0 = i - t; - float Y0 = j - t; + FN_DECIMAL X0 = i - t; + FN_DECIMAL Y0 = j - t; - float x0 = x - X0; - float y0 = y - Y0; + FN_DECIMAL x0 = x - X0; + FN_DECIMAL y0 = y - Y0; int i1, j1; if (x0 > y0) @@ -1260,14 +1260,14 @@ float FastNoise::SingleSimplex(unsigned char offset, float x, float y) i1 = 0; j1 = 1; } - float x1 = x0 - (float)i1 + G2; - float y1 = y0 - (float)j1 + G2; - float x2 = x0 - 1.0f + 2.0f*G2; - float y2 = y0 - 1.0f + 2.0f*G2; + FN_DECIMAL x1 = x0 - (FN_DECIMAL)i1 + G2; + FN_DECIMAL y1 = y0 - (FN_DECIMAL)j1 + G2; + FN_DECIMAL x2 = x0 - 1 + 2*G2; + FN_DECIMAL y2 = y0 - 1 + 2*G2; - float n0, n1, n2; + FN_DECIMAL n0, n1, n2; - t = 0.5f - x0*x0 - y0*y0; + t = FN_DECIMAL(0.5) - x0*x0 - y0*y0; if (t < 0) n0 = 0; else { @@ -1275,7 +1275,7 @@ float FastNoise::SingleSimplex(unsigned char offset, float x, float y) n0 = t * t * GradCoord2D(offset, i, j, x0, y0); } - t = 0.5f - x1*x1 - y1*y1; + t = FN_DECIMAL(0.5) - x1*x1 - y1*y1; if (t < 0) n1 = 0; else { @@ -1283,7 +1283,7 @@ float FastNoise::SingleSimplex(unsigned char offset, float x, float y) n1 = t*t*GradCoord2D(offset, i + i1, j + j1, x1, y1); } - t = 0.5f - x2*x2 - y2*y2; + t = FN_DECIMAL(0.5) - x2*x2 - y2*y2; if (t < 0) n2 = 0; else { @@ -1291,10 +1291,10 @@ float FastNoise::SingleSimplex(unsigned char offset, float x, float y) n2 = t*t*GradCoord2D(offset, i + 1, j + 1, x2, y2); } - return 50.0f * (n0 + n1 + n2); + return 50 * (n0 + n1 + n2); } -float FastNoise::GetSimplex(float x, float y, float z, float w) +FN_DECIMAL FastNoise::GetSimplex(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z, FN_DECIMAL w) { return SingleSimplex(0, x * m_frequency, y * m_frequency, z * m_frequency, w * m_frequency); } @@ -1311,26 +1311,26 @@ static const unsigned char SIMPLEX_4D[] = 2,1,0,3,0,0,0,0,0,0,0,0,0,0,0,0,3,1,0,2,0,0,0,0,3,2,0,1,3,2,1,0 }; -static const float F4 = (sqrtf(5.0f) - 1.0f) / 4.0f; -static const float G4 = (5.0f - sqrtf(5.0f)) / 20.0f; +static const FN_DECIMAL F4 = (sqrt(FN_DECIMAL(5)) - 1) / 4; +static const FN_DECIMAL G4 = (5 - sqrt(FN_DECIMAL(5))) / 2; -float FastNoise::SingleSimplex(unsigned char offset, float x, float y, float z, float w) +FN_DECIMAL FastNoise::SingleSimplex(unsigned char offset, FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z, FN_DECIMAL w) { - float n0, n1, n2, n3, n4; - float t = (x + y + z + w) * F4; + FN_DECIMAL n0, n1, n2, n3, n4; + FN_DECIMAL t = (x + y + z + w) * F4; int i = FastFloor(x + t); int j = FastFloor(y + t); int k = FastFloor(z + t); int l = FastFloor(w + t); t = (i + j + k + l) * G4; - float X0 = i - t; - float Y0 = j - t; - float Z0 = k - t; - float W0 = l - t; - float x0 = x - X0; - float y0 = y - Y0; - float z0 = z - Z0; - float w0 = w - W0; + FN_DECIMAL X0 = i - t; + FN_DECIMAL Y0 = j - t; + FN_DECIMAL Z0 = k - t; + FN_DECIMAL W0 = l - t; + FN_DECIMAL x0 = x - X0; + FN_DECIMAL y0 = y - Y0; + FN_DECIMAL z0 = z - Z0; + FN_DECIMAL w0 = w - W0; int c = (x0 > y0) ? 32 : 0; c += (x0 > z0) ? 16 : 0; @@ -1353,59 +1353,59 @@ float FastNoise::SingleSimplex(unsigned char offset, float x, float y, float z, int l2 = SIMPLEX_4D[c] >= 2 ? 1 : 0; int l3 = SIMPLEX_4D[c] >= 1 ? 1 : 0; - float x1 = x0 - i1 + G4; - float y1 = y0 - j1 + G4; - float z1 = z0 - k1 + G4; - float w1 = w0 - l1 + G4; - float x2 = x0 - i2 + 2.0f*G4; - float y2 = y0 - j2 + 2.0f*G4; - float z2 = z0 - k2 + 2.0f*G4; - float w2 = w0 - l2 + 2.0f*G4; - float x3 = x0 - i3 + 3.0f*G4; - float y3 = y0 - j3 + 3.0f*G4; - float z3 = z0 - k3 + 3.0f*G4; - float w3 = w0 - l3 + 3.0f*G4; - float x4 = x0 - 1.0f + 4.0f*G4; - float y4 = y0 - 1.0f + 4.0f*G4; - float z4 = z0 - 1.0f + 4.0f*G4; - float w4 = w0 - 1.0f + 4.0f*G4; - - t = 0.6f - x0*x0 - y0*y0 - z0*z0 - w0*w0; - if (t < 0.f) n0 = 0.0f; + FN_DECIMAL x1 = x0 - i1 + G4; + FN_DECIMAL y1 = y0 - j1 + G4; + FN_DECIMAL z1 = z0 - k1 + G4; + FN_DECIMAL w1 = w0 - l1 + G4; + FN_DECIMAL x2 = x0 - i2 + 2*G4; + FN_DECIMAL y2 = y0 - j2 + 2*G4; + FN_DECIMAL z2 = z0 - k2 + 2*G4; + FN_DECIMAL w2 = w0 - l2 + 2*G4; + FN_DECIMAL x3 = x0 - i3 + 3*G4; + FN_DECIMAL y3 = y0 - j3 + 3*G4; + FN_DECIMAL z3 = z0 - k3 + 3*G4; + FN_DECIMAL w3 = w0 - l3 + 3*G4; + FN_DECIMAL x4 = x0 - 1 + 4*G4; + FN_DECIMAL y4 = y0 - 1 + 4*G4; + FN_DECIMAL z4 = z0 - 1 + 4*G4; + FN_DECIMAL w4 = w0 - 1 + 4*G4; + + t = FN_DECIMAL(0.6) - x0*x0 - y0*y0 - z0*z0 - w0*w0; + if (t < 0) n0 = 0; else { t *= t; n0 = t * t * GradCoord4D(offset, i, j, k, l, x0, y0, z0, w0); } - t = 0.6f - x1*x1 - y1*y1 - z1*z1 - w1*w1; - if (t < 0.f) n1 = 0.0f; + t = FN_DECIMAL(0.6) - x1*x1 - y1*y1 - z1*z1 - w1*w1; + if (t < 0) n1 = 0; else { t *= t; n1 = t * t * GradCoord4D(offset, i + i1, j + j1, k + k1, l + l1, x1, y1, z1, w1); } - t = 0.6f - x2*x2 - y2*y2 - z2*z2 - w2*w2; - if (t < 0.f) n2 = 0.0f; + t = FN_DECIMAL(0.6) - x2*x2 - y2*y2 - z2*z2 - w2*w2; + if (t < 0) n2 = 0; else { t *= t; n2 = t * t * GradCoord4D(offset, i + i2, j + j2, k + k2, l + l2, x2, y2, z2, w2); } - t = 0.6f - x3*x3 - y3*y3 - z3*z3 - w3*w3; - if (t < 0.f) n3 = 0.0f; + t = FN_DECIMAL(0.6) - x3*x3 - y3*y3 - z3*z3 - w3*w3; + if (t < 0) n3 = 0; else { t *= t; n3 = t * t * GradCoord4D(offset, i + i3, j + j3, k + k3, l + l3, x3, y3, z3, w3); } - t = 0.6f - x4*x4 - y4*y4 - z4*z4 - w4*w4; - if (t < 0.f) n4 = 0.0f; + t = FN_DECIMAL(0.6) - x4*x4 - y4*y4 - z4*z4 - w4*w4; + if (t < 0) n4 = 0; else { t *= t; n4 = t * t * GradCoord4D(offset, i + 1, j + 1, k + 1, l + 1, x4, y4, z4, w4); } - return 27.0f * (n0 + n1 + n2 + n3 + n4); + return 27 * (n0 + n1 + n2 + n3 + n4); } // Cubic Noise -float FastNoise::GetCubicFractal(float x, float y, float z) +FN_DECIMAL FastNoise::GetCubicFractal(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { x *= m_frequency; y *= m_frequency; @@ -1420,14 +1420,14 @@ float FastNoise::GetCubicFractal(float x, float y, float z) case RigidMulti: return SingleCubicFractalRigidMulti(x, y, z); default: - return 0.0f; + return 0; } } -float FastNoise::SingleCubicFractalFBM(float x, float y, float z) +FN_DECIMAL FastNoise::SingleCubicFractalFBM(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { - float sum = SingleCubic(m_perm[0], x, y, z); - float amp = 1.0f; + FN_DECIMAL sum = SingleCubic(m_perm[0], x, y, z); + FN_DECIMAL amp = 1; int i = 0; while (++i < m_octaves) @@ -1443,10 +1443,10 @@ float FastNoise::SingleCubicFractalFBM(float x, float y, float z) return sum * m_fractalBounding; } -float FastNoise::SingleCubicFractalBillow(float x, float y, float z) +FN_DECIMAL FastNoise::SingleCubicFractalBillow(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { - float sum = FastAbs(SingleCubic(m_perm[0], x, y, z)) * 2.0f - 1.0f; - float amp = 1.0f; + FN_DECIMAL sum = FastAbs(SingleCubic(m_perm[0], x, y, z)) * 2 - 1; + FN_DECIMAL amp = 1; int i = 0; while (++i < m_octaves) @@ -1456,16 +1456,16 @@ float FastNoise::SingleCubicFractalBillow(float x, float y, float z) z *= m_lacunarity; amp *= m_gain; - sum += (FastAbs(SingleCubic(m_perm[i], x, y, z)) * 2.0f - 1.0f) * amp; + sum += (FastAbs(SingleCubic(m_perm[i], x, y, z)) * 2 - 1) * amp; } return sum * m_fractalBounding; } -float FastNoise::SingleCubicFractalRigidMulti(float x, float y, float z) +FN_DECIMAL FastNoise::SingleCubicFractalRigidMulti(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { - float sum = 1.0f - FastAbs(SingleCubic(m_perm[0], x, y, z)); - float amp = 1.0f; + FN_DECIMAL sum = 1 - FastAbs(SingleCubic(m_perm[0], x, y, z)); + FN_DECIMAL amp = 1; int i = 0; while (++i < m_octaves) @@ -1475,20 +1475,20 @@ float FastNoise::SingleCubicFractalRigidMulti(float x, float y, float z) z *= m_lacunarity; amp *= m_gain; - sum -= (1.0f - FastAbs(SingleCubic(m_perm[i], x, y, z))) * amp; + sum -= (1 - FastAbs(SingleCubic(m_perm[i], x, y, z))) * amp; } return sum; } -float FastNoise::GetCubic(float x, float y, float z) +FN_DECIMAL FastNoise::GetCubic(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { return SingleCubic(0, x * m_frequency, y * m_frequency, z * m_frequency); } -const float CUBIC_3D_BOUNDING = 1.f / (1.5f*1.5f*1.5f); +const FN_DECIMAL CUBIC_3D_BOUNDING = 1 / (1.5*1.5*1.5); -float FastNoise::SingleCubic(unsigned char offset, float x, float y, float z) +FN_DECIMAL FastNoise::SingleCubic(unsigned char offset, FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { int x1 = FastFloor(x); int y1 = FastFloor(y); @@ -1504,9 +1504,9 @@ float FastNoise::SingleCubic(unsigned char offset, float x, float y, float z) int y3 = y1 + 2; int z3 = z1 + 2; - float xs = x - (float)x1; - float ys = y - (float)y1; - float zs = z - (float)z1; + FN_DECIMAL xs = x - (FN_DECIMAL)x1; + FN_DECIMAL ys = y - (FN_DECIMAL)y1; + FN_DECIMAL zs = z - (FN_DECIMAL)z1; return CubicLerp( CubicLerp( @@ -1537,7 +1537,7 @@ float FastNoise::SingleCubic(unsigned char offset, float x, float y, float z) } -float FastNoise::GetCubicFractal(float x, float y) +FN_DECIMAL FastNoise::GetCubicFractal(FN_DECIMAL x, FN_DECIMAL y) { x *= m_frequency; y *= m_frequency; @@ -1551,14 +1551,14 @@ float FastNoise::GetCubicFractal(float x, float y) case RigidMulti: return SingleCubicFractalRigidMulti(x, y); default: - return 0.0f; + return 0; } } -float FastNoise::SingleCubicFractalFBM(float x, float y) +FN_DECIMAL FastNoise::SingleCubicFractalFBM(FN_DECIMAL x, FN_DECIMAL y) { - float sum = SingleCubic(m_perm[0], x, y); - float amp = 1.0f; + FN_DECIMAL sum = SingleCubic(m_perm[0], x, y); + FN_DECIMAL amp = 1; int i = 0; while (++i < m_octaves) @@ -1573,10 +1573,10 @@ float FastNoise::SingleCubicFractalFBM(float x, float y) return sum * m_fractalBounding; } -float FastNoise::SingleCubicFractalBillow(float x, float y) +FN_DECIMAL FastNoise::SingleCubicFractalBillow(FN_DECIMAL x, FN_DECIMAL y) { - float sum = FastAbs(SingleCubic(m_perm[0], x, y)) * 2.0f - 1.0f; - float amp = 1.0f; + FN_DECIMAL sum = FastAbs(SingleCubic(m_perm[0], x, y)) * 2 - 1; + FN_DECIMAL amp = 1; int i = 0; while (++i < m_octaves) @@ -1585,16 +1585,16 @@ float FastNoise::SingleCubicFractalBillow(float x, float y) y *= m_lacunarity; amp *= m_gain; - sum += (FastAbs(SingleCubic(m_perm[i], x, y)) * 2.0f - 1.0f) * amp; + sum += (FastAbs(SingleCubic(m_perm[i], x, y)) * 2 - 1) * amp; } return sum * m_fractalBounding; } -float FastNoise::SingleCubicFractalRigidMulti(float x, float y) +FN_DECIMAL FastNoise::SingleCubicFractalRigidMulti(FN_DECIMAL x, FN_DECIMAL y) { - float sum = 1.0f - FastAbs(SingleCubic(m_perm[0], x, y)); - float amp = 1.0f; + FN_DECIMAL sum = 1 - FastAbs(SingleCubic(m_perm[0], x, y)); + FN_DECIMAL amp = 1; int i = 0; while (++i < m_octaves) @@ -1603,13 +1603,13 @@ float FastNoise::SingleCubicFractalRigidMulti(float x, float y) y *= m_lacunarity; amp *= m_gain; - sum -= (1.0f - FastAbs(SingleCubic(m_perm[i], x, y))) * amp; + sum -= (1 - FastAbs(SingleCubic(m_perm[i], x, y))) * amp; } return sum; } -float FastNoise::GetCubic(float x, float y) +FN_DECIMAL FastNoise::GetCubic(FN_DECIMAL x, FN_DECIMAL y) { x *= m_frequency; y *= m_frequency; @@ -1617,9 +1617,9 @@ float FastNoise::GetCubic(float x, float y) return SingleCubic(0, x, y); } -const float CUBIC_2D_BOUNDING = 1.f / (1.5f*1.5f); +const FN_DECIMAL CUBIC_2D_BOUNDING = 1 / (1.5*1.5); -float FastNoise::SingleCubic(unsigned char offset, float x, float y) +FN_DECIMAL FastNoise::SingleCubic(unsigned char offset, FN_DECIMAL x, FN_DECIMAL y) { int x1 = FastFloor(x); int y1 = FastFloor(y); @@ -1631,8 +1631,8 @@ float FastNoise::SingleCubic(unsigned char offset, float x, float y) int x3 = x1 + 2; int y3 = y1 + 2; - float xs = x - (float)x1; - float ys = y - (float)y1; + FN_DECIMAL xs = x - (FN_DECIMAL)x1; + FN_DECIMAL ys = y - (FN_DECIMAL)y1; return CubicLerp( CubicLerp(ValCoord2DFast(offset, x0, y0), ValCoord2DFast(offset, x1, y0), ValCoord2DFast(offset, x2, y0), ValCoord2DFast(offset, x3, y0), xs), @@ -1643,7 +1643,7 @@ float FastNoise::SingleCubic(unsigned char offset, float x, float y) } // Cellular Noise -float FastNoise::GetCellular(float x, float y, float z) +FN_DECIMAL FastNoise::GetCellular(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { x *= m_frequency; y *= m_frequency; @@ -1660,13 +1660,13 @@ float FastNoise::GetCellular(float x, float y, float z) } } -float FastNoise::SingleCellular(float x, float y, float z) +FN_DECIMAL FastNoise::SingleCellular(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { int xr = FastRound(x); int yr = FastRound(y); int zr = FastRound(z); - float distance = 999999.f; + FN_DECIMAL distance = 999999; int xc, yc, zc; switch (m_cellularDistanceFunction) @@ -1680,11 +1680,11 @@ float FastNoise::SingleCellular(float x, float y, float z) { unsigned char lutPos = Index3D_256(0, xi, yi, zi); - float vecX = xi - x + CELL_3D_X[lutPos]; - float vecY = yi - y + CELL_3D_Y[lutPos]; - float vecZ = zi - z + CELL_3D_Z[lutPos]; + FN_DECIMAL vecX = xi - x + CELL_3D_X[lutPos]; + FN_DECIMAL vecY = yi - y + CELL_3D_Y[lutPos]; + FN_DECIMAL vecZ = zi - z + CELL_3D_Z[lutPos]; - float newDistance = vecX * vecX + vecY * vecY + vecZ * vecZ; + FN_DECIMAL newDistance = vecX * vecX + vecY * vecY + vecZ * vecZ; if (newDistance < distance) { @@ -1706,11 +1706,11 @@ float FastNoise::SingleCellular(float x, float y, float z) { unsigned char lutPos = Index3D_256(0, xi, yi, zi); - float vecX = xi - x + CELL_3D_X[lutPos]; - float vecY = yi - y + CELL_3D_Y[lutPos]; - float vecZ = zi - z + CELL_3D_Z[lutPos]; + FN_DECIMAL vecX = xi - x + CELL_3D_X[lutPos]; + FN_DECIMAL vecY = yi - y + CELL_3D_Y[lutPos]; + FN_DECIMAL vecZ = zi - z + CELL_3D_Z[lutPos]; - float newDistance = FastAbs(vecX) + FastAbs(vecY) + FastAbs(vecZ); + FN_DECIMAL newDistance = FastAbs(vecX) + FastAbs(vecY) + FastAbs(vecZ); if (newDistance < distance) { @@ -1732,11 +1732,11 @@ float FastNoise::SingleCellular(float x, float y, float z) { unsigned char lutPos = Index3D_256(0, xi, yi, zi); - float vecX = xi - x + CELL_3D_X[lutPos]; - float vecY = yi - y + CELL_3D_Y[lutPos]; - float vecZ = zi - z + CELL_3D_Z[lutPos]; + FN_DECIMAL vecX = xi - x + CELL_3D_X[lutPos]; + FN_DECIMAL vecY = yi - y + CELL_3D_Y[lutPos]; + FN_DECIMAL vecZ = zi - z + CELL_3D_Z[lutPos]; - float newDistance = (FastAbs(vecX) + FastAbs(vecY) + FastAbs(vecZ)) + (vecX * vecX + vecY * vecY + vecZ * vecZ); + FN_DECIMAL newDistance = (FastAbs(vecX) + FastAbs(vecY) + FastAbs(vecZ)) + (vecX * vecX + vecY * vecY + vecZ * vecZ); if (newDistance < distance) { @@ -1766,20 +1766,20 @@ float FastNoise::SingleCellular(float x, float y, float z) return m_cellularNoiseLookup->GetNoise(xc + CELL_3D_X[lutPos], yc + CELL_3D_Y[lutPos], zc + CELL_3D_Z[lutPos]); case Distance: - return distance - 1.0f; + return distance - 1; default: - return 0.0f; + return 0; } } -float FastNoise::SingleCellular2Edge(float x, float y, float z) +FN_DECIMAL FastNoise::SingleCellular2Edge(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) { int xr = FastRound(x); int yr = FastRound(y); int zr = FastRound(z); - float distance = 999999.f; - float distance2 = 999999.f; + FN_DECIMAL distance = 999999; + FN_DECIMAL distance2 = 999999; switch (m_cellularDistanceFunction) { @@ -1792,14 +1792,14 @@ float FastNoise::SingleCellular2Edge(float x, float y, float z) { unsigned char lutPos = Index3D_256(0, xi, yi, zi); - float vecX = xi - x + CELL_3D_X[lutPos]; - float vecY = yi - y + CELL_3D_Y[lutPos]; - float vecZ = zi - z + CELL_3D_Z[lutPos]; + FN_DECIMAL vecX = xi - x + CELL_3D_X[lutPos]; + FN_DECIMAL vecY = yi - y + CELL_3D_Y[lutPos]; + FN_DECIMAL vecZ = zi - z + CELL_3D_Z[lutPos]; - float newDistance = vecX * vecX + vecY * vecY + vecZ * vecZ; + FN_DECIMAL newDistance = vecX * vecX + vecY * vecY + vecZ * vecZ; - distance2 = fmaxf(fminf(distance2, newDistance), distance); - distance = fminf(distance, newDistance); + distance2 = fmax(fmin(distance2, newDistance), distance); + distance = fmin(distance, newDistance); } } } @@ -1813,14 +1813,14 @@ float FastNoise::SingleCellular2Edge(float x, float y, float z) { unsigned char lutPos = Index3D_256(0, xi, yi, zi); - float vecX = xi - x + CELL_3D_X[lutPos]; - float vecY = yi - y + CELL_3D_Y[lutPos]; - float vecZ = zi - z + CELL_3D_Z[lutPos]; + FN_DECIMAL vecX = xi - x + CELL_3D_X[lutPos]; + FN_DECIMAL vecY = yi - y + CELL_3D_Y[lutPos]; + FN_DECIMAL vecZ = zi - z + CELL_3D_Z[lutPos]; - float newDistance = FastAbs(vecX) + FastAbs(vecY) + FastAbs(vecZ); + FN_DECIMAL newDistance = FastAbs(vecX) + FastAbs(vecY) + FastAbs(vecZ); - distance2 = fmaxf(fminf(distance2, newDistance), distance); - distance = fminf(distance, newDistance); + distance2 = fmax(fmin(distance2, newDistance), distance); + distance = fmin(distance, newDistance); } } } @@ -1834,14 +1834,14 @@ float FastNoise::SingleCellular2Edge(float x, float y, float z) { unsigned char lutPos = Index3D_256(0, xi, yi, zi); - float vecX = xi - x + CELL_3D_X[lutPos]; - float vecY = yi - y + CELL_3D_Y[lutPos]; - float vecZ = zi - z + CELL_3D_Z[lutPos]; + FN_DECIMAL vecX = xi - x + CELL_3D_X[lutPos]; + FN_DECIMAL vecY = yi - y + CELL_3D_Y[lutPos]; + FN_DECIMAL vecZ = zi - z + CELL_3D_Z[lutPos]; - float newDistance = (FastAbs(vecX) + FastAbs(vecY) + FastAbs(vecZ)) + (vecX * vecX + vecY * vecY + vecZ * vecZ); + FN_DECIMAL newDistance = (FastAbs(vecX) + FastAbs(vecY) + FastAbs(vecZ)) + (vecX * vecX + vecY * vecY + vecZ * vecZ); - distance2 = fmaxf(fminf(distance2, newDistance), distance); - distance = fminf(distance, newDistance); + distance2 = fmax(fmin(distance2, newDistance), distance); + distance = fmin(distance, newDistance); } } } @@ -1853,21 +1853,21 @@ float FastNoise::SingleCellular2Edge(float x, float y, float z) switch (m_cellularReturnType) { case Distance2: - return distance2 - 1.0f; + return distance2 - 1; case Distance2Add: - return distance2 + distance - 1.0f; + return distance2 + distance - 1; case Distance2Sub: - return distance2 - distance - 1.0f; + return distance2 - distance - 1; case Distance2Mul: - return distance2 * distance - 1.0f; + return distance2 * distance - 1; case Distance2Div: - return distance / distance2 - 1.0f; + return distance / distance2 - 1; default: - return 0.0f; + return 0; } } -float FastNoise::GetCellular(float x, float y) +FN_DECIMAL FastNoise::GetCellular(FN_DECIMAL x, FN_DECIMAL y) { x *= m_frequency; y *= m_frequency; @@ -1883,12 +1883,12 @@ float FastNoise::GetCellular(float x, float y) } } -float FastNoise::SingleCellular(float x, float y) +FN_DECIMAL FastNoise::SingleCellular(FN_DECIMAL x, FN_DECIMAL y) { int xr = FastRound(x); int yr = FastRound(y); - float distance = 999999.f; + FN_DECIMAL distance = 999999; int xc, yc; switch (m_cellularDistanceFunction) @@ -1901,10 +1901,10 @@ float FastNoise::SingleCellular(float x, float y) { unsigned char lutPos = Index2D_256(0, xi, yi); - float vecX = xi - x + CELL_2D_X[lutPos]; - float vecY = yi - y + CELL_2D_Y[lutPos]; + FN_DECIMAL vecX = xi - x + CELL_2D_X[lutPos]; + FN_DECIMAL vecY = yi - y + CELL_2D_Y[lutPos]; - float newDistance = vecX * vecX + vecY * vecY; + FN_DECIMAL newDistance = vecX * vecX + vecY * vecY; if (newDistance < distance) { @@ -1922,10 +1922,10 @@ float FastNoise::SingleCellular(float x, float y) { unsigned char lutPos = Index2D_256(0, xi, yi); - float vecX = xi - x + CELL_2D_X[lutPos]; - float vecY = yi - y + CELL_2D_Y[lutPos]; + FN_DECIMAL vecX = xi - x + CELL_2D_X[lutPos]; + FN_DECIMAL vecY = yi - y + CELL_2D_Y[lutPos]; - float newDistance = (FastAbs(vecX) + FastAbs(vecY)); + FN_DECIMAL newDistance = (FastAbs(vecX) + FastAbs(vecY)); if (newDistance < distance) { @@ -1943,10 +1943,10 @@ float FastNoise::SingleCellular(float x, float y) { unsigned char lutPos = Index2D_256(0, xi, yi); - float vecX = xi - x + CELL_2D_X[lutPos]; - float vecY = yi - y + CELL_2D_Y[lutPos]; + FN_DECIMAL vecX = xi - x + CELL_2D_X[lutPos]; + FN_DECIMAL vecY = yi - y + CELL_2D_Y[lutPos]; - float newDistance = (FastAbs(vecX) + FastAbs(vecY)) + (vecX * vecX + vecY * vecY); + FN_DECIMAL newDistance = (FastAbs(vecX) + FastAbs(vecY)) + (vecX * vecX + vecY * vecY); if (newDistance < distance) { @@ -1972,19 +1972,19 @@ float FastNoise::SingleCellular(float x, float y) return m_cellularNoiseLookup->GetNoise(xc + CELL_2D_X[lutPos], yc + CELL_2D_Y[lutPos]); case Distance: - return distance - 1.0f; + return distance - 1; default: - return 0.0f; + return 0; } } -float FastNoise::SingleCellular2Edge(float x, float y) +FN_DECIMAL FastNoise::SingleCellular2Edge(FN_DECIMAL x, FN_DECIMAL y) { int xr = FastRound(x); int yr = FastRound(y); - float distance = 999999.f; - float distance2 = 999999.f; + FN_DECIMAL distance = 999999; + FN_DECIMAL distance2 = 999999; switch (m_cellularDistanceFunction) { @@ -1996,13 +1996,13 @@ float FastNoise::SingleCellular2Edge(float x, float y) { unsigned char lutPos = Index2D_256(0, xi, yi); - float vecX = xi - x + CELL_2D_X[lutPos]; - float vecY = yi - y + CELL_2D_Y[lutPos]; + FN_DECIMAL vecX = xi - x + CELL_2D_X[lutPos]; + FN_DECIMAL vecY = yi - y + CELL_2D_Y[lutPos]; - float newDistance = vecX * vecX + vecY * vecY; + FN_DECIMAL newDistance = vecX * vecX + vecY * vecY; - distance2 = fmaxf(fminf(distance2, newDistance), distance); - distance = fminf(distance, newDistance); + distance2 = fmax(fmin(distance2, newDistance), distance); + distance = fmin(distance, newDistance); } } break; @@ -2013,13 +2013,13 @@ float FastNoise::SingleCellular2Edge(float x, float y) { unsigned char lutPos = Index2D_256(0, xi, yi); - float vecX = xi - x + CELL_2D_X[lutPos]; - float vecY = yi - y + CELL_2D_Y[lutPos]; + FN_DECIMAL vecX = xi - x + CELL_2D_X[lutPos]; + FN_DECIMAL vecY = yi - y + CELL_2D_Y[lutPos]; - float newDistance = FastAbs(vecX) + FastAbs(vecY); + FN_DECIMAL newDistance = FastAbs(vecX) + FastAbs(vecY); - distance2 = fmaxf(fminf(distance2, newDistance), distance); - distance = fminf(distance, newDistance); + distance2 = fmax(fmin(distance2, newDistance), distance); + distance = fmin(distance, newDistance); } } break; @@ -2030,13 +2030,13 @@ float FastNoise::SingleCellular2Edge(float x, float y) { unsigned char lutPos = Index2D_256(0, xi, yi); - float vecX = xi - x + CELL_2D_X[lutPos]; - float vecY = yi - y + CELL_2D_Y[lutPos]; + FN_DECIMAL vecX = xi - x + CELL_2D_X[lutPos]; + FN_DECIMAL vecY = yi - y + CELL_2D_Y[lutPos]; - float newDistance = (FastAbs(vecX) + FastAbs(vecY)) + (vecX * vecX + vecY * vecY); + FN_DECIMAL newDistance = (FastAbs(vecX) + FastAbs(vecY)) + (vecX * vecX + vecY * vecY); - distance2 = fmaxf(fminf(distance2, newDistance), distance); - distance = fminf(distance, newDistance); + distance2 = fmax(fmin(distance2, newDistance), distance); + distance = fmin(distance, newDistance); } } break; @@ -2045,29 +2045,29 @@ float FastNoise::SingleCellular2Edge(float x, float y) switch (m_cellularReturnType) { case Distance2: - return distance2 - 1.0f; + return distance2 - 1; case Distance2Add: - return distance2 + distance - 1.0f; + return distance2 + distance - 1; case Distance2Sub: - return distance2 - distance - 1.0f; + return distance2 - distance - 1; case Distance2Mul: - return distance2 * distance - 1.0f; + return distance2 * distance - 1; case Distance2Div: - return distance / distance2 - 1.0f; + return distance / distance2 - 1; default: - return 0.0f; + return 0; } } -void FastNoise::GradientPerturb(float& x, float& y, float& z) +void FastNoise::GradientPerturb(FN_DECIMAL& x, FN_DECIMAL& y, FN_DECIMAL& z) { SingleGradientPerturb(0, m_gradientPerturbAmp, m_frequency, x, y, z); } -void FastNoise::GradientPerturbFractal(float& x, float& y, float& z) +void FastNoise::GradientPerturbFractal(FN_DECIMAL& x, FN_DECIMAL& y, FN_DECIMAL& z) { - float amp = m_gradientPerturbAmp * m_fractalBounding; - float freq = m_frequency; + FN_DECIMAL amp = m_gradientPerturbAmp * m_fractalBounding; + FN_DECIMAL freq = m_frequency; int i = 0; SingleGradientPerturb(m_perm[0], amp, m_frequency, x, y, z); @@ -2080,11 +2080,11 @@ void FastNoise::GradientPerturbFractal(float& x, float& y, float& z) } } -void FastNoise::SingleGradientPerturb(unsigned char offset, float warpAmp, float frequency, float& x, float& y, float& z) +void FastNoise::SingleGradientPerturb(unsigned char offset, FN_DECIMAL warpAmp, FN_DECIMAL frequency, FN_DECIMAL& x, FN_DECIMAL& y, FN_DECIMAL& z) { - float xf = x * frequency; - float yf = y * frequency; - float zf = z * frequency; + FN_DECIMAL xf = x * frequency; + FN_DECIMAL yf = y * frequency; + FN_DECIMAL zf = z * frequency; int x0 = FastFloor(xf); int y0 = FastFloor(yf); @@ -2093,44 +2093,44 @@ void FastNoise::SingleGradientPerturb(unsigned char offset, float warpAmp, float int y1 = y0 + 1; int z1 = z0 + 1; - float xs, ys, zs; + FN_DECIMAL xs, ys, zs; switch (m_interp) { default: case Linear: - xs = xf - (float)x0; - ys = yf - (float)y0; - zs = zf - (float)z0; + xs = xf - (FN_DECIMAL)x0; + ys = yf - (FN_DECIMAL)y0; + zs = zf - (FN_DECIMAL)z0; break; case Hermite: - xs = InterpHermiteFunc(xf - (float)x0); - ys = InterpHermiteFunc(yf - (float)y0); - zs = InterpHermiteFunc(zf - (float)z0); + xs = InterpHermiteFunc(xf - (FN_DECIMAL)x0); + ys = InterpHermiteFunc(yf - (FN_DECIMAL)y0); + zs = InterpHermiteFunc(zf - (FN_DECIMAL)z0); break; case Quintic: - xs = InterpQuinticFunc(xf - (float)x0); - ys = InterpQuinticFunc(yf - (float)y0); - zs = InterpQuinticFunc(zf - (float)z0); + xs = InterpQuinticFunc(xf - (FN_DECIMAL)x0); + ys = InterpQuinticFunc(yf - (FN_DECIMAL)y0); + zs = InterpQuinticFunc(zf - (FN_DECIMAL)z0); break; } int lutPos0 = Index3D_256(offset, x0, y0, z0); int lutPos1 = Index3D_256(offset, x1, y0, z0); - float lx0x = Lerp(CELL_3D_X[lutPos0], CELL_3D_X[lutPos1], xs); - float ly0x = Lerp(CELL_3D_Y[lutPos0], CELL_3D_Y[lutPos1], xs); - float lz0x = Lerp(CELL_3D_Z[lutPos0], CELL_3D_Z[lutPos1], xs); + FN_DECIMAL lx0x = Lerp(CELL_3D_X[lutPos0], CELL_3D_X[lutPos1], xs); + FN_DECIMAL ly0x = Lerp(CELL_3D_Y[lutPos0], CELL_3D_Y[lutPos1], xs); + FN_DECIMAL lz0x = Lerp(CELL_3D_Z[lutPos0], CELL_3D_Z[lutPos1], xs); lutPos0 = Index3D_256(offset, x0, y1, z0); lutPos1 = Index3D_256(offset, x1, y1, z0); - float lx1x = Lerp(CELL_3D_X[lutPos0], CELL_3D_X[lutPos1], xs); - float ly1x = Lerp(CELL_3D_Y[lutPos0], CELL_3D_Y[lutPos1], xs); - float lz1x = Lerp(CELL_3D_Z[lutPos0], CELL_3D_Z[lutPos1], xs); + FN_DECIMAL lx1x = Lerp(CELL_3D_X[lutPos0], CELL_3D_X[lutPos1], xs); + FN_DECIMAL ly1x = Lerp(CELL_3D_Y[lutPos0], CELL_3D_Y[lutPos1], xs); + FN_DECIMAL lz1x = Lerp(CELL_3D_Z[lutPos0], CELL_3D_Z[lutPos1], xs); - float lx0y = Lerp(lx0x, lx1x, ys); - float ly0y = Lerp(ly0x, ly1x, ys); - float lz0y = Lerp(lz0x, lz1x, ys); + FN_DECIMAL lx0y = Lerp(lx0x, lx1x, ys); + FN_DECIMAL ly0y = Lerp(ly0x, ly1x, ys); + FN_DECIMAL lz0y = Lerp(lz0x, lz1x, ys); lutPos0 = Index3D_256(offset, x0, y0, z1); lutPos1 = Index3D_256(offset, x1, y0, z1); @@ -2151,15 +2151,15 @@ void FastNoise::SingleGradientPerturb(unsigned char offset, float warpAmp, float z += Lerp(lz0y, Lerp(lz0x, lz1x, ys), zs) * warpAmp; } -void FastNoise::GradientPerturb(float& x, float& y) +void FastNoise::GradientPerturb(FN_DECIMAL& x, FN_DECIMAL& y) { SingleGradientPerturb(0, m_gradientPerturbAmp, m_frequency, x, y); } -void FastNoise::GradientPerturbFractal(float& x, float& y) +void FastNoise::GradientPerturbFractal(FN_DECIMAL& x, FN_DECIMAL& y) { - float amp = m_gradientPerturbAmp * m_fractalBounding; - float freq = m_frequency; + FN_DECIMAL amp = m_gradientPerturbAmp * m_fractalBounding; + FN_DECIMAL freq = m_frequency; int i = 0; SingleGradientPerturb(m_perm[0], amp, m_frequency, x, y); @@ -2172,45 +2172,45 @@ void FastNoise::GradientPerturbFractal(float& x, float& y) } } -void FastNoise::SingleGradientPerturb(unsigned char offset, float warpAmp, float frequency, float& x, float& y) +void FastNoise::SingleGradientPerturb(unsigned char offset, FN_DECIMAL warpAmp, FN_DECIMAL frequency, FN_DECIMAL& x, FN_DECIMAL& y) { - float xf = x * frequency; - float yf = y * frequency; + FN_DECIMAL xf = x * frequency; + FN_DECIMAL yf = y * frequency; int x0 = FastFloor(xf); int y0 = FastFloor(yf); int x1 = x0 + 1; int y1 = y0 + 1; - float xs, ys; + FN_DECIMAL xs, ys; switch (m_interp) { default: case Linear: - xs = xf - (float)x0; - ys = yf - (float)y0; + xs = xf - (FN_DECIMAL)x0; + ys = yf - (FN_DECIMAL)y0; break; case Hermite: - xs = InterpHermiteFunc(xf - (float)x0); - ys = InterpHermiteFunc(yf - (float)y0); + xs = InterpHermiteFunc(xf - (FN_DECIMAL)x0); + ys = InterpHermiteFunc(yf - (FN_DECIMAL)y0); break; case Quintic: - xs = InterpQuinticFunc(xf - (float)x0); - ys = InterpQuinticFunc(yf - (float)y0); + xs = InterpQuinticFunc(xf - (FN_DECIMAL)x0); + ys = InterpQuinticFunc(yf - (FN_DECIMAL)y0); break; } int lutPos0 = Index2D_256(offset, x0, y0); int lutPos1 = Index2D_256(offset, x1, y0); - float lx0x = Lerp(CELL_2D_X[lutPos0], CELL_2D_X[lutPos1], xs); - float ly0x = Lerp(CELL_2D_Y[lutPos0], CELL_2D_Y[lutPos1], xs); + FN_DECIMAL lx0x = Lerp(CELL_2D_X[lutPos0], CELL_2D_X[lutPos1], xs); + FN_DECIMAL ly0x = Lerp(CELL_2D_Y[lutPos0], CELL_2D_Y[lutPos1], xs); lutPos0 = Index2D_256(offset, x0, y1); lutPos1 = Index2D_256(offset, x1, y1); - float lx1x = Lerp(CELL_2D_X[lutPos0], CELL_2D_X[lutPos1], xs); - float ly1x = Lerp(CELL_2D_Y[lutPos0], CELL_2D_Y[lutPos1], xs); + FN_DECIMAL lx1x = Lerp(CELL_2D_X[lutPos0], CELL_2D_X[lutPos1], xs); + FN_DECIMAL ly1x = Lerp(CELL_2D_Y[lutPos0], CELL_2D_Y[lutPos1], xs); x += Lerp(lx0x, lx1x, ys) * warpAmp; y += Lerp(ly0x, ly1x, ys) * warpAmp; diff --git a/FastNoise.h b/FastNoise.h index 6ef2c13..94bb351 100644 --- a/FastNoise.h +++ b/FastNoise.h @@ -29,6 +29,15 @@ #ifndef FASTNOISE_H #define FASTNOISE_H +// Uncomment the line below to use doubles throughout FastNoise instead of floats +//#define FN_USE_DOUBLES + +#ifdef FN_USE_DOUBLES +typedef double FN_DECIMAL; +#else +typedef float FN_DECIMAL; +#endif + class FastNoise { public: @@ -50,7 +59,7 @@ class FastNoise // Sets frequency for all noise types // Default: 0.01 - void SetFrequency(float frequency) { m_frequency = frequency; } + void SetFrequency(FN_DECIMAL frequency) { m_frequency = frequency; } // Changes the interpolation method used to smooth between noise values // Possible interpolation methods (lowest to highest quality) : @@ -71,11 +80,11 @@ class FastNoise // Sets octave lacunarity for all fractal noise types // Default: 2.0 - void SetFractalLacunarity(float lacunarity) { m_lacunarity = lacunarity; } + void SetFractalLacunarity(FN_DECIMAL lacunarity) { m_lacunarity = lacunarity; } // Sets octave gain for all fractal noise types // Default: 0.5 - void SetFractalGain(float gain) { m_gain = gain; CalculateFractalBounding(); } + void SetFractalGain(FN_DECIMAL gain) { m_gain = gain; CalculateFractalBounding(); } // Sets method for combining octaves in all fractal noise types // Default: FBM @@ -96,148 +105,148 @@ class FastNoise // Sets the maximum warp distance from original location when using GradientPerturb{Fractal}(...) // Default: 1.0 - void SetGradientPerturbAmp(float gradientPerturbAmp) { m_gradientPerturbAmp = gradientPerturbAmp / 0.45f; } + void SetGradientPerturbAmp(FN_DECIMAL gradientPerturbAmp) { m_gradientPerturbAmp = gradientPerturbAmp / 0.45f; } //2D - float GetValue(float x, float y); - float GetValueFractal(float x, float y); + FN_DECIMAL GetValue(FN_DECIMAL x, FN_DECIMAL y); + FN_DECIMAL GetValueFractal(FN_DECIMAL x, FN_DECIMAL y); - float GetPerlin(float x, float y); - float GetPerlinFractal(float x, float y); + FN_DECIMAL GetPerlin(FN_DECIMAL x, FN_DECIMAL y); + FN_DECIMAL GetPerlinFractal(FN_DECIMAL x, FN_DECIMAL y); - float GetSimplex(float x, float y); - float GetSimplexFractal(float x, float y); + FN_DECIMAL GetSimplex(FN_DECIMAL x, FN_DECIMAL y); + FN_DECIMAL GetSimplexFractal(FN_DECIMAL x, FN_DECIMAL y); - float GetCellular(float x, float y); + FN_DECIMAL GetCellular(FN_DECIMAL x, FN_DECIMAL y); - float GetWhiteNoise(float x, float y); - float GetWhiteNoiseInt(int x, int y); + FN_DECIMAL GetWhiteNoise(FN_DECIMAL x, FN_DECIMAL y); + FN_DECIMAL GetWhiteNoiseInt(int x, int y); - float GetCubic(float x, float y); - float GetCubicFractal(float x, float y); + FN_DECIMAL GetCubic(FN_DECIMAL x, FN_DECIMAL y); + FN_DECIMAL GetCubicFractal(FN_DECIMAL x, FN_DECIMAL y); - float GetNoise(float x, float y); + FN_DECIMAL GetNoise(FN_DECIMAL x, FN_DECIMAL y); - void GradientPerturb(float& x, float& y); - void GradientPerturbFractal(float& x, float& y); + void GradientPerturb(FN_DECIMAL& x, FN_DECIMAL& y); + void GradientPerturbFractal(FN_DECIMAL& x, FN_DECIMAL& y); //3D - float GetValue(float x, float y, float z); - float GetValueFractal(float x, float y, float z); + FN_DECIMAL GetValue(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); + FN_DECIMAL GetValueFractal(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); - float GetPerlin(float x, float y, float z); - float GetPerlinFractal(float x, float y, float z); + FN_DECIMAL GetPerlin(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); + FN_DECIMAL GetPerlinFractal(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); - float GetSimplex(float x, float y, float z); - float GetSimplexFractal(float x, float y, float z); + FN_DECIMAL GetSimplex(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); + FN_DECIMAL GetSimplexFractal(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); - float GetCellular(float x, float y, float z); + FN_DECIMAL GetCellular(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); - float GetWhiteNoise(float x, float y, float z); - float GetWhiteNoiseInt(int x, int y, int z); + FN_DECIMAL GetWhiteNoise(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); + FN_DECIMAL GetWhiteNoiseInt(int x, int y, int z); - float GetCubic(float x, float y, float z); - float GetCubicFractal(float x, float y, float z); + FN_DECIMAL GetCubic(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); + FN_DECIMAL GetCubicFractal(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); - float GetNoise(float x, float y, float z); + FN_DECIMAL GetNoise(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); - void GradientPerturb(float& x, float& y, float& z); - void GradientPerturbFractal(float& x, float& y, float& z); + void GradientPerturb(FN_DECIMAL& x, FN_DECIMAL& y, FN_DECIMAL& z); + void GradientPerturbFractal(FN_DECIMAL& x, FN_DECIMAL& y, FN_DECIMAL& z); //4D - float GetSimplex(float x, float y, float z, float w); + FN_DECIMAL GetSimplex(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z, FN_DECIMAL w); - float GetWhiteNoise(float x, float y, float z, float w); - float GetWhiteNoiseInt(int x, int y, int z, int w); + FN_DECIMAL GetWhiteNoise(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z, FN_DECIMAL w); + FN_DECIMAL GetWhiteNoiseInt(int x, int y, int z, int w); protected: unsigned char m_perm[512]; unsigned char m_perm12[512]; int m_seed = 1337; - float m_frequency = 0.01f; + FN_DECIMAL m_frequency = FN_DECIMAL(0.01); Interp m_interp = Quintic; NoiseType m_noiseType = Simplex; int m_octaves = 3; - float m_lacunarity = 2.0f; - float m_gain = 0.5f; + FN_DECIMAL m_lacunarity = FN_DECIMAL(2); + FN_DECIMAL m_gain = FN_DECIMAL(0.5); FractalType m_fractalType = FBM; - float m_fractalBounding; + FN_DECIMAL m_fractalBounding; void CalculateFractalBounding() { - float amp = m_gain; - float ampFractal = 1.0f; + FN_DECIMAL amp = m_gain; + FN_DECIMAL ampFractal = 1; for (int i = 1; i < m_octaves; i++) { ampFractal += amp; amp *= m_gain; } - m_fractalBounding = 1.0f / ampFractal; + m_fractalBounding = 1 / ampFractal; } CellularDistanceFunction m_cellularDistanceFunction = Euclidean; CellularReturnType m_cellularReturnType = CellValue; FastNoise* m_cellularNoiseLookup = nullptr; - float m_gradientPerturbAmp = 1.0f / 0.45f; + FN_DECIMAL m_gradientPerturbAmp = 1 / FN_DECIMAL(0.45); //2D - float SingleValueFractalFBM(float x, float y); - float SingleValueFractalBillow(float x, float y); - float SingleValueFractalRigidMulti(float x, float y); - float SingleValue(unsigned char offset, float x, float y); + FN_DECIMAL SingleValueFractalFBM(FN_DECIMAL x, FN_DECIMAL y); + FN_DECIMAL SingleValueFractalBillow(FN_DECIMAL x, FN_DECIMAL y); + FN_DECIMAL SingleValueFractalRigidMulti(FN_DECIMAL x, FN_DECIMAL y); + FN_DECIMAL SingleValue(unsigned char offset, FN_DECIMAL x, FN_DECIMAL y); - float SinglePerlinFractalFBM(float x, float y); - float SinglePerlinFractalBillow(float x, float y); - float SinglePerlinFractalRigidMulti(float x, float y); - float SinglePerlin(unsigned char offset, float x, float y); + FN_DECIMAL SinglePerlinFractalFBM(FN_DECIMAL x, FN_DECIMAL y); + FN_DECIMAL SinglePerlinFractalBillow(FN_DECIMAL x, FN_DECIMAL y); + FN_DECIMAL SinglePerlinFractalRigidMulti(FN_DECIMAL x, FN_DECIMAL y); + FN_DECIMAL SinglePerlin(unsigned char offset, FN_DECIMAL x, FN_DECIMAL y); - float SingleSimplexFractalFBM(float x, float y); - float SingleSimplexFractalBillow(float x, float y); - float SingleSimplexFractalRigidMulti(float x, float y); - float SingleSimplexFractalBlend(float x, float y); - float SingleSimplex(unsigned char offset, float x, float y); + FN_DECIMAL SingleSimplexFractalFBM(FN_DECIMAL x, FN_DECIMAL y); + FN_DECIMAL SingleSimplexFractalBillow(FN_DECIMAL x, FN_DECIMAL y); + FN_DECIMAL SingleSimplexFractalRigidMulti(FN_DECIMAL x, FN_DECIMAL y); + FN_DECIMAL SingleSimplexFractalBlend(FN_DECIMAL x, FN_DECIMAL y); + FN_DECIMAL SingleSimplex(unsigned char offset, FN_DECIMAL x, FN_DECIMAL y); - float SingleCubicFractalFBM(float x, float y); - float SingleCubicFractalBillow(float x, float y); - float SingleCubicFractalRigidMulti(float x, float y); - float SingleCubic(unsigned char offset, float x, float y); + FN_DECIMAL SingleCubicFractalFBM(FN_DECIMAL x, FN_DECIMAL y); + FN_DECIMAL SingleCubicFractalBillow(FN_DECIMAL x, FN_DECIMAL y); + FN_DECIMAL SingleCubicFractalRigidMulti(FN_DECIMAL x, FN_DECIMAL y); + FN_DECIMAL SingleCubic(unsigned char offset, FN_DECIMAL x, FN_DECIMAL y); - float SingleCellular(float x, float y); - float SingleCellular2Edge(float x, float y); + FN_DECIMAL SingleCellular(FN_DECIMAL x, FN_DECIMAL y); + FN_DECIMAL SingleCellular2Edge(FN_DECIMAL x, FN_DECIMAL y); - void SingleGradientPerturb(unsigned char offset, float warpAmp, float frequency, float& x, float& y); + void SingleGradientPerturb(unsigned char offset, FN_DECIMAL warpAmp, FN_DECIMAL frequency, FN_DECIMAL& x, FN_DECIMAL& y); //3D - float SingleValueFractalFBM(float x, float y, float z); - float SingleValueFractalBillow(float x, float y, float z); - float SingleValueFractalRigidMulti(float x, float y, float z); - float SingleValue(unsigned char offset, float x, float y, float z); + FN_DECIMAL SingleValueFractalFBM(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); + FN_DECIMAL SingleValueFractalBillow(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); + FN_DECIMAL SingleValueFractalRigidMulti(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); + FN_DECIMAL SingleValue(unsigned char offset, FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); - float SinglePerlinFractalFBM(float x, float y, float z); - float SinglePerlinFractalBillow(float x, float y, float z); - float SinglePerlinFractalRigidMulti(float x, float y, float z); - float SinglePerlin(unsigned char offset, float x, float y, float z); + FN_DECIMAL SinglePerlinFractalFBM(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); + FN_DECIMAL SinglePerlinFractalBillow(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); + FN_DECIMAL SinglePerlinFractalRigidMulti(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); + FN_DECIMAL SinglePerlin(unsigned char offset, FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); - float SingleSimplexFractalFBM(float x, float y, float z); - float SingleSimplexFractalBillow(float x, float y, float z); - float SingleSimplexFractalRigidMulti(float x, float y, float z); - float SingleSimplex(unsigned char offset, float x, float y, float z); + FN_DECIMAL SingleSimplexFractalFBM(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); + FN_DECIMAL SingleSimplexFractalBillow(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); + FN_DECIMAL SingleSimplexFractalRigidMulti(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); + FN_DECIMAL SingleSimplex(unsigned char offset, FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); - float SingleCubicFractalFBM(float x, float y, float z); - float SingleCubicFractalBillow(float x, float y, float z); - float SingleCubicFractalRigidMulti(float x, float y, float z); - float SingleCubic(unsigned char offset, float x, float y, float z); + FN_DECIMAL SingleCubicFractalFBM(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); + FN_DECIMAL SingleCubicFractalBillow(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); + FN_DECIMAL SingleCubicFractalRigidMulti(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); + FN_DECIMAL SingleCubic(unsigned char offset, FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); - float SingleCellular(float x, float y, float z); - float SingleCellular2Edge(float x, float y, float z); + FN_DECIMAL SingleCellular(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); + FN_DECIMAL SingleCellular2Edge(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z); - void SingleGradientPerturb(unsigned char offset, float warpAmp, float frequency, float& x, float& y, float& z); + void SingleGradientPerturb(unsigned char offset, FN_DECIMAL warpAmp, FN_DECIMAL frequency, FN_DECIMAL& x, FN_DECIMAL& y, FN_DECIMAL& z); //4D - float SingleSimplex(unsigned char offset, float x, float y, float z, float w); + FN_DECIMAL SingleSimplex(unsigned char offset, FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z, FN_DECIMAL w); private: inline unsigned char Index2D_12(unsigned char offset, int x, int y); inline unsigned char Index3D_12(unsigned char offset, int x, int y, int z); @@ -246,10 +255,10 @@ class FastNoise inline unsigned char Index3D_256(unsigned char offset, int x, int y, int z); inline unsigned char Index4D_256(unsigned char offset, int x, int y, int z, int w); - inline float ValCoord2DFast(unsigned char offset, int x, int y); - inline float ValCoord3DFast(unsigned char offset, int x, int y, int z); - inline float GradCoord2D(unsigned char offset, int x, int y, float xd, float yd); - inline float GradCoord3D(unsigned char offset, int x, int y, int z, float xd, float yd, float zd); - inline float GradCoord4D(unsigned char offset, int x, int y, int z, int w, float xd, float yd, float zd, float wd); + inline FN_DECIMAL ValCoord2DFast(unsigned char offset, int x, int y); + inline FN_DECIMAL ValCoord3DFast(unsigned char offset, int x, int y, int z); + inline FN_DECIMAL GradCoord2D(unsigned char offset, int x, int y, FN_DECIMAL xd, FN_DECIMAL yd); + inline FN_DECIMAL GradCoord3D(unsigned char offset, int x, int y, int z, FN_DECIMAL xd, FN_DECIMAL yd, FN_DECIMAL zd); + inline FN_DECIMAL GradCoord4D(unsigned char offset, int x, int y, int z, int w, FN_DECIMAL xd, FN_DECIMAL yd, FN_DECIMAL zd, FN_DECIMAL wd); }; #endif