• API
• FAQ
• Tools
• Archive
daily pastebin goal
1%
SHARE
TWEET

a guest Dec 18th, 2018 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
2. index 2e47d74a414..858b76b1fd5 100644
5. @@ -98,68 +98,62 @@ void voronoi_m(point p, string metric, float e, float da[4], point pa[4])
6.  /* Voronoi */
7.
9.     int use_mapping = 0,
10.     matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
11.     string coloring = "intensity",
12.     string metric = "distance",
13.     string feature = "F1",
14.     float Exponent = 1.0,
15.     float Scale = 5.0,
16.     point Vector = P,
17.     output float Fac = 0.0,
18. -   output color Color = 0.0)
19. +   output color Color = 0.0,
20. +   output point outVector = (0, 0, 0))
21.  {
22.     point p = Vector;
23.
24.     if (use_mapping)
25.         p = transform(mapping, p);
26.
27.     /* compute distance and point coordinate of 4 nearest neighbours */
28.     float da[4];
29.     point pa[4];
30.
31.     /* compute distance and point coordinate of 4 nearest neighbours */
32.     voronoi_m(p * Scale, metric, Exponent, da, pa);
33.
34. +   /* Default: F1 => Closest point */
35. +   int   idx     = 0;
36. +   point pOut    = p;
37. +   point vOffset = (0, 0, 0);
38. +   float dOffset = 0.0;
39. +
40. +   if (feature == "F2") {
41. +       idx = 1;
42. +   }
43. +   else if (feature == "F3") {
44. +       idx = 2;
45. +   }
46. +   else if (feature == "F4") {
47. +       idx = 3;
48. +   }
49. +   else if (feature == "F2F1") {
50. +       /* F2 - F1 */
51. +       idx     = 1;
52. +       pOut    = pa[0];
53. +       vOffset = pa[0];
54. +       dOffset = da[0];
55. +   }
56. +   outVector = pa[idx] - pOut;
57.     if (coloring == "intensity") {
58.         /* Intensity output */
59. -       if (feature == "F1") {
60. -           Fac = fabs(da[0]);
61. -       }
62. -       else if (feature == "F2") {
63. -           Fac = fabs(da[1]);
64. -       }
65. -       else if (feature == "F3") {
66. -           Fac = fabs(da[2]);
67. -       }
68. -       else if (feature == "F4") {
69. -           Fac = fabs(da[3]);
70. -       }
71. -       else if (feature == "F2F1") {
72. -           Fac = fabs(da[1] - da[0]);
73. -       }
74. +       Fac = fabs(da[idx] - dOffset);
75.         Color = color(Fac);
76. -   }
77. -   else {
78. +   } else {
79.         /* Color output */
80. -       if (feature == "F1") {
81. -           Color = pa[0];
82. -       }
83. -       else if (feature == "F2") {
84. -           Color = pa[1];
85. -       }
86. -       else if (feature == "F3") {
87. -           Color = pa[2];
88. -       }
89. -       else if (feature == "F4") {
90. -           Color = pa[3];
91. -       }
92. -       else if (feature == "F2F1") {
93. -           Color = fabs(pa[1] - pa[0]);
94. -       }
95. -
96. +       Color = pa[idx] - vOffset;
97.         Color = cellnoise_color(Color);
98.         Fac = (Color[0] + Color[1] + Color[2]) * (1.0 / 3.0);
99.     }
100.  }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top