*/}}

ournodes.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. /*
  2. * Our Paint: A light weight GPU powered painting program.
  3. * Copyright (C) 2022-2023 Wu Yiming
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include "ourpaint.h"
  19. extern LA MAIN;
  20. extern tnsMain* T;
  21. extern OurPaint *Our;
  22. laBaseNodeType OUR_IDN_BRUSH_SETTINGS;
  23. laBaseNodeType OUR_IDN_BRUSH_OUTPUTS;
  24. laBaseNodeType OUR_IDN_BRUSH_DEVICE;
  25. laPropContainer* OUR_PC_IDN_BRUSH_SETTINGS;
  26. laPropContainer* OUR_PC_IDN_BRUSH_OUTPUTS;
  27. laPropContainer* OUR_PC_IDN_BRUSH_DEVICE;
  28. void IDN_BrushSettingsInit(OurBrushSettingsNode* n, int NoCreate){
  29. if(!NoCreate){
  30. n->CanvasScale=laCreateOutSocket(n,"Canvas Scale",LA_PROP_FLOAT);
  31. n->Size=laCreateOutSocket(n,"SIZE",LA_PROP_FLOAT);
  32. n->Transparency=laCreateOutSocket(n,"TRANSP",LA_PROP_FLOAT);
  33. n->Hardness=laCreateOutSocket(n,"HARD",LA_PROP_FLOAT);
  34. n->Smudge=laCreateOutSocket(n,"SMUDGE",LA_PROP_FLOAT);
  35. n->SmudgeLength=laCreateOutSocket(n,"LEN",LA_PROP_FLOAT);
  36. n->DabsPerSize=laCreateOutSocket(n,"Dabs Per Size",LA_PROP_FLOAT);
  37. n->Slender=laCreateOutSocket(n,"SLENDER",LA_PROP_FLOAT);
  38. n->Angle=laCreateOutSocket(n,"ANGLE",LA_PROP_FLOAT);
  39. n->Color=laCreateOutSocket(n,"COLOR",LA_PROP_FLOAT|LA_PROP_ARRAY);
  40. strSafeSet(&n->Base.Name, "Brush Settings");
  41. }
  42. if(!n->Iteration) n->Iteration=laCreateOutSocket(n,"ITER",LA_PROP_INT);
  43. if(!n->Custom1) n->Custom1=laCreateOutSocket(n,"C1",LA_PROP_FLOAT);
  44. if(!n->Custom2) n->Custom2=laCreateOutSocket(n,"C2",LA_PROP_FLOAT);
  45. if(!n->Gunkyness) n->Gunkyness=laCreateOutSocket(n,"GUNKY",LA_PROP_FLOAT);
  46. if(!n->Force) n->Force=laCreateOutSocket(n,"FORCE",LA_PROP_FLOAT);
  47. n->CanvasScale->Data=&n->rCanvasScale;
  48. n->Size->Data=&n->rSize;
  49. n->Transparency->Data=&n->rTransparency;
  50. n->Hardness->Data=&n->rHardness;
  51. n->Smudge->Data=&n->rSmudge;
  52. n->SmudgeLength->Data=&n->rSmudgeLength;
  53. n->DabsPerSize->Data=&n->rDabsPerSize;
  54. n->Slender->Data=&n->rSlender;
  55. n->Angle->Data=&n->rAngle;
  56. n->Color->Data=Our->CurrentColor; n->Color->ArrLen=3;
  57. n->Gunkyness->Data=&n->rGunkyness;
  58. n->Force->Data=&n->rForce;
  59. n->Iteration->Data=&n->rIteration;
  60. n->Custom1->Data=&n->rCustom1;
  61. n->Custom2->Data=&n->rCustom2;
  62. }
  63. void IDN_BrushSettingsDestroy(OurBrushSettingsNode* n){
  64. laDestroyOutSocket(n->Size); laDestroyOutSocket(n->Transparency); laDestroyOutSocket(n->Hardness); laDestroyOutSocket(n->Smudge);
  65. laDestroyOutSocket(n->SmudgeLength); laDestroyOutSocket(n->DabsPerSize); laDestroyOutSocket(n->Slender); laDestroyOutSocket(n->Angle);
  66. laDestroyOutSocket(n->CanvasScale); laDestroyOutSocket(n->Iteration); laDestroyOutSocket(n->Custom1); laDestroyOutSocket(n->Custom2);
  67. laDestroyOutSocket(n->Gunkyness); laDestroyOutSocket(n->Force);
  68. strSafeDestroy(&n->Base.Name);
  69. }
  70. int IDN_BrushSettingsVisit(OurBrushSettingsNode* n, laNodeVisitInfo* vi){
  71. LA_GUARD_THIS_NODE(n,vi); LA_ADD_THIS_NODE(n,vi);
  72. return LA_DAG_FLAG_PERM;
  73. }
  74. int IDN_BrushSettingsEval(OurBrushSettingsNode* n){
  75. if(!Our->CurrentBrush){ return 0; } // unlikely;
  76. n->rCanvasScale = Our->CurrentScale;
  77. n->rSize = OUR_BRUSH_ACTUAL_SIZE(Our->CurrentBrush);
  78. n->rTransparency = Our->CurrentBrush->Transparency;
  79. n->rHardness = Our->CurrentBrush->Hardness;
  80. n->rSmudge = Our->CurrentBrush->Smudge;
  81. n->rSmudgeLength = Our->CurrentBrush->SmudgeResampleLength;
  82. n->rDabsPerSize = Our->CurrentBrush->DabsPerSize;
  83. n->rSlender = Our->CurrentBrush->Slender;
  84. n->rAngle = Our->CurrentBrush->Angle;
  85. n->rGunkyness = Our->CurrentBrush->Gunkyness;
  86. n->rForce = Our->CurrentBrush->Force;
  87. n->rIteration = Our->CurrentBrush->Iteration;
  88. n->rCustom1 = Our->CurrentBrush->Custom1;
  89. n->rCustom2 = Our->CurrentBrush->Custom2;
  90. return 1;
  91. }
  92. void IDN_BrushSettingsCopy(OurBrushSettingsNode* new, OurBrushSettingsNode* old, int DoRematch){
  93. if(DoRematch){ return;}
  94. LA_IDN_OLD_DUPL(Angle) LA_IDN_OLD_DUPL(CanvasScale)
  95. LA_IDN_OLD_DUPL(Color) LA_IDN_OLD_DUPL(Custom1)
  96. LA_IDN_OLD_DUPL(Custom2) LA_IDN_OLD_DUPL(DabsPerSize)
  97. LA_IDN_OLD_DUPL(Hardness) LA_IDN_OLD_DUPL(Iteration)
  98. LA_IDN_OLD_DUPL(Size) LA_IDN_OLD_DUPL(Slender)
  99. LA_IDN_OLD_DUPL(Smudge) LA_IDN_OLD_DUPL(SmudgeLength)
  100. LA_IDN_OLD_DUPL(Transparency)LA_IDN_OLD_DUPL(Gunkyness)
  101. LA_IDN_OLD_DUPL(Force)
  102. }
  103. void ui_BrushSettingsNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  104. laColumn* c=laFirstColumn(uil); OurBrushSettingsNode*n=This->EndInstance;
  105. laUiItem* b,*u;
  106. LA_BASE_NODE_HEADER(uil,c,This);
  107. b=laBeginRow(uil,c,0,0);
  108. laShowSeparator(uil,c)->Expand=1;
  109. laShowNodeSocket(uil,c,This,"size",0)->Flags|=LA_UI_SOCKET_LABEL_N;
  110. laShowNodeSocket(uil,c,This,"transparency",0)->Flags|=LA_UI_SOCKET_LABEL_N;
  111. laShowNodeSocket(uil,c,This,"hardness",0)->Flags|=LA_UI_SOCKET_LABEL_N;
  112. laShowNodeSocket(uil,c,This,"slender",0)->Flags|=LA_UI_SOCKET_LABEL_N;
  113. laShowNodeSocket(uil,c,This,"angle",0)->Flags|=LA_UI_SOCKET_LABEL_N;
  114. laShowNodeSocket(uil,c,This,"color",0)->Flags|=LA_UI_SOCKET_LABEL_N;
  115. laEndRow(uil,b);
  116. b=laBeginRow(uil,c,0,0);
  117. laShowSeparator(uil,c)->Expand=1;
  118. laShowNodeSocket(uil,c,This,"smudge_length",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  119. laShowNodeSocket(uil,c,This,"smudge",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  120. laEndRow(uil,b);
  121. b=laBeginRow(uil,c,0,0);
  122. laShowSeparator(uil,c)->Expand=1;
  123. laShowNodeSocket(uil,c,This,"gunkyness",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  124. laShowNodeSocket(uil,c,This,"force",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  125. laEndRow(uil,b);
  126. b=laBeginRow(uil,c,0,0); u=laShowLabel(uil,c,"Canvas Scale",0,0);u->Flags|=LA_TEXT_ALIGN_RIGHT; u->Expand=1; laShowNodeSocket(uil,c,This,"canvas_scale",0);
  127. u=laShowLabel(uil,c,"Dabs Per Size",0,0);u->Flags|=LA_TEXT_ALIGN_RIGHT; u->Expand=1; laShowNodeSocket(uil,c,This,"dabs_per_size",0); laEndRow(uil,b);
  128. b=laBeginRow(uil,c,0,0);
  129. laShowSeparator(uil,c)->Expand=1; laShowNodeSocket(uil,c,This,"iteration",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  130. laEndRow(uil,b);
  131. b=laBeginRow(uil,c,0,0); u=laShowItem(uil,c,0,"our.tools.current_brush.c1_name");u->Flags|=LA_UI_FLAGS_PLAIN|LA_TEXT_ALIGN_RIGHT; u->Expand=1;
  132. laShowNodeSocket(uil,c,This,"c1",0); laEndRow(uil,b);
  133. b=laBeginRow(uil,c,0,0); u=laShowItem(uil,c,0,"our.tools.current_brush.c2_name");u->Flags|=LA_UI_FLAGS_PLAIN|LA_TEXT_ALIGN_RIGHT; u->Expand=1;
  134. laShowNodeSocket(uil,c,This,"c2",0); laEndRow(uil,b);
  135. }
  136. void IDN_BrushOutputsInit(OurBrushOutputsNode* n, int NoCreate){
  137. if(!NoCreate){
  138. n->Offset=laCreateInSocket("OFFSET",LA_PROP_FLOAT);
  139. n->Size=laCreateInSocket("SIZE",LA_PROP_FLOAT);
  140. n->Transparency=laCreateInSocket("TRANSP",LA_PROP_FLOAT);
  141. n->Hardness=laCreateInSocket("HRAD",LA_PROP_FLOAT);
  142. n->Smudge=laCreateInSocket("SMUDGE",LA_PROP_FLOAT);
  143. n->SmudgeLength=laCreateInSocket("LENGTH",LA_PROP_FLOAT);
  144. n->DabsPerSize=laCreateInSocket("Dabs Per Size",LA_PROP_FLOAT);
  145. n->Slender=laCreateInSocket("SLENDER",LA_PROP_FLOAT);
  146. n->Angle=laCreateInSocket("ANGLE",LA_PROP_FLOAT);
  147. n->Color=laCreateInSocket("COLOR",LA_PROP_FLOAT);
  148. }
  149. if(!n->Repeats) n->Repeats=laCreateInSocket("REPEATS",LA_PROP_INT);
  150. if(!n->Discard) n->Discard=laCreateInSocket("DISCARD",LA_PROP_INT);
  151. if(!n->Gunkyness) n->Gunkyness=laCreateInSocket("GUNKY",LA_PROP_FLOAT);
  152. if(!n->Force) n->Force=laCreateInSocket("FORCE",LA_PROP_FLOAT);
  153. strSafeSet(&n->Base.Name, "Brush Outputs");
  154. }
  155. void IDN_BrushOutputsDestroy(OurBrushOutputsNode* n){
  156. laDestroyInSocket(n->Offset);
  157. laDestroyInSocket(n->Size); laDestroyInSocket(n->Transparency); laDestroyInSocket(n->Hardness); laDestroyInSocket(n->Smudge);
  158. laDestroyInSocket(n->SmudgeLength); laDestroyInSocket(n->DabsPerSize); laDestroyInSocket(n->Slender); laDestroyInSocket(n->Angle);
  159. laDestroyInSocket(n->Color); laDestroyInSocket(n->Repeats); laDestroyInSocket(n->Discard);
  160. laDestroyInSocket(n->Gunkyness); laDestroyInSocket(n->Force);
  161. strSafeDestroy(&n->Base.Name);
  162. }
  163. int IDN_BrushOutputsVisit(OurBrushOutputsNode* n, laNodeVisitInfo* vi){
  164. LA_GUARD_THIS_NODE(n,vi);
  165. #define BRUSH_OUT_VISIT(a) \
  166. if(LA_SRC_AND_PARENT(n->a)){ laBaseNode*bn=n->a->Source->Parent; LA_VISIT_NODE(bn,vi); }
  167. BRUSH_OUT_VISIT(Offset) BRUSH_OUT_VISIT(Size) BRUSH_OUT_VISIT(Transparency)
  168. BRUSH_OUT_VISIT(Hardness) BRUSH_OUT_VISIT(Smudge) BRUSH_OUT_VISIT(SmudgeLength)
  169. BRUSH_OUT_VISIT(DabsPerSize) BRUSH_OUT_VISIT(Slender) BRUSH_OUT_VISIT(Angle)
  170. BRUSH_OUT_VISIT(Color) BRUSH_OUT_VISIT(Repeats) BRUSH_OUT_VISIT(Discard)
  171. BRUSH_OUT_VISIT(Gunkyness) BRUSH_OUT_VISIT(Force)
  172. #undef BRUSH_OUT_VISIT
  173. LA_ADD_THIS_NODE(n,vi);
  174. return LA_DAG_FLAG_PERM;
  175. }
  176. int IDN_BrushOutputsEval(OurBrushOutputsNode* n){
  177. if(!Our->CurrentBrush) return 0;
  178. #define BRUSH_OUT_EVAL(a) \
  179. if(LA_SRC_AND_PARENT(n->a)){ \
  180. if(n->a->Source->DataType&LA_PROP_INT){ Our->CurrentBrush->Eval##a=*((int*)n->a->Source->Data); } \
  181. if(n->a->Source->DataType&LA_PROP_FLOAT){ Our->CurrentBrush->Eval##a=*((real*)n->a->Source->Data); } \
  182. }
  183. if(LA_SRC_AND_PARENT(n->Offset) && (n->Offset->Source->DataType&LA_PROP_FLOAT|LA_PROP_ARRAY) && n->Offset->Source->ArrLen>=2){
  184. Our->CurrentBrush->EvalOffset[0]=((real*)n->Offset->Source->Data)[0];
  185. Our->CurrentBrush->EvalOffset[1]=((real*)n->Offset->Source->Data)[1];
  186. }
  187. if(LA_SRC_AND_PARENT(n->Color) && (n->Color->Source->DataType&LA_PROP_FLOAT|LA_PROP_ARRAY) && n->Color->Source->ArrLen>=3){
  188. Our->CurrentBrush->EvalColor[0]=((real*)n->Color->Source->Data)[0];
  189. Our->CurrentBrush->EvalColor[1]=((real*)n->Color->Source->Data)[1];
  190. Our->CurrentBrush->EvalColor[2]=((real*)n->Color->Source->Data)[2];
  191. }
  192. BRUSH_OUT_EVAL(Size)
  193. BRUSH_OUT_EVAL(Transparency)
  194. BRUSH_OUT_EVAL(Hardness)
  195. BRUSH_OUT_EVAL(Smudge)
  196. BRUSH_OUT_EVAL(SmudgeLength)
  197. BRUSH_OUT_EVAL(DabsPerSize)
  198. BRUSH_OUT_EVAL(Slender)
  199. BRUSH_OUT_EVAL(Angle)
  200. BRUSH_OUT_EVAL(Gunkyness)
  201. BRUSH_OUT_EVAL(Force)
  202. BRUSH_OUT_EVAL(Repeats)
  203. BRUSH_OUT_EVAL(Discard)
  204. #undef BRUSH_OUT_EVAL
  205. return 1;
  206. }
  207. void IDN_BrushOutputsCopy(OurBrushOutputsNode* new, OurBrushOutputsNode* old, int DoRematch){
  208. if(DoRematch){
  209. LA_IDN_NEW_LINK(Offset) LA_IDN_NEW_LINK(Size) LA_IDN_NEW_LINK(Transparency) LA_IDN_NEW_LINK(Hardness)
  210. LA_IDN_NEW_LINK(Smudge) LA_IDN_NEW_LINK(SmudgeLength) LA_IDN_NEW_LINK(DabsPerSize) LA_IDN_NEW_LINK(Slender)
  211. LA_IDN_NEW_LINK(Angle) LA_IDN_NEW_LINK(Color) LA_IDN_NEW_LINK(Repeats) LA_IDN_NEW_LINK(Discard)
  212. LA_IDN_NEW_LINK(Gunkyness) LA_IDN_NEW_LINK(Force)
  213. return;
  214. }
  215. return;
  216. }
  217. void ui_BrushOutputsNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  218. laColumn* c=laFirstColumn(uil); OurBrushOutputsNode*n=This->EndInstance;
  219. laUiItem* b,*u;
  220. LA_BASE_NODE_HEADER(uil,c,This);
  221. b=laBeginRow(uil,c,0,0);
  222. laShowNodeSocket(uil,c,This,"offset",0)->Flags|=LA_UI_SOCKET_LABEL_N;
  223. laShowNodeSocket(uil,c,This,"size",0)->Flags|=LA_UI_SOCKET_LABEL_N;
  224. laShowNodeSocket(uil,c,This,"transparency",0)->Flags|=LA_UI_SOCKET_LABEL_N;
  225. laShowNodeSocket(uil,c,This,"hardness",0)->Flags|=LA_UI_SOCKET_LABEL_N;
  226. laShowNodeSocket(uil,c,This,"slender",0)->Flags|=LA_UI_SOCKET_LABEL_N;
  227. laShowNodeSocket(uil,c,This,"angle",0)->Flags|=LA_UI_SOCKET_LABEL_N;
  228. laShowNodeSocket(uil,c,This,"color",0)->Flags|=LA_UI_SOCKET_LABEL_N;
  229. laEndRow(uil,b);
  230. b=laBeginRow(uil,c,0,0);
  231. laShowNodeSocket(uil,c,This,"smudge",0)->Flags|=LA_UI_SOCKET_LABEL_E;
  232. laShowNodeSocket(uil,c,This,"smudge_length",0)->Flags|=LA_UI_SOCKET_LABEL_E;
  233. laEndRow(uil,b);
  234. b=laBeginRow(uil,c,0,0);
  235. laShowNodeSocket(uil,c,This,"gunkyness",0)->Flags|=LA_UI_SOCKET_LABEL_E;
  236. laShowNodeSocket(uil,c,This,"force",0)->Flags|=LA_UI_SOCKET_LABEL_E;
  237. laEndRow(uil,b);
  238. b=laBeginRow(uil,c,0,0); laShowNodeSocket(uil,c,This,"dabs_per_size",0); laShowLabel(uil,c,"Dabs Per Size",0,0); laEndRow(uil,b);
  239. b=laBeginRow(uil,c,0,0);
  240. laShowNodeSocket(uil,c,This,"repeats",0)->Flags|=LA_UI_SOCKET_LABEL_E;
  241. laShowNodeSocket(uil,c,This,"discard",0)->Flags|=LA_UI_SOCKET_LABEL_E;
  242. laEndRow(uil,b);
  243. }
  244. void IDN_BrushDeviceInit(OurBrushDeviceNode* n, int NoCreate){
  245. if(!NoCreate){
  246. n->Pressure=laCreateOutSocket(n,"PRESSURE",LA_PROP_FLOAT);
  247. n->Tilt=laCreateOutSocket(n,"TILT",LA_PROP_FLOAT|LA_PROP_ARRAY);
  248. n->IsEraser=laCreateOutSocket(n,"ERASER",LA_PROP_INT);
  249. n->Position=laCreateOutSocket(n,"POS",LA_PROP_FLOAT|LA_PROP_ARRAY);
  250. n->Speed=laCreateOutSocket(n,"SPD",LA_PROP_FLOAT);
  251. n->Angle=laCreateOutSocket(n,"ANGLE",LA_PROP_FLOAT);
  252. n->Length=laCreateOutSocket(n,"LENGTH",LA_PROP_FLOAT);
  253. n->LengthAccum=laCreateOutSocket(n,"ACUM",LA_PROP_FLOAT);
  254. strSafeSet(&n->Base.Name, "Brush Device");
  255. }
  256. if(!n->Twist){ n->Twist=laCreateOutSocket(n,"TWIST",LA_PROP_FLOAT); }
  257. n->Pressure->Data=&n->rPressure;
  258. n->Tilt->Data=n->rTilt; n->Tilt->ArrLen=2;
  259. n->Twist->Data=&n->rTwist;
  260. n->IsEraser->Data=&n->rIsEraser;
  261. n->Position->Data=n->rPosition; n->Position->ArrLen=2;
  262. n->Speed->Data=&n->rSpeed;
  263. n->Angle->Data=&n->rAngle;
  264. n->Length->Data=&n->rLength;
  265. n->LengthAccum->Data=&n->rLengthAccum;
  266. }
  267. void IDN_BrushDeviceDestroy(OurBrushDeviceNode* n){
  268. laDestroyOutSocket(n->Pressure); laDestroyOutSocket(n->Tilt); laDestroyOutSocket(n->Position); laDestroyOutSocket(n->IsEraser); laDestroyOutSocket(n->Speed);
  269. laDestroyOutSocket(n->Angle); laDestroyOutSocket(n->Length); laDestroyOutSocket(n->LengthAccum); laDestroyOutSocket(n->Twist);
  270. strSafeDestroy(&n->Base.Name);
  271. }
  272. int IDN_BrushDeviceVisit(OurBrushDeviceNode* n, laNodeVisitInfo* vi){
  273. LA_GUARD_THIS_NODE(n,vi); LA_ADD_THIS_NODE(n,vi);
  274. return LA_DAG_FLAG_PERM;
  275. }
  276. int IDN_BrushDeviceEval(OurBrushDeviceNode* n){
  277. if(!Our->CurrentBrush){ return 0; } // unlikely;
  278. tnsVectorSet2v(n->rPosition, Our->CurrentBrush->EvalPosition);
  279. tnsVectorSet2v(n->rTilt, Our->CurrentBrush->EvalTilt);
  280. n->rAngle=Our->CurrentBrush->EvalStrokeAngle;
  281. n->rIsEraser = Our->CurrentBrush->EvalIsEraser;
  282. n->rPressure = Our->CurrentBrush->EvalPressure;
  283. n->rTwist = Our->CurrentBrush->EvalTwist;
  284. n->rSpeed = Our->CurrentBrush->EvalSpeed;
  285. n->rLength = Our->CurrentBrush->EvalStrokeLength;
  286. n->rLengthAccum = Our->CurrentBrush->EvalStrokeLengthAccum;
  287. return 1;
  288. }
  289. void IDN_BrushDeviceCopy(OurBrushDeviceNode* new, OurBrushDeviceNode* old, int DoRematch){
  290. if(DoRematch){ return;}
  291. LA_IDN_OLD_DUPL(Pressure) LA_IDN_OLD_DUPL(Tilt) LA_IDN_OLD_DUPL(Position) LA_IDN_OLD_DUPL(Twist)
  292. LA_IDN_OLD_DUPL(IsEraser) LA_IDN_OLD_DUPL(Speed) LA_IDN_OLD_DUPL(Angle)
  293. LA_IDN_OLD_DUPL(Length) LA_IDN_OLD_DUPL(LengthAccum)
  294. }
  295. void ui_BrushDeviceNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  296. laColumn* c=laFirstColumn(uil); OurBrushDeviceNode*n=This->EndInstance;
  297. laUiItem* b,*u;
  298. LA_BASE_NODE_HEADER(uil,c,This);
  299. b=laBeginRow(uil,c,0,0);
  300. laShowSeparator(uil,c)->Expand=1;
  301. laShowNodeSocket(uil,c,This,"position",0)->Flags|=LA_UI_SOCKET_LABEL_N;
  302. laShowNodeSocket(uil,c,This,"speed",0)->Flags|=LA_UI_SOCKET_LABEL_N;
  303. laShowNodeSocket(uil,c,This,"angle",0)->Flags|=LA_UI_SOCKET_LABEL_N;
  304. laShowNodeSocket(uil,c,This,"pressure",0)->Flags|=LA_UI_SOCKET_LABEL_N;
  305. laShowNodeSocket(uil,c,This,"tilt",0)->Flags|=LA_UI_SOCKET_LABEL_N;
  306. laShowNodeSocket(uil,c,This,"twist",0)->Flags|=LA_UI_SOCKET_LABEL_N;
  307. laShowNodeSocket(uil,c,This,"is_eraser",0)->Flags|=LA_UI_SOCKET_LABEL_N;
  308. laEndRow(uil,b);
  309. b=laBeginRow(uil,c,0,0); laShowSeparator(uil,c)->Expand=1;
  310. laShowNodeSocket(uil,c,This,"length_accum",0)->Flags|=LA_UI_SOCKET_LABEL_W; laShowNodeSocket(uil,c,This,"length",0)->Flags|=LA_UI_SOCKET_LABEL_W; laEndRow(uil,b);
  311. }
  312. int ourEvalBrush(){
  313. return Our->CurrentBrush?laRunPage(Our->CurrentBrush->Rack, 1):0;
  314. }
  315. int ourRebuildBrushEval(){
  316. return Our->CurrentBrush?laRebuildPageEval(Our->CurrentBrush->Rack):0;
  317. }
  318. void ourRegisterNodes(){
  319. laPropContainer *pc; laProp *p;
  320. laOperatorType *at;
  321. laEnumProp *ep;
  322. pc=laAddPropertyContainer("our_node_brush_settings", "Brush Settings", "Brush settings node to read from",0,ui_BrushSettingsNode,sizeof(OurBrushSettingsNode),lapost_Node,0,1);
  323. OUR_PC_IDN_BRUSH_SETTINGS=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  324. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  325. laAddSubGroup(pc,"canvas_scale", "Canvas scale","Canvas scale","la_out_socket",0,0,0,offsetof(OurBrushSettingsNode,CanvasScale),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  326. laAddSubGroup(pc,"size", "Size","Size","la_out_socket",0,0,0,offsetof(OurBrushSettingsNode,Size),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  327. laAddSubGroup(pc,"transparency", "Transparency","Transparency","la_out_socket",0,0,0,offsetof(OurBrushSettingsNode,Transparency),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  328. laAddSubGroup(pc,"hardness", "Hardness","Hardness","la_out_socket",0,0,0,offsetof(OurBrushSettingsNode,Hardness),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  329. laAddSubGroup(pc,"smudge", "Smudge","Smudge","la_out_socket",0,0,0,offsetof(OurBrushSettingsNode,Smudge),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  330. laAddSubGroup(pc,"smudge_length", "Smudge Length","Smudge length","la_out_socket",0,0,0,offsetof(OurBrushSettingsNode,SmudgeLength),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  331. laAddSubGroup(pc,"dabs_per_size", "Dabs Per Size","Dabs per size","la_out_socket",0,0,0,offsetof(OurBrushSettingsNode,DabsPerSize),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  332. laAddSubGroup(pc,"slender", "Slender","Slender","la_out_socket",0,0,0,offsetof(OurBrushSettingsNode,Slender),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  333. laAddSubGroup(pc,"angle", "Angle","Angle","la_out_socket",0,0,0,offsetof(OurBrushSettingsNode,Angle),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  334. laAddSubGroup(pc,"color", "Color","Color","la_out_socket",0,0,0,offsetof(OurBrushSettingsNode,Color),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  335. laAddSubGroup(pc,"gunkyness", "Gunkyness","Gunkyness","la_out_socket",0,0,0,offsetof(OurBrushSettingsNode,Gunkyness),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  336. laAddSubGroup(pc,"force", "Force","Force","la_out_socket",0,0,0,offsetof(OurBrushSettingsNode,Force),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  337. laAddSubGroup(pc,"iteration", "Iteration","Iteration","la_out_socket",0,0,0,offsetof(OurBrushSettingsNode,Iteration),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  338. laAddSubGroup(pc,"c1", "C1","Custom 1","la_out_socket",0,0,0,offsetof(OurBrushSettingsNode,Custom1),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  339. laAddSubGroup(pc,"c2", "C2","Custom 2","la_out_socket",0,0,0,offsetof(OurBrushSettingsNode,Custom2),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  340. pc=laAddPropertyContainer("our_node_brush_outputs", "Brush Outputs", "Brush outputs to draw actual dabs",0,ui_BrushOutputsNode,sizeof(OurBrushOutputsNode),lapost_Node,0,1);
  341. OUR_PC_IDN_BRUSH_OUTPUTS=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  342. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  343. laAddSubGroup(pc,"offset", "Offset","Offset","la_in_socket",0,0,0,offsetof(OurBrushOutputsNode,Offset),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  344. laAddSubGroup(pc,"size", "Size","Size","la_in_socket",0,0,0,offsetof(OurBrushOutputsNode,Size),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  345. laAddSubGroup(pc,"transparency", "Transparency","Transparency","la_in_socket",0,0,0,offsetof(OurBrushOutputsNode,Transparency),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  346. laAddSubGroup(pc,"hardness", "Hardness","Hardness","la_in_socket",0,0,0,offsetof(OurBrushOutputsNode,Hardness),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  347. laAddSubGroup(pc,"smudge", "Smudge","Smudge","la_in_socket",0,0,0,offsetof(OurBrushOutputsNode,Smudge),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  348. laAddSubGroup(pc,"smudge_length", "Smudge Length","Smudge length","la_in_socket",0,0,0,offsetof(OurBrushOutputsNode,SmudgeLength),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  349. laAddSubGroup(pc,"dabs_per_size", "Dabs Per Size","Dabs per size","la_in_socket",0,0,0,offsetof(OurBrushOutputsNode,DabsPerSize),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  350. laAddSubGroup(pc,"slender", "Slender","Slender","la_in_socket",0,0,0,offsetof(OurBrushOutputsNode,Slender),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  351. laAddSubGroup(pc,"angle", "Angle","Angle","la_in_socket",0,0,0,offsetof(OurBrushOutputsNode,Angle),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  352. laAddSubGroup(pc,"gunkyness", "Gunkyness","Gunkyness","la_in_socket",0,0,0,offsetof(OurBrushOutputsNode,Gunkyness),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  353. laAddSubGroup(pc,"force", "Force","Force","la_in_socket",0,0,0,offsetof(OurBrushOutputsNode,Force),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  354. laAddSubGroup(pc,"color", "Color","Color","la_in_socket",0,0,0,offsetof(OurBrushOutputsNode,Color),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  355. laAddSubGroup(pc,"repeats", "Repeats","Repeats","la_in_socket",0,0,0,offsetof(OurBrushOutputsNode,Repeats),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  356. laAddSubGroup(pc,"discard", "Discard","Discard","la_in_socket",0,0,0,offsetof(OurBrushOutputsNode,Discard),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  357. pc=laAddPropertyContainer("our_node_brush_device", "Brush Device", "Brush device input",0,ui_BrushDeviceNode,sizeof(OurBrushDeviceNode),lapost_Node,0,1);
  358. OUR_PC_IDN_BRUSH_DEVICE =pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  359. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  360. laAddSubGroup(pc,"pressure","Pressure","Pressure of the input","la_out_socket",0,0,0,offsetof(OurBrushDeviceNode,Pressure),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  361. laAddSubGroup(pc,"tilt", "Tilt","Pen tilt vector","la_out_socket",0,0,0,offsetof(OurBrushDeviceNode,Tilt),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  362. laAddSubGroup(pc,"twist", "Twist","Pen twist angle","la_out_socket",0,0,0,offsetof(OurBrushDeviceNode,Twist),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  363. laAddSubGroup(pc,"is_eraser", "Is Eraser","Input event is from an eraser","la_out_socket",0,0,0,offsetof(OurBrushDeviceNode,IsEraser),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  364. laAddSubGroup(pc,"position", "Dab position","Interpolated dab position","la_out_socket",0,0,0,offsetof(OurBrushDeviceNode,Position),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  365. laAddSubGroup(pc,"speed","Speed","Speed on the canvas","la_out_socket",0,0,0,offsetof(OurBrushDeviceNode,Speed),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  366. laAddSubGroup(pc,"angle","Angle","Direction of the brush","la_out_socket",0,0,0,offsetof(OurBrushDeviceNode,Angle),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  367. laAddSubGroup(pc,"length","Length","Length of this brush stroke","la_out_socket",0,0,0,offsetof(OurBrushDeviceNode,Length),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  368. laAddSubGroup(pc,"length_accum","Accumulated Length","Accumulated stroke length","la_out_socket",0,0,0,offsetof(OurBrushDeviceNode,LengthAccum),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  369. LA_IDN_REGISTER("Brush Settings",U'🖌',OUR_IDN_BRUSH_SETTINGS,OUR_PC_IDN_BRUSH_SETTINGS, IDN_BrushSettings, OurBrushSettingsNode);
  370. LA_IDN_REGISTER("Brush Outputs",U'🖌',OUR_IDN_BRUSH_OUTPUTS,OUR_PC_IDN_BRUSH_OUTPUTS, IDN_BrushOutputs, OurBrushOutputsNode);
  371. LA_IDN_REGISTER("Brush Device",U'🖳',OUR_IDN_BRUSH_DEVICE,OUR_PC_IDN_BRUSH_DEVICE, IDN_BrushDevice, OurBrushDeviceNode);
  372. laNodeCategory* nc=laEnsureNodeCategory("Our Paint",0,LA_RACK_TYPE_DRIVER);
  373. laNodeCategoryAddNodeTypes(LA_NODE_CATEGORY_DRIVER, &OUR_IDN_BRUSH_OUTPUTS,0LL);
  374. laNodeCategoryAddNodeTypes(nc, &OUR_IDN_BRUSH_DEVICE, 0LL);
  375. laNodeCategoryAddNodeTypes(nc, &OUR_IDN_BRUSH_SETTINGS, 0LL);
  376. }