*/}}

la_nodes_basic.c 91 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502
  1. /*
  2. * LaGUI: A graphical application framework.
  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 "../la_5.h"
  19. extern LA MAIN;
  20. extern struct _tnsMain *T;
  21. laBaseNodeType LA_IDN_KEYBOARD;
  22. laBaseNodeType LA_IDN_MOUSE;
  23. laBaseNodeType LA_IDN_CONTROLLER;
  24. laBaseNodeType LA_IDN_VISUALIZER;
  25. laBaseNodeType LA_IDN_SPLIT;
  26. laBaseNodeType LA_IDN_SWITCH;
  27. laBaseNodeType LA_IDN_COMBINE;
  28. laBaseNodeType LA_IDN_VALUES;
  29. laBaseNodeType LA_IDN_MATRIX;
  30. laBaseNodeType LA_IDN_MATH;
  31. laBaseNodeType LA_IDN_SMALL_MATH;
  32. laBaseNodeType LA_IDN_MAPPER;
  33. laBaseNodeType LA_IDN_RANDOM;
  34. laBaseNodeType LA_IDN_VECTOR_MATH;
  35. laBaseNodeType LA_IDN_COMMENT;
  36. laBaseNodeType LA_IDN_RGB2OKHSL;
  37. laBaseNodeType LA_IDN_OKHSL2RGB;
  38. laBaseNodeType LA_IDN_LOOP;
  39. laBaseNodeType LA_IDN_LOOP_INDEX;
  40. laPropContainer* LA_PC_IDN_GENERIC;
  41. laPropContainer* LA_PC_IDN_KEYBOARD;
  42. laPropContainer* LA_PC_IDN_MOUSE;
  43. laPropContainer* LA_PC_IDN_CONTROLLER;
  44. laPropContainer* LA_PC_IDN_VISUALIZER;
  45. laPropContainer* LA_PC_IDN_SPLIT;
  46. laPropContainer* LA_PC_IDN_SWITCH;
  47. laPropContainer* LA_PC_IDN_COMBINE;
  48. laPropContainer* LA_PC_IDN_VALUES;
  49. laPropContainer* LA_PC_IDN_MATRIX;
  50. laPropContainer* LA_PC_IDN_MATH;
  51. laPropContainer* LA_PC_IDN_SMALL_MATH;
  52. laPropContainer* LA_PC_IDN_MAPPER;
  53. laPropContainer* LA_PC_IDN_RANDOM;
  54. laPropContainer* LA_PC_IDN_VECTOR_MATH;
  55. laPropContainer* LA_PC_IDN_COMMENT;
  56. laPropContainer* LA_PC_IDN_RGB2OKHSL;
  57. laPropContainer* LA_PC_IDN_OKHSL2RGB;
  58. laPropContainer* LA_PC_IDN_LOOP;
  59. laPropContainer* LA_PC_IDN_LOOP_INDEX;
  60. laNodeCategory* LA_NODE_CATEGORY_INPUT;
  61. laNodeCategory* LA_NODE_CATEGORY_MATH;
  62. laNodeCategory* LA_NODE_CATEGORY_ROUTE;
  63. laNodeCategory* LA_NODE_CATEGORY_AUX;
  64. laNodeCategory* LA_NODE_CATEGORY_DRIVER;
  65. laNodeCategory* LA_NODE_CATEGORY_COLOR;
  66. void la_PageClearBranch(laRackPage* rp, int mask);
  67. #define LA_IDN_CONTROLLER_RESET_SOCKET(ns) \
  68. {ns->IntVal[0]=0; ns->Out->DataType=LA_PROP_INT; ns->Offset=0; ns->Out->Data=&ns->IntVal;}
  69. void IDN_ControllerInit(laInputControllerNode* n, int NoCreate){
  70. if(NoCreate){return;}
  71. for(int i=0;i<8;i++){ n->Sockets[i].Out=laCreateOutSocket(n, "out", 0); n->Sockets[i].Parent=n; }
  72. strSafeSet(&n->Base.Name,"Controller Output");
  73. }
  74. void IDN_ControllerDestroy(laInputControllerNode* n){
  75. for(int i=0;i<8;i++){ laDestroyOutSocket(n->Sockets[i].Out); }
  76. strSafeDestroy(&n->Base.Name);
  77. }
  78. int IDN_ControllerVisit(laInputControllerNode* n, laNodeVisitInfo* vi){
  79. laController* c=la_FindControllerWithID(n->UserID);
  80. if(!c){ for(int i=0;i<8;i++){ laInputControllerNodeSocket* ns=&n->Sockets[i]; LA_IDN_CONTROLLER_RESET_SOCKET(ns); } return LA_DAG_FLAG_PERM; }
  81. else{
  82. for(int i=0;i<8;i++){ laInputControllerNodeSocket* ns=&n->Sockets[i];
  83. if(!ns->Which || !ns->Which->Ptr){ LA_IDN_CONTROLLER_RESET_SOCKET(ns); continue; }
  84. laPropContainer*pc=la_EnsureSubTarget(LA_PROP_CONTROLLER, c);
  85. laProp* p=la_PropLookup(&pc->Props, n->Sockets[i].Which->Ptr);
  86. if((!p)||(!p->Offset)||
  87. ((p->PropertyType!=LA_PROP_INT)&&(p->PropertyType!=LA_PROP_ENUM)&&
  88. (p->PropertyType!=(LA_PROP_INT|LA_PROP_ARRAY))&&(p->PropertyType!=(LA_PROP_ENUM|LA_PROP_ARRAY)))){ LA_IDN_CONTROLLER_RESET_SOCKET(ns); continue; }
  89. if(p->PropertyType==LA_PROP_INT){ ns->Out->DataType=LA_PROP_FLOAT; ns->Out->Data=&ns->RealVal; ns->Out->ArrLen=1; }
  90. elif(p->PropertyType==(LA_PROP_INT|LA_PROP_ARRAY)){ ns->Out->DataType=(LA_PROP_FLOAT|LA_PROP_ARRAY); ns->Out->Data=&ns->RealVal; ns->Out->ArrLen=p->Len; }
  91. elif(p->PropertyType==LA_PROP_ENUM){ ns->Out->DataType=LA_PROP_ENUM; ns->Out->Data=&ns->IntVal; ns->Out->ArrLen=1; }
  92. elif(p->PropertyType==(LA_PROP_ENUM|LA_PROP_ARRAY)){ ns->Out->DataType=(LA_PROP_ENUM|LA_PROP_ARRAY); ns->Out->Data=&ns->IntVal; ns->Out->ArrLen=p->Len; }
  93. ns->Offset=p->Offset;
  94. }
  95. }
  96. LA_ADD_THIS_NODE(n,vi);
  97. return LA_DAG_FLAG_PERM;
  98. }
  99. int IDN_ControllerEval(laInputControllerNode* n){
  100. laNotifyInstanceUsers(n);
  101. laController* c=la_FindControllerWithID(n->UserID); if(!c){
  102. for(int i=0;i<8;i++){ laInputControllerNodeSocket* ns=&n->Sockets[i]; LA_IDN_CONTROLLER_RESET_SOCKET(ns); } return 1;
  103. }
  104. for(int i=0;i<8;i++){ laInputControllerNodeSocket* ns=&n->Sockets[i];
  105. int *addr=((char*)c)+ns->Offset; char* addc=addr;
  106. if(ns->Out->DataType==LA_PROP_FLOAT){ ns->RealVal[0]=(real)(*addr)/32767.0; }
  107. if(ns->Out->DataType==(LA_PROP_FLOAT|LA_PROP_ARRAY)){ for(int a=0;a<ns->Out->ArrLen;a++) ns->RealVal[a]=((real)addr[a])/32767.0; }
  108. elif(ns->Out->DataType==LA_PROP_ENUM){ ns->IntVal[0]=(*addc); }
  109. elif(ns->Out->DataType==(LA_PROP_ENUM|LA_PROP_ARRAY)){ for(int a=0;a<ns->Out->ArrLen;a++) ns->IntVal[a]=addc[a]; }
  110. }
  111. return 1;
  112. }
  113. void laui_ControllerNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  114. laColumn* c=laFirstColumn(uil); laInputControllerNode*n=This->EndInstance;
  115. laColumn* cl,*cr;
  116. LA_BASE_NODE_HEADER(uil,c,This);
  117. laSplitColumn(uil,c,0.3); cl=laLeftColumn(c,0); cr=laRightColumn(c,0);
  118. laUiItem* b=laBeginRow(uil,c,0,0);
  119. laShowItem(uil,c,This,"base.name")->Expand=1;
  120. laShowItem(uil,c,This,"user_id");
  121. laEndRow(uil,b);
  122. char* buf[128],buf2[128];
  123. for(int i=0;i<8;i++){
  124. sprintf(buf,"out%d.which",i); laShowItem(uil,cl,This,buf);
  125. laUiItem* b=laBeginRow(uil,cr,0,0);
  126. sprintf(buf2,"out%d.out.data_type",i);
  127. laUiItem* b2=laOnConditionThat(uil,cr,laEqual(laPropExpression(This,buf2),laIntExpression(LA_PROP_FLOAT)));{
  128. sprintf(buf,"out%d.axis",i); laShowItem(uil,cr,This,buf)->Expand=1;
  129. }laElse(uil,b2);{
  130. laUiItem* b3=laOnConditionThat(uil,cr,laEqual(laPropExpression(This,buf2),laIntExpression(LA_PROP_FLOAT|LA_PROP_ARRAY)));{
  131. sprintf(buf,"out%d.axis2d",i); laUiItem* aui=laShowItem(uil,cr,This,buf);aui->Expand=1;aui->Flags|=LA_UI_FLAGS_TRANSPOSE;aui->Extra->HeightCoeff=1;
  132. }laElse(uil,b3);{
  133. sprintf(buf,"out%d.switch",i); laUiItem* sui=laShowItem(uil,cr,This,buf);sui->Expand=1;sui->Flags|=LA_UI_FLAGS_TRANSPOSE;
  134. }laEndCondition(uil,b3);
  135. }laEndCondition(uil,b2);
  136. sprintf(buf,"out%d.out",i); laShowNodeSocket(uil,cr,This,buf,0);
  137. laEndRow(uil,b);
  138. }
  139. }
  140. void IDN_InputVisualizeInit(laInputVisualizerNode* n, int NoCreate){
  141. if(NoCreate){return;}
  142. n->In=laCreateInSocket("IN", 0);
  143. strSafeSet(&n->Base.Name,"Input Visualizer");
  144. }
  145. void IDN_InputVisualizeDestroy(laInputVisualizerNode* n){
  146. laDestroyInSocket(n->In);
  147. strSafeDestroy(&n->Base.Name);
  148. }
  149. int IDN_InputVisualizeVisit(laInputVisualizerNode* n, laNodeVisitInfo* vi){
  150. LA_GUARD_THIS_NODE(n,vi);
  151. if(LA_SRC_AND_PARENT(n->In)){ laBaseNode* sn=n->In->Source->Parent;LA_VISIT_NODE(sn,vi); }
  152. LA_ADD_THIS_NODE(n,vi);
  153. return LA_DAG_FLAG_PERM;
  154. }
  155. int IDN_InputVisualizerEval(laInputVisualizerNode* n){
  156. if(!n->In->Source) return 0;
  157. laNodeOutSocket* os=n->In->Source; int arrlen=1;
  158. switch(os->DataType){
  159. case LA_PROP_FLOAT|LA_PROP_ARRAY:
  160. case LA_PROP_FLOAT: if(os->ArrLen)arrlen=os->ArrLen; memcpy(n->RealVal,os->Data,sizeof(real)*arrlen); n->In->ArrLen=arrlen; break;
  161. case LA_PROP_ENUM|LA_PROP_ARRAY:
  162. case LA_PROP_ENUM: if(os->ArrLen)arrlen=os->ArrLen; memcpy(n->IntVal,os->Data,sizeof(int)*arrlen); n->In->ArrLen=arrlen; break;
  163. default: n->IntVal[0]=0; n->In->ArrLen=1; break;
  164. }
  165. n->In->DataType=os->DataType;
  166. laNotifyInstanceUsers(n);
  167. return 1;
  168. }
  169. void laui_InputVisualizeNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  170. laColumn* c=laFirstColumn(uil); laInputVisualizerNode*n=This->EndInstance;
  171. LA_BASE_NODE_HEADER(uil,c,This);
  172. laColumn* cl,*cr; laSplitColumn(uil,c,0.4); cl=laLeftColumn(c,1); cr=laRightColumn(c,0);
  173. laShowNodeSocket(uil,cl,This,"in",0);
  174. laUiItem* b2=laOnConditionThat(uil,cr,laEqual(laPropExpression(This,"in.data_type"),laIntExpression(LA_PROP_FLOAT)));{
  175. laShowItem(uil,cr,This,"axis");
  176. }laElse(uil,b2);{
  177. laUiItem* b3=laOnConditionThat(uil,cr,laEqual(laPropExpression(This,"in.data_type"),laIntExpression(LA_PROP_FLOAT|LA_PROP_ARRAY)));{
  178. laUiItem* aui=laShowItem(uil,cr,This,"axis2d");
  179. }laElse(uil,b3);{
  180. laUiItem* sui=laShowItem(uil,cr,This,"switch");
  181. }laEndCondition(uil,b3);
  182. }laEndCondition(uil,b2);
  183. }
  184. void IDN_SplitInit(laSplitNode* n, int NoCreate){
  185. if(NoCreate){return;}
  186. n->In=laCreateInSocket("in", 0); strSafeSet(&n->Base.Name,"Split");
  187. for(int i=0;i<8;i++){ char str[4]; sprintf(str,"%d",i); n->Out[i].Out=laCreateOutSocket(n,str,0); }
  188. }
  189. void IDN_SplitDestroy(laSplitNode* n){
  190. laDestroyInSocket(n->In); strSafeDestroy(&n->Base.Name);
  191. for(int i=0;i<8;i++){ laDestroyOutSocket(n->Out[i].Out); }
  192. }
  193. int IDN_SplitVisit(laSplitNode* n, laNodeVisitInfo* vi){
  194. LA_GUARD_THIS_NODE(n,vi);
  195. if(LA_SRC_AND_PARENT(n->In)){ laBaseNode* sn=n->In->Source->Parent; LA_VISIT_NODE(sn,vi); }
  196. LA_ADD_THIS_NODE(n,vi);
  197. return LA_DAG_FLAG_PERM;
  198. }
  199. int IDN_SplitEval(laSplitNode* n){
  200. if(!n->In->Source) return 0;
  201. laNodeOutSocket* os=n->In->Source; int arrlen=1;
  202. switch(os->DataType){
  203. case LA_PROP_FLOAT|LA_PROP_ARRAY:
  204. case LA_PROP_FLOAT: if(os->ArrLen) n->ArrLen=os->ArrLen;
  205. for(int i=0;i<TNS_MIN2(n->ArrLen,8);i++){ n->Out[i].Out->DataType=LA_PROP_FLOAT; n->Out[i].Out->Data=&n->RealVal[i]; }
  206. memcpy(n->RealVal,os->Data,sizeof(real)*n->ArrLen); n->In->ArrLen=arrlen; break;
  207. case LA_PROP_ENUM|LA_PROP_ARRAY:
  208. case LA_PROP_ENUM: if(os->ArrLen) n->ArrLen=os->ArrLen;
  209. for(int i=0;i<TNS_MIN2(n->ArrLen,8);i++){ n->Out[i].Out->DataType=LA_PROP_ENUM; n->Out[i].Out->Data=&n->IntVal[i]; }
  210. memcpy(n->IntVal,os->Data,sizeof(int)*n->ArrLen); n->In->ArrLen=arrlen; break;
  211. default:
  212. for(int i=0;i<TNS_MIN2(n->ArrLen,8);i++){ n->Out[i].Out->DataType=LA_PROP_ENUM; n->Out[i].Out->Data=&n->IntVal[i]; }
  213. n->IntVal[0]=0; n->In->ArrLen=1; break;
  214. }
  215. n->In->DataType=os->DataType;
  216. return 1;
  217. }
  218. void laui_SplitNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  219. laColumn* c=laFirstColumn(uil); laSplitNode*n=This->EndInstance;
  220. laColumn* cl,*cr; laSplitColumn(uil,c,0.4); cl=laLeftColumn(c,1); cr=laRightColumn(c,0);
  221. LA_BASE_NODE_HEADER(uil,c,This);
  222. laUiItem* b=laBeginRow(uil,c,0,0);
  223. laShowNodeSocket(uil,c,This,"in",0);
  224. laShowItemFull(uil,c,This,"array_length",LA_WIDGET_INT_PLAIN,0,0,0);
  225. laShowLabel(uil,c,"🡲",0,0)->Expand=1;
  226. for(int i=0;i<8;i++){
  227. char* buf[128]; sprintf(buf,"out%d.out",i); laShowNodeSocket(uil,cr,This,buf,0);
  228. }
  229. laEndRow(uil,b);
  230. }
  231. void IDN_SwitchInit(laSwitchNode* n, int NoCreate){
  232. if(NoCreate){return;}
  233. n->SwitchIn=laCreateInSocket("sw in",0); n->Out=laCreateOutSocket(n,"out",0); strSafeSet(&n->Base.Name,"Switch");
  234. for(int i=0;i<8;i++){ char str[4]; sprintf(str,"%d",i); n->In[i].In=laCreateInSocket(n,str); }
  235. }
  236. void IDN_SwitchDestroy(laSwitchNode* n){
  237. laDestroyInSocket(n->SwitchIn); laDestroyOutSocket(n->Out); strSafeDestroy(&n->Base.Name);
  238. for(int i=0;i<8;i++){ laDestroyInSocket(n->In[i].In); }
  239. }
  240. int IDN_SwitchVisit(laSwitchNode* n, laNodeVisitInfo* vi){
  241. LA_GUARD_THIS_NODE(n,vi); n->MaxUsed=0; n->Page=vi->Page;
  242. for(int i=0;i<8;i++){ if(n->In[i].In->Source){ n->MaxUsed=i+2; } }
  243. uint64_t OrigBranch=vi->Branch; int NextBranch=vi->NextBranch;
  244. vi->NextBranch+=n->MaxUsed; n->BranchSW=(1<<(NextBranch-1));
  245. if(OrigBranch==1){ lstAppendPointer(vi->br,n); }
  246. for(int i=0;i<8;i++){
  247. if(n->In[i].In->Source){
  248. vi->Branch=OrigBranch|(1<<(NextBranch+i));
  249. laBaseNode* sn=n->In[i].In->Source->Parent; LA_VISIT_NODE(sn,vi);
  250. }
  251. }
  252. vi->Branch=OrigBranch|n->BranchSW;
  253. laBaseNode* sw=n->SwitchIn->Source?n->SwitchIn->Source->Parent:0; if(sw){ LA_VISIT_NODE(sw,vi); }
  254. vi->Branch=OrigBranch;
  255. LA_ADD_THIS_NODE(n,vi);
  256. return LA_DAG_FLAG_PERM;
  257. }
  258. int IDN_SwitchEval(laSwitchNode* n){
  259. int sw=n->Switch;
  260. if(n->SwitchIn->Source){
  261. laRunPage(n->Page,n->BranchSW);
  262. laNodeOutSocket* os=n->SwitchIn->Source; int* id; real* fd;
  263. switch(os->DataType){
  264. case LA_PROP_ARRAY|LA_PROP_ENUM:
  265. id=os->Data; for(int i=0;i<os->ArrLen;i++){ if(id[i]){sw=i; break;} } break;
  266. case LA_PROP_ENUM: case LA_PROP_INT: case LA_PROP_INT|LA_PROP_ARRAY:
  267. id=os->Data; sw=*id; break;
  268. case LA_PROP_FLOAT: case LA_PROP_FLOAT|LA_PROP_ARRAY:
  269. fd=os->Data; sw=(int)(*fd); break;
  270. default: sw=0; break;
  271. }
  272. }
  273. laRunPage(n->Page,(n->BranchSW<<(sw+1)));
  274. TNS_CLAMP(sw,0,7);
  275. laSwitchNodeInSocket *is=&n->In[sw];
  276. if(is->In->Source){ n->Out->Data=is->In->Source->Data; n->Out->DataType=is->In->Source->DataType; n->Out->ArrLen=is->In->Source->ArrLen; }
  277. else{ n->Out->Data=&n->TempVal; n->Out->DataType=LA_PROP_FLOAT; n->Out->ArrLen=1; }
  278. return 1;
  279. }
  280. void laui_SwitchNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  281. laColumn* c=laFirstColumn(uil); laSwitchNode*n=This->EndInstance;
  282. laColumn* cl,*cr; laSplitColumn(uil,c,0.4); cl=laLeftColumn(c,1); cr=laRightColumn(c,0);
  283. LA_BASE_NODE_HEADER(uil,c,This);
  284. laUiItem* b=laBeginRow(uil,c,0,0);
  285. for(int i=0;i<8;i++){
  286. char* buf[128]; sprintf(buf,"in%d.in",i); laShowNodeSocket(uil,cr,This,buf,0);
  287. } laShowSeparator(uil,c)->Expand=1;
  288. laEndRow(uil,b);
  289. b=laBeginRow(uil,c,0,0);
  290. laShowItem(uil,c,This,"switch_in");
  291. laUiItem* b2=laOnConditionThat(uil,c,laNot(laPropExpression(This,"switch_in.source")));{
  292. laShowItem(uil,c,This,"switch");
  293. };laEndCondition(uil,b2);
  294. laShowSeparator(uil,c)->Expand=1;
  295. laShowNodeSocket(uil,c,This,"out",0);
  296. laEndRow(uil,b);
  297. }
  298. void IDN_CombineInit(laCombineNode* n, int NoCreate){
  299. if(!NoCreate){
  300. n->Out=laCreateOutSocket(n,"F",0);n->OutInt=laCreateOutSocket(n,"I",0);n->OutEnum=laCreateOutSocket(n,"E",0); strSafeSet(&n->Base.Name,"Combine");
  301. for(int i=0;i<8;i++){ char str[4]; sprintf(str,"%d",i); n->In[i].In=laCreateInSocket(n,str); }
  302. }
  303. n->Out->Data=n->Values; n->OutInt->Data=n->ValuesI; n->OutEnum->Data=n->ValuesI;
  304. n->Out->DataType=LA_PROP_FLOAT|LA_PROP_ARRAY; n->OutInt->DataType=LA_PROP_INT|LA_PROP_ARRAY; n->OutEnum->DataType=LA_PROP_ENUM|LA_PROP_ARRAY;
  305. }
  306. void IDN_CombineDestroy(laCombineNode* n){
  307. laDestroyOutSocket(n->Out);laDestroyOutSocket(n->OutInt);laDestroyOutSocket(n->OutEnum); strSafeDestroy(&n->Base.Name);
  308. for(int i=0;i<8;i++){ laDestroyInSocket(n->In[i].In); }
  309. }
  310. int IDN_CombineVisit(laCombineNode* n, laNodeVisitInfo* vi){
  311. LA_GUARD_THIS_NODE(n,vi);
  312. for(int i=0;i<8;i++){ if(LA_SRC_AND_PARENT(n->In[i].In)){ laBaseNode* sn=n->In[i].In->Source->Parent; LA_VISIT_NODE(sn,vi); } }
  313. LA_ADD_THIS_NODE(n,vi);
  314. return LA_DAG_FLAG_PERM;
  315. }
  316. int IDN_CombineEval(laCombineNode* n){
  317. int maxlen=0;
  318. for(int i=0;i<8;i++){ laNodeInSocket *is=n->In[i].In;
  319. if(LA_SRC_AND_PARENT(is)){
  320. if((is->Source->DataType&LA_PROP_FLOAT) && is->Source->Data){ n->Values[i]=*((real*)is->Source->Data); }
  321. elif((is->Source->DataType&LA_PROP_INT) && is->Source->Data){ n->Values[i]=*((int*)is->Source->Data); }
  322. elif((is->Source->DataType&LA_PROP_ENUM) && is->Source->Data){ n->Values[i]=*((int*)is->Source->Data); }
  323. else n->Values[i]=0;
  324. maxlen=i+1;
  325. }
  326. else n->Values[i]=0;
  327. n->ValuesI[i]=n->Values[i];
  328. }
  329. n->Out->ArrLen=n->OutInt->ArrLen=n->OutEnum->ArrLen=maxlen;
  330. return 1;
  331. }
  332. void laui_CombineNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  333. laColumn* c=laFirstColumn(uil); laCombineNode*n=This->EndInstance;
  334. laColumn* cl,*cr; laSplitColumn(uil,c,0.4); cl=laLeftColumn(c,1); cr=laRightColumn(c,0);
  335. LA_BASE_NODE_HEADER(uil,c,This);
  336. laUiItem* b=laBeginRow(uil,c,0,0);
  337. for(int i=0;i<8;i++){
  338. char* buf[128]; sprintf(buf,"in%d.in",i); laShowNodeSocket(uil,cr,This,buf,0);
  339. } laShowSeparator(uil,c)->Expand=1;
  340. laEndRow(uil,b);
  341. b=laBeginRow(uil,c,0,0);
  342. laUiItem* lu=laShowLabel(uil,c,"Combine 🡲",0,0); lu->Expand=1; lu->Flags|=LA_TEXT_ALIGN_RIGHT;
  343. laShowNodeSocket(uil,c,This,"out_enum",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  344. laShowNodeSocket(uil,c,This,"out_int",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  345. laShowNodeSocket(uil,c,This,"out",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  346. laEndRow(uil,b);
  347. }
  348. void IDN_ValuesInit(laValuesNode* n, int NoCreate){
  349. if(NoCreate){return;}
  350. strSafeSet(&n->Base.Name,"Values");
  351. for(int i=0;i<8;i++){ char str[4]; sprintf(str,"%d",i); n->Out[i].Out=laCreateOutSocket(n,str,0); }
  352. }
  353. void IDN_ValuesDestroy(laValuesNode* n){
  354. strSafeDestroy(&n->Base.Name);
  355. for(int i=0;i<8;i++){ laDestroyOutSocket(n->Out[i].Out); }
  356. }
  357. int IDN_ValuesVisit(laValuesNode* n, laNodeVisitInfo* vi){
  358. LA_GUARD_THIS_NODE(n,vi);
  359. LA_ADD_THIS_NODE(n,vi);
  360. return LA_DAG_FLAG_PERM;
  361. }
  362. int IDN_ValuesEval(laValuesNode* n){
  363. for(int i=0;i<8;i++){ laNodeOutSocket *is=n->Out[i].Out;
  364. if(n->Modes[i]==LA_VALUES_NODE_FLOAT){ is->Data=&n->Values[i]; is->DataType=LA_PROP_FLOAT; }
  365. if(n->Modes[i]==LA_VALUES_NODE_INT){ is->Data=&n->ValuesI[i]; is->DataType=LA_PROP_INT; }
  366. if(n->Modes[i]==LA_VALUES_NODE_ENUM){ is->Data=&n->ValuesE[i]; is->DataType=LA_PROP_ENUM; }
  367. }
  368. return 1;
  369. }
  370. void laui_ValuesNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  371. laColumn* c=laFirstColumn(uil); laValuesNode*n=This->EndInstance;
  372. laUiItem*b,*b2;
  373. LA_BASE_NODE_HEADER(uil,c,This);
  374. laColumn* cl,*cr; laSplitColumn(uil,c,0.4); cl=laLeftColumn(c,3); cr=laRightColumn(c,0);
  375. for(int i=0;i<8;i++){
  376. char* bufm[32]; sprintf(bufm,"mode%d",i); laShowItem(uil,cl,This,bufm);
  377. b=laBeginRow(uil,cr,0,0);
  378. b2=laOnConditionThat(uil,cr,laEqual(laPropExpression(This,bufm),laIntExpression(LA_VALUES_NODE_FLOAT)));{
  379. char* buf[32]; sprintf(buf,"value%d",i); laShowItem(uil,cr,This,buf)->Expand=1;
  380. }laEndCondition(uil,b2);
  381. b2=laOnConditionThat(uil,cr,laEqual(laPropExpression(This,bufm),laIntExpression(LA_VALUES_NODE_INT)));{
  382. char* buf[32]; sprintf(buf,"valuei%d",i); laShowItem(uil,cr,This,buf)->Expand=1;
  383. }laEndCondition(uil,b2);
  384. b2=laOnConditionThat(uil,cr,laEqual(laPropExpression(This,bufm),laIntExpression(LA_VALUES_NODE_ENUM)));{
  385. char* buf[32]; sprintf(buf,"valuee%d",i); laUiItem* eui=laShowItem(uil,cr,This,buf); eui->Expand=1; eui->Flags|=LA_UI_FLAGS_HIGHLIGHT;
  386. }laEndCondition(uil,b2);
  387. sprintf(bufm,"out%d.out",i); laShowNodeSocket(uil,cr,This,bufm,0);
  388. laEndRow(uil,b);
  389. }
  390. }
  391. void IDN_MatrixInit(laMatrixNode* n, int NoCreate){
  392. if(!NoCreate){
  393. strSafeSet(&n->Base.Name,"Matrix");
  394. n->InL=laCreateInSocket("l",0); n->InR=laCreateInSocket("r",0); n->Out=laCreateOutSocket(n,"MAT",LA_PROP_FLOAT|LA_PROP_ARRAY);
  395. }
  396. n->Out->ArrLen=16; n->Out->Data=n->Mat;
  397. }
  398. void IDN_MatrixDestroy(laMatrixNode* n){
  399. strSafeDestroy(&n->Base.Name);
  400. laDestroyInSocket(n->InL); laDestroyInSocket(n->InR); laDestroyOutSocket(n->Out);
  401. }
  402. int IDN_MatrixVisit(laMatrixNode* n, laNodeVisitInfo* vi){
  403. LA_GUARD_THIS_NODE(n,vi);
  404. if(LA_SRC_AND_PARENT(n->InL)){ laBaseNode* bn=n->InL->Source->Parent; LA_VISIT_NODE(bn,vi); }
  405. if(LA_SRC_AND_PARENT(n->InR)){ laBaseNode* bn=n->InR->Source->Parent; LA_VISIT_NODE(bn,vi); }
  406. LA_ADD_THIS_NODE(n,vi);
  407. return LA_DAG_FLAG_PERM;
  408. }
  409. int IDN_MatrixEval(laMatrixNode* n){
  410. int hasl=LA_SRC_AND_PARENT(n->InL),hasr=LA_SRC_AND_PARENT(n->InR);
  411. if((!hasl) && (!hasr)){ tnsLoadIdentity44d(n->Mat); return 0; }
  412. if(hasl&&((n->InL->Source->DataType!=(LA_PROP_FLOAT|LA_PROP_ARRAY))||n->InL->Source->ArrLen!=16)){tnsLoadIdentity44d(n->Mat); return 0;}
  413. if(hasr&&((n->InR->Source->DataType!=(LA_PROP_FLOAT|LA_PROP_ARRAY))||n->InR->Source->ArrLen!=16)){tnsLoadIdentity44d(n->Mat); return 0;}
  414. if(n->Operation==LA_MATRIX_NODE_OP_INV){
  415. real* mat; if(hasl)mat=n->InL->Source->Data;else mat=n->InR->Source->Data;
  416. tnsInverse44d(n->Mat, mat);
  417. }else{
  418. if(!hasl) { memcpy(n->Mat,n->InR->Source->Data,sizeof(tnsMatrix44d)); }
  419. elif(!hasr) { memcpy(n->Mat,n->InL->Source->Data,sizeof(tnsMatrix44d)); }
  420. else{
  421. tnsMultiply44d(n->Mat,n->InL->Source->Data,n->InR->Source->Data);
  422. }
  423. }
  424. return 1;
  425. }
  426. void laui_MatrixNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  427. laColumn* c=laFirstColumn(uil); laMatrixNode*n=This->EndInstance;
  428. laColumn* cl,*cr; laSplitColumn(uil,c,0.4); cl=laLeftColumn(c,3); cr=laRightColumn(c,0);
  429. laUiItem*b,*b2;
  430. LA_BASE_NODE_HEADER(uil,c,This);
  431. b=laBeginRow(uil,c,0,0);
  432. laShowNodeSocket(uil,c,This,"in_l",0); laShowNodeSocket(uil,c,This,"in_r",0); laShowItem(uil,c,This,"operation");
  433. laShowSeparator(uil,c)->Expand=1; laShowNodeSocket(uil,c,This,"out",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  434. laEndRow(uil,b);
  435. }
  436. void IDN_MathInit(laMathNode* n, int NoCreate){
  437. if(!NoCreate){
  438. strSafeSet(&n->Base.Name,"Math");
  439. n->InL=laCreateInSocket("l",0); n->InR=laCreateInSocket("r",0);
  440. n->Out=laCreateOutSocket(n,"F",LA_PROP_FLOAT); n->OutInt=laCreateOutSocket(n,"I",LA_PROP_INT);
  441. }
  442. n->Out->Data=&n->Value; n->OutInt->Data=&n->ValueI;
  443. }
  444. void IDN_MathDestroy(laMathNode* n){
  445. strSafeDestroy(&n->Base.Name); laDestroyInSocket(n->InL); laDestroyInSocket(n->InR); laDestroyOutSocket(n->Out); laDestroyOutSocket(n->OutInt);
  446. }
  447. int IDN_MathVisit(laMathNode* n, laNodeVisitInfo* vi){
  448. LA_GUARD_THIS_NODE(n,vi);
  449. if(LA_SRC_AND_PARENT(n->InL)){ laBaseNode* bn=n->InL->Source->Parent; LA_VISIT_NODE(bn,vi); }
  450. if(LA_SRC_AND_PARENT(n->InR)){ laBaseNode* bn=n->InR->Source->Parent; LA_VISIT_NODE(bn,vi); }
  451. LA_ADD_THIS_NODE(n,vi);
  452. return LA_DAG_FLAG_PERM;
  453. }
  454. #define LA_GET_SRC_AS_FLOAT(var, socket) \
  455. {if(socket->Source->DataType&LA_PROP_FLOAT) var=*((real*)socket->Source->Data);\
  456. if(socket->Source->DataType&(LA_PROP_INT|LA_PROP_ENUM)) var=*((int*)socket->Source->Data);}
  457. int IDN_MathEval(laMathNode* n){
  458. real vl=n->ValueL;real vr=n->ValueR;
  459. int hasl=LA_SRC_AND_PARENT(n->InL),hasr=LA_SRC_AND_PARENT(n->InR);
  460. if(hasl){ LA_GET_SRC_AS_FLOAT(vl,n->InL) } if(hasr){ LA_GET_SRC_AS_FLOAT(vr,n->InR) }
  461. switch(n->Operation){
  462. case LA_MATH_NODE_OP_ADD: default: n->Value=vl+vr; break;
  463. case LA_MATH_NODE_OP_SUB: n->Value=vl-vr; break;
  464. case LA_MATH_NODE_OP_MUL: n->Value=vl*vr; break;
  465. case LA_MATH_NODE_OP_DIV: if(vr)n->Value=vl/vr;else n->Value=0; break;
  466. case LA_MATH_NODE_OP_POW: n->Value=pow(vl,vr); break;
  467. case LA_MATH_NODE_OP_LOG: n->Value=log2(vl)/log2(vr); break;
  468. case LA_MATH_NODE_OP_SIN: n->Value=sin(vl); break;
  469. case LA_MATH_NODE_OP_COS: n->Value=cos(vl); break;
  470. case LA_MATH_NODE_OP_TAN: n->Value=tan(vl); break;
  471. case LA_MATH_NODE_OP_ASIN: n->Value=asin(vl); break;
  472. case LA_MATH_NODE_OP_ACOS: n->Value=acos(vl); break;
  473. case LA_MATH_NODE_OP_ATAN: n->Value=atan(vl); break;
  474. case LA_MATH_NODE_OP_ATAN2: n->Value=atan2(vl,vr); break;
  475. case LA_MATH_NODE_OP_MOD: n->Value=fmod(vl,vr); break;
  476. }
  477. n->ValueI=(int)n->Value;
  478. return 1;
  479. }
  480. void laui_MathNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  481. laColumn* c=laFirstColumn(uil); laMathNode*n=This->EndInstance;
  482. laColumn* cl,*cr; laSplitColumn(uil,c,0.4); cl=laLeftColumn(c,3); cr=laRightColumn(c,0);
  483. laUiItem*b,*b2;
  484. LA_BASE_NODE_HEADER(uil,c,This);
  485. b=laBeginRow(uil,c,0,0);
  486. laShowNodeSocket(uil,c,This,"in_l",0); b=laOnConditionThat(uil,c,laNot(laPropExpression(This,"in_l.source")));{ laShowItem(uil,c,This,"vl"); }laEndCondition(uil,b);
  487. laShowSeparator(uil,c)->Expand=1; laShowItem(uil,c,This,"operation");
  488. laEndRow(uil,b);
  489. b=laBeginRow(uil,c,0,0);
  490. laShowNodeSocket(uil,c,This,"in_r",0); b=laOnConditionThat(uil,c,laNot(laPropExpression(This,"in_r.source")));{ laShowItem(uil,c,This,"vr");}laEndCondition(uil,b);
  491. laShowSeparator(uil,c)->Expand=1;
  492. laShowNodeSocket(uil,c,This,"out_int",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  493. laShowNodeSocket(uil,c,This,"out",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  494. laEndRow(uil,b);
  495. }
  496. void laui_SmallMathNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  497. laColumn* c=laFirstColumn(uil); laMathNode*n=This->EndInstance;
  498. laColumn* cl,*cr; laSplitColumn(uil,c,0.4); cl=laLeftColumn(c,3); cr=laRightColumn(c,0);
  499. laUiItem*b,*b2;
  500. LA_BASE_NODE_HEADER(uil,c,This);
  501. b=laBeginRow(uil,c,0,0);
  502. laShowNodeSocket(uil,c,This,"in_l",0);laShowNodeSocket(uil,c,This,"in_r",0);
  503. laShowSeparator(uil,c)->Expand=1;laShowItem(uil,c,This,"operation");
  504. laShowNodeSocket(uil,c,This,"out",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  505. laEndRow(uil,b);
  506. }
  507. void IDN_MapperInit(laMapperNode* n, int NoCreate){
  508. if(!NoCreate){
  509. strSafeSet(&n->Base.Name,"Mapper");
  510. n->Mapper=laValueMapperInit();
  511. }
  512. if(!n->In) n->In=laCreateInSocket("IN",LA_PROP_FLOAT); if(!n->Out) n->Out=laCreateOutSocket(n,"OUT",LA_PROP_FLOAT);
  513. if(!n->InMin) n->InMin=laCreateInSocket("[IN",LA_PROP_FLOAT); if(!n->InMax) n->InMax=laCreateInSocket("IN]",LA_PROP_FLOAT);
  514. if(!n->OutMin) n->OutMin=laCreateInSocket("[OUT",LA_PROP_FLOAT); if(!n->OutMax) n->OutMax=laCreateInSocket("OUT]",LA_PROP_FLOAT);
  515. n->Out->Data=&n->rOut;
  516. }
  517. void IDN_MapperDestroy(laMapperNode* n){
  518. strSafeDestroy(&n->Base.Name);
  519. laDestroyInSocket(n->In); laDestroyOutSocket(n->Out);
  520. laDestroyInSocket(n->InMin); laDestroyInSocket(n->InMax); laDestroyInSocket(n->OutMin); laDestroyInSocket(n->OutMax);
  521. laValueMapperDestroy(n->Mapper);
  522. }
  523. int IDN_MapperVisit(laMapperNode* n, laNodeVisitInfo* vi){
  524. LA_GUARD_THIS_NODE(n,vi);
  525. if(LA_SRC_AND_PARENT(n->In)){ laBaseNode* bn=n->In->Source->Parent; LA_VISIT_NODE(bn,vi); }
  526. if(LA_SRC_AND_PARENT(n->InMin)){ laBaseNode* bn=n->InMin->Source->Parent; LA_VISIT_NODE(bn,vi); }
  527. if(LA_SRC_AND_PARENT(n->InMax)){ laBaseNode* bn=n->InMax->Source->Parent; LA_VISIT_NODE(bn,vi); }
  528. if(LA_SRC_AND_PARENT(n->OutMin)){ laBaseNode* bn=n->OutMin->Source->Parent; LA_VISIT_NODE(bn,vi); }
  529. if(LA_SRC_AND_PARENT(n->OutMax)){ laBaseNode* bn=n->OutMax->Source->Parent; LA_VISIT_NODE(bn,vi); }
  530. LA_ADD_THIS_NODE(n,vi);
  531. return LA_DAG_FLAG_PERM;
  532. }
  533. int IDN_MapperEval(laMapperNode* n){
  534. real in=0; real* InMin=0,*InMax=0,*OutMin=0,*OutMax=0;
  535. if(LA_SRC_AND_PARENT(n->In) && (n->In->Source->DataType&LA_PROP_FLOAT)){ in=*((real*)n->In->Source->Data); }
  536. if(LA_SRC_AND_PARENT(n->InMin) && (n->InMin->Source->DataType&LA_PROP_FLOAT)){ InMin=n->InMin->Source->Data; }
  537. if(LA_SRC_AND_PARENT(n->InMax) && (n->InMax->Source->DataType&LA_PROP_FLOAT)){ InMax=n->InMax->Source->Data; }
  538. if(LA_SRC_AND_PARENT(n->OutMin) && (n->OutMin->Source->DataType&LA_PROP_FLOAT)){ OutMin=n->OutMin->Source->Data; }
  539. if(LA_SRC_AND_PARENT(n->OutMax) && (n->OutMax->Source->DataType&LA_PROP_FLOAT)){ OutMax=n->OutMax->Source->Data; }
  540. real result=laValueMapperEvaluate(n->Mapper,in,InMin,InMax,OutMin,OutMax,n->ClampInput,n->ClampOutput);
  541. n->rOut=result;
  542. return 1;
  543. }
  544. void laui_MapperNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  545. laColumn* c=laFirstColumn(uil); laMapperNode*n=This->EndInstance;
  546. laColumn* cl,*cr; laSplitColumn(uil,c,0.4); cl=laLeftColumn(c,3); cr=laRightColumn(c,0);
  547. laUiItem*b,*b2;
  548. LA_BASE_NODE_HEADER(uil,c,This);
  549. b=laBeginRow(uil,c,0,0);
  550. laShowNodeSocket(uil,c,This,"in",0)->Flags|=LA_UI_SOCKET_LABEL_E; laShowItemFull(uil,c,This,"clamp_input",0,"text=C",0,0); laShowNodeSocket(uil,c,This,"in_min",0);
  551. laShowItem(uil,c,This,"mapper.in_range")->Expand=1; laShowNodeSocket(uil,c,This,"in_max",0);
  552. laEndRow(uil,b);
  553. laShowItem(uil,c,This,"mapper");
  554. b=laBeginRow(uil,c,0,0);
  555. laShowNodeSocket(uil,c,This,"out_min",0); laShowItem(uil,c,This,"mapper.out_range")->Expand=1;
  556. laShowNodeSocket(uil,c,This,"out_max",0); laShowItemFull(uil,c,This,"clamp_output",0,"text=C",0,0); laShowNodeSocket(uil,c,This,"out",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  557. laEndRow(uil,b);
  558. }
  559. void IDN_RandomInit(laRandomNode* n, int NoCreate){
  560. if(!NoCreate){
  561. strSafeSet(&n->Base.Name,"Random"); n->Out=laCreateOutSocket(n,"RAND",LA_PROP_FLOAT); n->Min=0; n->Max=1;
  562. }
  563. if(!n->InMin) n->InMin=laCreateInSocket("[IN",LA_PROP_FLOAT); if(!n->InMax) n->InMax=laCreateInSocket("IN]",LA_PROP_FLOAT);
  564. n->Out->Data=&n->rOut;
  565. }
  566. void IDN_RandomDestroy(laRandomNode* n){
  567. strSafeDestroy(&n->Base.Name); laDestroyOutSocket(n->Out); laDestroyInSocket(n->InMin); laDestroyInSocket(n->InMax);
  568. }
  569. int IDN_RandomVisit(laRandomNode* n, laNodeVisitInfo* vi){
  570. LA_GUARD_THIS_NODE(n,vi);
  571. if(LA_SRC_AND_PARENT(n->InMin)){ laBaseNode* bn=n->InMin->Source->Parent; LA_VISIT_NODE(bn,vi); }
  572. if(LA_SRC_AND_PARENT(n->InMax)){ laBaseNode* bn=n->InMax->Source->Parent; LA_VISIT_NODE(bn,vi); }
  573. LA_ADD_THIS_NODE(n,vi);
  574. return LA_DAG_FLAG_PERM;
  575. }
  576. int IDN_RandomEval(laRandomNode* n){
  577. real Min=n->Min,Max=n->Max;
  578. if(LA_SRC_AND_PARENT(n->InMin) && (n->InMin->Source->DataType&LA_PROP_FLOAT)){ Min=*((real*)n->InMin->Source->Data); }
  579. if(LA_SRC_AND_PARENT(n->InMax) && (n->InMax->Source->DataType&LA_PROP_FLOAT)){ Max=*((real*)n->InMax->Source->Data); }
  580. n->rOut=Min+(real)rand()/(real)(RAND_MAX/(Max-Min));
  581. return 1;
  582. }
  583. void laui_RandomNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  584. laColumn* c=laFirstColumn(uil); laRandomNode*n=This->EndInstance;
  585. laColumn* cl,*cr; laSplitColumn(uil,c,0.4); cl=laLeftColumn(c,3); cr=laRightColumn(c,0);
  586. laUiItem*b,*b2;
  587. LA_BASE_NODE_HEADER(uil,c,This);
  588. b=laBeginRow(uil,c,0,0);
  589. laShowNodeSocket(uil,c,This,"min",0); laShowItem(uil,c,This,"range")->Expand=1; laShowNodeSocket(uil,c,This,"max",0);
  590. laShowNodeSocket(uil,c,This,"out",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  591. laEndRow(uil,b);
  592. }
  593. void IDN_VectorMathInit(laVectorMathNode* n, int NoCreate){
  594. if(!NoCreate){
  595. strSafeSet(&n->Base.Name,"Math");
  596. n->InL=laCreateInSocket("l",0); n->InR=laCreateInSocket("r",0);
  597. n->Out=laCreateOutSocket(n,"OUT",LA_PROP_FLOAT);
  598. }
  599. n->Out->Data=n->rOut;
  600. }
  601. void IDN_VectorMathDestroy(laVectorMathNode* n){
  602. strSafeDestroy(&n->Base.Name); laDestroyInSocket(n->InL); laDestroyInSocket(n->InR); laDestroyOutSocket(n->Out);
  603. }
  604. int IDN_VectorMathVisit(laVectorMathNode* n, laNodeVisitInfo* vi){
  605. LA_GUARD_THIS_NODE(n,vi);
  606. if(LA_SRC_AND_PARENT(n->InL)){ laBaseNode* bn=n->InL->Source->Parent; LA_VISIT_NODE(bn,vi); }
  607. if(LA_SRC_AND_PARENT(n->InR)){ laBaseNode* bn=n->InR->Source->Parent; LA_VISIT_NODE(bn,vi); }
  608. LA_ADD_THIS_NODE(n,vi);
  609. return LA_DAG_FLAG_PERM;
  610. }
  611. #define LA_GET_SRC_AS_FLOAT_THINGS(var, socket, maxlen) \
  612. {if(socket->Source->DataType&LA_PROP_FLOAT){ real*adr=socket->Source->Data; maxlen=TNS_MIN2(TNS_MAX2(1,socket->Source->ArrLen),maxlen); for(int i=0;i<maxlen;i++){ var[i]=adr[i]; } }\
  613. if(socket->Source->DataType&(LA_PROP_INT|LA_PROP_ENUM)){ int*adr=socket->Source->Data; maxlen=TNS_MIN2(TNS_MAX2(1,socket->Source->ArrLen),maxlen); for(int i=0;i<maxlen;i++){ var[i]=adr[i]; } }\
  614. }
  615. int IDN_VectorMathEval(laVectorMathNode* n){
  616. real vl[4]={0,0,0,1};real vr[4]={0,0,0,1}; int maxlen1=4,maxlen2=4,maxlen;
  617. int hasl=LA_SRC_AND_PARENT(n->InL),hasr=LA_SRC_AND_PARENT(n->InR);
  618. if(hasl){ LA_GET_SRC_AS_FLOAT_THINGS(vl,n->InL,maxlen1) } if(hasr){ LA_GET_SRC_AS_FLOAT_THINGS(vr,n->InR,maxlen2) }
  619. if(maxlen1>1 && maxlen2<maxlen1){ for(int i=maxlen2;i<maxlen1;i++){ vr[i]=vr[maxlen2-1]; } maxlen=maxlen1; }
  620. else{ maxlen=TNS_MIN2(maxlen1,maxlen2); }
  621. switch(n->Operation){
  622. case LA_VECTOR_MATH_OP_ADD: default:n->Out->ArrLen=maxlen; for(int i=0;i<maxlen;i++)n->rOut[i]=vl[i]+vr[i]; break;
  623. case LA_VECTOR_MATH_OP_SUB:n->Out->ArrLen=maxlen; for(int i=0;i<maxlen;i++)n->rOut[i]=vl[i]-vr[i]; break;
  624. case LA_VECTOR_MATH_OP_MUL:n->Out->ArrLen=maxlen; for(int i=0;i<maxlen;i++)n->rOut[i]=vl[i]*vr[i]; break;
  625. case LA_VECTOR_MATH_OP_DIV:n->Out->ArrLen=maxlen; for(int i=0;i<maxlen;i++)n->rOut[i]=vl[i]/vr[i]; break;
  626. case LA_VECTOR_MATH_OP_POW:n->Out->ArrLen=maxlen; for(int i=0;i<maxlen;i++)n->rOut[i]=pow(vl[i],vr[i]); break;
  627. case LA_VECTOR_MATH_OP_LOG:n->Out->ArrLen=maxlen; for(int i=0;i<maxlen;i++)n->rOut[i]=log2(vl[i])/log2(vr[i]); break;
  628. case LA_VECTOR_MATH_OP_CROSS: if(maxlen<3) return 0; n->Out->ArrLen=3; tnsVectorCross3d(n->rOut,vl,vr); break;
  629. case LA_VECTOR_MATH_OP_DOT: if(maxlen<2) return 0; n->Out->ArrLen=1; if(maxlen==2) n->rOut[0]=tnsDot2d(vl,vr,0); else n->rOut[0]=tnsDot3d(vl,vr,0); break;
  630. case LA_VECTOR_MATH_OP_LEN: if(maxlen<2) return 0; n->Out->ArrLen=1;
  631. if(maxlen==2){ tnsVector2d d; tnsVectorMinus2d(d,vr,vl); n->rOut[0]=tnsLength2d(d); }
  632. else { tnsVector3d d; tnsVectorMinus2d(d,vr,vl); n->rOut[0]=tnsLength3d(d); } break;
  633. case LA_VECTOR_MATH_OP_NORMALIZE: if(maxlen<2) return 0; n->Out->ArrLen=maxlen; if(maxlen==2) tnsNormalize2d(n->rOut, vl); else tnsNormalize3d(n->rOut, vl); break;
  634. }
  635. return 1;
  636. }
  637. void laui_VectorMathNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  638. laColumn* c=laFirstColumn(uil); laVectorMathNode*n=This->EndInstance;
  639. laColumn* cl,*cr; laSplitColumn(uil,c,0.4); cl=laLeftColumn(c,3); cr=laRightColumn(c,0);
  640. laUiItem*b,*b2;
  641. LA_BASE_NODE_HEADER(uil,c,This);
  642. b=laBeginRow(uil,c,0,0);
  643. laShowNodeSocket(uil,c,This,"in_l",0); laShowNodeSocket(uil,c,This,"in_r",0);
  644. laShowSeparator(uil,c)->Expand=1;
  645. laShowItem(uil,c,This,"operation");
  646. laShowNodeSocket(uil,c,This,"out",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  647. laEndRow(uil,b);
  648. }
  649. void IDN_CommentInit(laCommentNode* n, int NoCreate){
  650. if(NoCreate){return;}
  651. strSafeSet(&n->Base.Name,"Math"); strSafeSet(&n->Content,"");
  652. }
  653. void IDN_CommentDestroy(laCommentNode* n){
  654. strSafeDestroy(&n->Base.Name); strSafeDestroy(&n->Content);
  655. }
  656. int IDN_CommentVisit(laCommentNode* n, laNodeVisitInfo* vi){
  657. //LA_GUARD_THIS_NODE(n,vi);
  658. //LA_ADD_THIS_NODE(n,vi);
  659. // No need to evaluate comments I guess?
  660. return LA_DAG_FLAG_PERM;
  661. }
  662. int IDN_CommentEval(laCommentNode* n){ return 1; }
  663. void laui_CommentNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  664. laColumn* c=laFirstColumn(uil); laCommentNode*n=This->EndInstance;
  665. LA_BASE_NODE_HEADER(uil,c,This);
  666. laColumn* cl,*cr; laSplitColumn(uil,c,0.7); cl=laLeftColumn(c,0);cr=laRightColumn(c,1);
  667. laUiItem* b=laOnConditionToggle(uil,cr,0,0,0,0,0);{
  668. laShowItemFull(uil,cl,This,"content",LA_WIDGET_STRING_MULTI,0,0,0)->Flags|=LA_UI_FLAGS_NO_SCROLL_INACTIVE;
  669. }laElse(uil,b);{
  670. laShowItemFull(uil,cl,This,"content",LA_WIDGET_STRING_PLAIN,0,0,0)->Flags|=LA_TEXT_LINE_WRAP;
  671. }laEndCondition(uil,b);}
  672. void IDN_RGB2OKHSLInit(laRGB2OKHSLNode* n, int NoCreate){
  673. if(!NoCreate){
  674. strSafeSet(&n->Base.Name,"RGB to OKHL"); n->In=laCreateInSocket("IN",LA_PROP_FLOAT);
  675. n->OutH=laCreateOutSocket(n,"H",LA_PROP_FLOAT);
  676. n->OutS=laCreateOutSocket(n,"S",LA_PROP_FLOAT);
  677. n->OutL=laCreateOutSocket(n,"L",LA_PROP_FLOAT);
  678. tnsVectorSet3(n->RGB,0.2,0.2,0.2);
  679. }
  680. n->OutH->Data=&n->rOut[0]; n->OutS->Data=&n->rOut[1]; n->OutL->Data=&n->rOut[2];
  681. }
  682. void IDN_RGB2OKHSLDestroy(laRGB2OKHSLNode* n){
  683. strSafeDestroy(&n->Base.Name);
  684. laDestroyInSocket(n->In); laDestroyOutSocket(n->OutH); laDestroyOutSocket(n->OutS); laDestroyOutSocket(n->OutL);
  685. }
  686. int IDN_RGB2OKHSLVisit(laRGB2OKHSLNode* n, laNodeVisitInfo* vi){
  687. LA_GUARD_THIS_NODE(n,vi);
  688. if(LA_SRC_AND_PARENT(n->In)){ laBaseNode* bn=n->In->Source->Parent; LA_VISIT_NODE(bn,vi); }
  689. LA_ADD_THIS_NODE(n,vi);
  690. return LA_DAG_FLAG_PERM;
  691. }
  692. int IDN_RGB2OKHSLEval(laRGB2OKHSLNode* n){
  693. real* in=n->RGB;
  694. if(LA_SRC_AND_PARENT(n->In) && (n->In->Source->DataType==(LA_PROP_FLOAT|LA_PROP_ARRAY) && n->In->Source->ArrLen>=3)){ in=n->In->Source->Data; }
  695. tnsRGB2HCYLinear(in, n->rOut);
  696. return 1;
  697. }
  698. void laui_RGB2OKHSLNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  699. laColumn* c=laFirstColumn(uil); laRGB2OKHSLNode*n=This->EndInstance;
  700. laUiItem*b,*b2;
  701. LA_BASE_NODE_HEADER(uil,c,This);
  702. b=laBeginRow(uil,c,0,0);
  703. laShowNodeSocket(uil,c,This,"in",0);
  704. b2=laOnConditionThat(uil,c,laNot(laPropExpression(This,"in.source")));{
  705. laShowItem(uil,c,This,"color");
  706. }laEndCondition(uil,b2);
  707. laShowSeparator(uil,c)->Expand=1;
  708. laShowLabel(uil,c,"OKHSL",0,0);
  709. laShowItem(uil,c,This,"out_h");
  710. laShowItem(uil,c,This,"out_s");
  711. laShowItem(uil,c,This,"out_l");
  712. laEndRow(uil,b);
  713. }
  714. void IDN_OKHSL2RGBInit(laOKHSL2RGBNode* n, int NoCreate){
  715. if(!NoCreate){
  716. strSafeSet(&n->Base.Name,"OKHL to RGB"); n->Out=laCreateOutSocket(n,"RGB",LA_PROP_FLOAT|LA_PROP_ARRAY);
  717. n->InH=laCreateInSocket("H",LA_PROP_FLOAT);
  718. n->InS=laCreateInSocket("S",LA_PROP_FLOAT);
  719. n->InL=laCreateInSocket("L",LA_PROP_FLOAT);
  720. }
  721. n->Out->ArrLen=3; n->Out->Data=n->rOut;
  722. }
  723. void IDN_OKHSL2RGBDestroy(laOKHSL2RGBNode* n){
  724. strSafeDestroy(&n->Base.Name);
  725. laDestroyInSocket(n->InH); laDestroyInSocket(n->InS); laDestroyInSocket(n->InL); laDestroyOutSocket(n->Out);
  726. }
  727. int IDN_OKHSL2RGBVisit(laOKHSL2RGBNode* n, laNodeVisitInfo* vi){
  728. LA_GUARD_THIS_NODE(n,vi);
  729. if(LA_SRC_AND_PARENT(n->InH)){ laBaseNode* bn=n->InH->Source->Parent; LA_VISIT_NODE(bn,vi); }
  730. if(LA_SRC_AND_PARENT(n->InS)){ laBaseNode* bn=n->InS->Source->Parent; LA_VISIT_NODE(bn,vi); }
  731. if(LA_SRC_AND_PARENT(n->InL)){ laBaseNode* bn=n->InL->Source->Parent; LA_VISIT_NODE(bn,vi); }
  732. LA_ADD_THIS_NODE(n,vi);
  733. return LA_DAG_FLAG_PERM;
  734. }
  735. int IDN_OKHSL2RGBEval(laOKHSL2RGBNode* n){
  736. real in[3]={0,0,0};
  737. if(LA_SRC_AND_PARENT(n->InH) && (n->InH->Source->DataType&LA_PROP_FLOAT)){ in[0]=*((real*)n->InH->Source->Data); }
  738. if(LA_SRC_AND_PARENT(n->InS) && (n->InS->Source->DataType&LA_PROP_FLOAT)){ in[1]=*((real*)n->InS->Source->Data); }
  739. if(LA_SRC_AND_PARENT(n->InL) && (n->InL->Source->DataType&LA_PROP_FLOAT)){ in[2]=*((real*)n->InL->Source->Data); }
  740. tnsHCY2RGBLinear(in, n->rOut);
  741. return 1;
  742. }
  743. void laui_OKHSL2RGBNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  744. laColumn* c=laFirstColumn(uil); laOKHSL2RGBNode*n=This->EndInstance;
  745. laUiItem*b,*b2;
  746. LA_BASE_NODE_HEADER(uil,c,This);
  747. b=laBeginRow(uil,c,0,0);
  748. laShowItem(uil,c,This,"in_h");
  749. laShowItem(uil,c,This,"in_s");
  750. laShowItem(uil,c,This,"in_l");
  751. laShowLabel(uil,c,"OKHSL",0,0);
  752. laShowSeparator(uil,c)->Expand=1; laShowNodeSocket(uil,c,This,"out",0)->Flags|=LA_UI_SOCKET_LABEL_W;
  753. laEndRow(uil,b);
  754. }
  755. void IDN_LoopInit(laLoopNode* n, int NoCreate){
  756. if(!NoCreate){
  757. strSafeSet(&n->Base.Name,"Loop");
  758. n->Branch=laCreateInSocket("CTRL",LA_PROP_FLOAT);
  759. n->InIndex=laCreateInSocket("IDX",LA_PROP_FLOAT);
  760. n->InIterations=laCreateInSocket("NUM",LA_PROP_FLOAT);
  761. n->Prev=laCreateInSocket("PREV",LA_PROP_FLOAT); n->Next=laCreateOutSocket(n,"NEXT",LA_PROP_INT);
  762. }
  763. n->Next->Data=&n->Iterations;
  764. }
  765. void IDN_LoopDestroy(laLoopNode* n){
  766. strSafeDestroy(&n->Base.Name);
  767. laDestroyInSocket(n->Prev); laDestroyInSocket(n->InIterations); laDestroyInSocket(n->InIndex);
  768. laDestroyInSocket(n->Branch); laDestroyOutSocket(n->Next);
  769. }
  770. int IDN_LoopVisit(laLoopNode* n, laNodeVisitInfo* vi){
  771. LA_GUARD_THIS_NODE(n,vi);if(!LA_SRC_AND_PARENT(n->Branch)){ return LA_DAG_FLAG_PERM; }
  772. if(LA_SRC_AND_PARENT(n->Prev)){ laBaseNode* bn=n->Prev->Source->Parent; LA_VISIT_NODE(bn,vi); }
  773. if(LA_SRC_AND_PARENT(n->InIterations)){ laBaseNode* bn=n->InIterations->Source->Parent; LA_VISIT_NODE(bn,vi); }
  774. if(LA_SRC_AND_PARENT(n->InIndex)){ laBaseNode* bn=n->InIndex->Source->Parent; LA_VISIT_NODE(bn,vi); }
  775. uint64_t OrigBranch=vi->Branch; int NextBranch=vi->NextBranch; n->Page=vi->Page;
  776. vi->NextBranch+=1; n->BranchControl=(1<<(NextBranch-1));
  777. if(OrigBranch==1){ lstAppendPointer(vi->br,n); }
  778. vi->Branch=OrigBranch|n->BranchControl;
  779. laBaseNode* sw=n->Branch->Source->Parent; LA_VISIT_NODE(sw,vi);
  780. vi->Branch=OrigBranch;
  781. LA_ADD_THIS_NODE(n,vi);
  782. return LA_DAG_FLAG_PERM;
  783. }
  784. #define LA_GET_SRC_AS_INT(var, socket) \
  785. {if(socket->Source->DataType&LA_PROP_FLOAT) var=*((real*)socket->Source->Data);\
  786. if(socket->Source->DataType&(LA_PROP_INT|LA_PROP_ENUM)) var=*((int*)socket->Source->Data);}
  787. int IDN_LoopEval(laLoopNode* n){
  788. laLoopIndexNode* lin=LA_SRC_AND_PARENT(n->InIndex)?n->InIndex->Source->Parent:0;
  789. if(lin->Base.Type!=&LA_IDN_LOOP_INDEX){lin=0;}
  790. int Iterations=n->Iterations;
  791. if(LA_SRC_AND_PARENT(n->InIterations)){ LA_GET_SRC_AS_INT(Iterations, n->InIterations); }
  792. for(int i=0; i<Iterations; i++){
  793. if(lin){ lin->Iteration=i; }
  794. la_PageClearBranch(n->Page,n->BranchControl);
  795. laRunPage(n->Page,n->BranchControl);
  796. }
  797. return 1;
  798. }
  799. void laui_LoopNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  800. laColumn* c=laFirstColumn(uil), *cl,*cr;
  801. laLoopNode*n=This->EndInstance;
  802. laUiItem*b,*b2;
  803. LA_BASE_NODE_HEADER(uil,c,This);
  804. laSplitColumn(uil,c,0.6); cl=laLeftColumn(c,0); cr=laRightColumn(c,5);
  805. b=laBeginRow(uil,cl,0,0);
  806. laShowItem(uil,cl,This,"branch")->Flags|=LA_UI_SOCKET_LABEL_E;
  807. laShowItem(uil,cl,This,"in_iterations")->Flags|=LA_UI_SOCKET_LABEL_E;
  808. laShowSeparator(uil,cl)->Expand=1;
  809. laEndRow(uil,b);
  810. b=laBeginRow(uil,cl,1,0);
  811. laShowItem(uil,cl,This,"index")->Flags|=LA_UI_SOCKET_LABEL_E;
  812. laShowItem(uil,cl,This,"iterations");
  813. laShowSeparator(uil,cl)->Expand=1;
  814. laEndRow(uil,b);
  815. b=laBeginRow(uil,cr,1,0);
  816. laShowItem(uil,cr,This,"prev")->Flags|=LA_UI_SOCKET_LABEL_S;
  817. laShowItem(uil,cr,This,"next")->Flags|=LA_UI_SOCKET_LABEL_N;
  818. laEndRow(uil,b);
  819. }
  820. void IDN_LoopIndexInit(laLoopIndexNode* n, int NoCreate){
  821. if(!NoCreate){
  822. strSafeSet(&n->Base.Name,"Loop Index");
  823. n->Out=laCreateOutSocket(n,"IDX",LA_PROP_INT);
  824. }
  825. n->Out->Data=&n->Iteration; n->Out->DataType=LA_PROP_INT;
  826. }
  827. void IDN_LoopIndexDestroy(laLoopIndexNode* n){
  828. strSafeDestroy(&n->Base.Name);
  829. laDestroyOutSocket(n->Out);
  830. }
  831. int IDN_LoopIndexVisit(laLoopIndexNode* n, laNodeVisitInfo* vi){
  832. LA_GUARD_THIS_NODE(n,vi);
  833. LA_ADD_THIS_NODE(n,vi);
  834. return LA_DAG_FLAG_PERM;
  835. }
  836. int IDN_LoopIndexEval(laLoopIndexNode* n){
  837. return 1;
  838. }
  839. void laui_LoopIndexNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  840. laColumn* c=laFirstColumn(uil);
  841. laLoopIndexNode*n=This->EndInstance;
  842. laUiItem*b,*b2;
  843. LA_BASE_NODE_HEADER(uil,c,This);
  844. b=laBeginRow(uil,c,0,0);
  845. laShowSeparator(uil,c)->Expand=1;
  846. laShowItem(uil,c,This,"index")->Flags|=LA_UI_SOCKET_LABEL_W;
  847. laEndRow(uil,b);
  848. }
  849. int OPINV_AddInputMapperPage(laOperator* a, laEvent *e){
  850. laRackPage* dp=memAcquireHyper(sizeof(laRackPage));
  851. strSafeSet(&dp->Name,"New Page");
  852. lstAppendItem(&MAIN.InputMapping->Pages, dp);
  853. memAssignRef(MAIN.InputMapping,&MAIN.InputMapping->CurrentPage,dp); dp->RackType=LA_RACK_TYPE_INPUT;
  854. laNotifyUsers("la.input_mapping"); laRecordAndPush(0,"la.input_mapping","Add Page", 0);
  855. return LA_FINISHED;
  856. }
  857. int OPINV_AddNodesRack(laOperator* a, laEvent *e){
  858. laRackPage* dp=a->This?a->This->EndInstance:0; if(!dp) return LA_FINISHED;
  859. laNodeRack* ir=memAcquire(sizeof(laNodeRack));
  860. strSafeSet(&ir->Name,"New Rack");
  861. lstAppendItem(&dp->Racks, ir); ir->ParentPage=dp;
  862. ir->RackType=dp->RackType;
  863. laNotifyInstanceUsers(dp); laRecordInstanceDifferences(dp,"la_node_rack"); laPushDifferences("Add Rack", 0);
  864. return LA_FINISHED;
  865. }
  866. int OPINV_RebuildInputMapping(laOperator* a, laEvent *e){
  867. laGraphRequestRebuild();
  868. return LA_FINISHED;
  869. }
  870. laBaseNode* la_CreateNode(laNodeRack* ir, laBaseNodeType* NodeType){
  871. laBaseNode* bn=memAcquire(NodeType->NodeSize);
  872. bn->Type=NodeType; NodeType->Init(bn, 0); bn->InitDone=1; lstAppendItem(&ir->Nodes, bn); bn->InRack=ir;
  873. laNotifyInstanceUsers(ir); laRecordInstanceDifferences(ir,"la_node_rack"); laPushDifferences("Add Node", 0);
  874. return bn;
  875. }
  876. void la_DestroyInputMapperNode(laBaseNode* bn){
  877. lstRemoveItem(bn->InRack, bn); bn->Type->Destroy(bn);
  878. laNotifyUsers("la.input_racks"); laRecordAndPush(0,"la.input_mapping","Delete node", 0);
  879. memLeave(bn);
  880. }
  881. int OPINV_AddNode(laOperator* a, laEvent *e){
  882. laNodeRack* ir=a->This?a->This->EndInstance:0; if(!ir) return LA_CANCELED;
  883. laBaseNodeType* bnt=0;
  884. if(!MAIN.CurrentNodeCategory) MAIN.CurrentNodeCategory=MAIN.NodeCategories.pFirst;
  885. char* target=strGetArgumentString(a->ExtraInstructionsP,"target");
  886. if(!target || strSame(target,"INPUT")){ MAIN.FilterNodeCategory=LA_RACK_TYPE_INPUT;
  887. if(!(MAIN.CurrentNodeCategory->For&LA_RACK_TYPE_INPUT)) MAIN.CurrentNodeCategory=LA_NODE_CATEGORY_INPUT; }
  888. else{ MAIN.FilterNodeCategory=LA_RACK_TYPE_DRIVER;
  889. if(!(MAIN.CurrentNodeCategory->For&LA_RACK_TYPE_DRIVER)) MAIN.CurrentNodeCategory=LA_NODE_CATEGORY_DRIVER; }
  890. char* type=strGetArgumentString(a->ExtraInstructionsP,"type");
  891. if(!type){ laEnableOperatorPanel(a,a->This,e->x-LA_RH*4,e->y-LA_RH,200,200,0,0,LA_RH*15,0,0,0,0,0,e); return LA_RUNNING; }
  892. else{
  893. for(int i=0;i<MAIN.NodeTypeNext;i++){
  894. if(strSame(MAIN.NodeTypes[i]->TypeName,type)){ la_CreateNode(ir, MAIN.NodeTypes[i]); }
  895. }
  896. }
  897. return LA_FINISHED;
  898. }
  899. int OPMOD_AddNode(laOperator* a, laEvent *e){
  900. laNodeRack* r=a->This->EndInstance;
  901. if(a->ConfirmData){
  902. if(a->ConfirmData->StrData){
  903. for(int i=0;i<MAIN.NodeTypeNext;i++){
  904. if(strSame(MAIN.NodeTypes[i]->TypeName,a->ConfirmData->StrData)){ la_CreateNode(r, MAIN.NodeTypes[i]); break; }
  905. }
  906. }
  907. return LA_FINISHED;
  908. }
  909. return LA_RUNNING;
  910. }
  911. void laui_AddNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  912. laColumn* c=laFirstColumn(uil),*cl,*cr; laSplitColumn(uil,c,0.4); cl=laLeftColumn(c,4); cr=laRightColumn(c,0);
  913. laShowItemFull(uil,cl,0,"la.node_categories",LA_WIDGET_COLLECTION,"feedback=NONE;",0,0);
  914. laUiItem* g=laMakeEmptyGroup(uil,cr,"Nodes",0); laUiList* gu=g->Page; laColumn* gc=laFirstColumn(gu); g->Flags|=LA_UI_FLAGS_NO_DECAL|LA_UI_FLAGS_NO_GAP;
  915. laShowItemFull(gu,gc,0,"la.node_categories",LA_WIDGET_COLLECTION_SINGLE,0,laui_NodeCategory,0)->Flags|=LA_UI_FLAGS_NO_DECAL;
  916. }
  917. int OPINV_MoveNodeToRack(laOperator* a, laEvent *e){
  918. laBaseNode* n=a->This?a->This->EndInstance:0; if(!n||!n->InRack) return LA_CANCELED;
  919. laBaseNodeType* bnt=0; laNodeRack* target;
  920. char* direction=strGetArgumentString(a->ExtraInstructionsP,"direction");
  921. if(strSame(direction,"left")) target=n->InRack->Item.pPrev; else target=n->InRack->Item.pNext;
  922. if(!target) return LA_CANCELED;
  923. lstRemoveItem(&n->InRack->Nodes, n); lstAppendItem(&target->Nodes,n); n->InRack=target;
  924. laNotifyInstanceUsers(n->InRack->ParentPage); laRecordInstanceDifferences(n->InRack->ParentPage,"la_node_page"); laPushDifferences("Move Node", 0);
  925. return LA_FINISHED;
  926. }
  927. int OPINV_DeleteNode(laOperator* a, laEvent *e){
  928. laBaseNode* n=a->This?a->This->EndInstance:0; if(!n||!n->InRack) return LA_CANCELED;
  929. laBaseNodeType* bnt=0; laNodeRack* target;
  930. laNodeRack* parent=n->InRack;
  931. lstRemoveItem(&n->InRack->Nodes, n); n->Type->Destroy(n); memLeave(n);
  932. laGraphRequestRebuild();
  933. laNotifyInstanceUsers(parent); laRecordInstanceDifferences(parent,"la_node_rack"); laPushDifferences("Delete Node", 0);
  934. return LA_FINISHED;
  935. }
  936. int OPINV_MoveRack(laOperator* a, laEvent *e){
  937. laNodeRack* r=a->This?a->This->EndInstance:0; if(!r) return LA_CANCELED;
  938. char* direction=strGetArgumentString(a->ExtraInstructionsP,"direction");
  939. if(strSame(direction,"left")) lstMoveUp(&r->ParentPage->Racks,r); else lstMoveDown(&r->ParentPage->Racks,r);
  940. laNotifyInstanceUsers(r->ParentPage); laRecordInstanceDifferences(r->ParentPage,"la_rack_page"); laPushDifferences("Move Rack", 0);
  941. return LA_FINISHED;
  942. }
  943. int OPINV_InsertRack(laOperator* a, laEvent *e){
  944. laNodeRack* rr=a->This?a->This->EndInstance:0; if(!rr) return LA_CANCELED;
  945. laNodeRack* r=memAcquire(sizeof(laNodeRack));
  946. strSafeSet(&r->Name,"New Rack");
  947. lstInsertItemAfter(&rr->ParentPage->Racks,r,rr); r->ParentPage=rr->ParentPage; r->RackType=rr->RackType;
  948. laNotifyInstanceUsers(r->ParentPage); laRecordInstanceDifferences(r->ParentPage,"la_rack_page"); laPushDifferences("Insert Rack", 0);
  949. return LA_FINISHED;
  950. }
  951. int OPINV_DeleteRack(laOperator* a, laEvent *e){
  952. laNodeRack* rr=a->This?a->This->EndInstance:0; if(!rr) return LA_CANCELED;
  953. if(strSame(strGetArgumentString(a->ExtraInstructionsP,"confirm"),"true")){
  954. laBaseNode* n; while(n=lstPopItem(&rr->Nodes)){ n->Type->Destroy(n); memLeave(n); }
  955. laRackPage* page=rr->ParentPage;
  956. strSafeDestroy(&rr->Name); lstRemoveItem(&rr->ParentPage->Racks, rr); memLeave(rr);
  957. laNotifyInstanceUsers(page); laRecordInstanceDifferences(page,"la_rack_page"); laPushDifferences("Delete Rack", 0);
  958. return LA_FINISHED;
  959. }
  960. laEnableOperatorPanel(a,a->This,e->x,e->y,200,200,0,0,0,0,0,0,0,0,e);
  961. return LA_RUNNING;
  962. }
  963. void laui_DeleteRack(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  964. laColumn* c=laFirstColumn(uil);
  965. laShowItemFull(uil,c,This,"delete",0,"confirm=true;",0,0);
  966. }
  967. laPropContainer* laget_BaseNodeType(laBaseNode* bn){
  968. for(int i=0;i<MAIN.NodeTypeNext;i++){ if(bn->Type==MAIN.NodeTypes[i]) return MAIN.NodeTypes[i]->pc; }
  969. return LA_PC_IDN_GENERIC;
  970. }
  971. int laget_BaseNodeGap(laNodeRack* rack_unused, laBaseNode* n){
  972. return n->Gap;
  973. }
  974. void laread_BaseNodeGap(laBaseNode* n, int gap){
  975. n->Gap=gap;
  976. }
  977. void laset_BaseNodeGap(laBaseNode* n, int gap){
  978. laBaseNode* nn;
  979. if(gap==-1){
  980. int done=0; nn=n; while(nn){ if(nn->Gap>0){ nn->Gap--; done=1; break; } nn=nn->Item.pPrev; }
  981. if(done){ nn=n->Item.pNext; while(nn){ if(nn->Gap>0){ nn->Gap++; break; } nn=nn->Item.pNext; } }
  982. }elif(gap==1){
  983. n->Gap+=gap; nn=n->Item.pNext; while(nn){ if(nn->Gap>0){ nn->Gap--; break; } nn=nn->Item.pNext; }
  984. }elif(gap==-2){
  985. if(n->Gap){ n->Gap--; if(nn=n->Item.pNext){ nn->Gap++; } }
  986. elif(nn=n->Item.pPrev){ n->Gap=nn->Gap; nn->Gap=0; lstRemoveItem(&n->InRack->Nodes,n); lstInsertItemBefore(&n->InRack->Nodes,n,nn); }
  987. }elif(gap==2){
  988. if(nn=n->Item.pNext){ if(!nn->Gap){ nn->Gap=n->Gap; n->Gap=0; lstRemoveItem(&n->InRack->Nodes,n); lstInsertItemAfter(&n->InRack->Nodes,n,nn); }else{ nn->Gap--; n->Gap++; } }
  989. else n->Gap++;
  990. }
  991. }
  992. void laset_InputNodeUserID(laInputControllerNode* n, int i){
  993. laNotifyUsers("la.input_racks");
  994. }
  995. void laset_InputControllerNodeSocketWhich(laInputControllerNodeSocket* s, char* str){
  996. strSafeSet(&s->Which, str);
  997. laNotifyUsers("la.input_racks"); laGraphRequestRebuild();
  998. }
  999. int laget_SocketEnumArrayLength(laInputControllerNodeSocket* s){
  1000. return s->Out->ArrLen?s->Out->ArrLen:1;
  1001. }
  1002. int laget_VisualizerArrayLength(laInputVisualizerNode* s){
  1003. return s->In->ArrLen?s->In->ArrLen:1;
  1004. }
  1005. laBoxedTheme* laget_NodeGetTheme(laNodeRack* rack_unused, laBaseNode* n){
  1006. return 0;
  1007. }
  1008. void laRegisterNode(laBaseNodeType* type, laPropContainer* pc,
  1009. laBaseNodeInitF init, laBaseNodeDestroyF destroy, laBaseNodeVisitF visit, laBaseNodeEvalF eval,
  1010. int nodesize, char* udf_string, char* type_string, char* UiText, int icon){
  1011. arrEnsureLength(&MAIN.NodeTypes, MAIN.NodeTypeNext, &MAIN.NodeTypeMax, sizeof(laBaseNode*));
  1012. type->Init = init; type->Destroy = destroy; type->Visit=visit; type->Eval=eval; type->NodeSize=nodesize; type->pc=pc;
  1013. type->TypeName=type_string;type->Name=UiText;type->Icon=icon;
  1014. MAIN.NodeTypes[MAIN.NodeTypeNext]=type; MAIN.NodeTypeNext++;
  1015. la_UDFAppendSharedTypePointer(udf_string, type);
  1016. }
  1017. void lapost_Node(laBaseNode *bn){
  1018. if(!bn->InitDone){
  1019. bn->Type->Init(bn,1);
  1020. bn->InitDone=1;
  1021. }
  1022. }
  1023. void la_AddValuesNodeEnum(laProp* p){
  1024. laAddEnumItemAs(p,"FLOAT","Float","Float value",LA_VALUES_NODE_FLOAT,0);
  1025. laAddEnumItemAs(p,"INT","Int","Int value",LA_VALUES_NODE_INT,0);
  1026. laAddEnumItemAs(p,"ENUM","Switch","Swich value",LA_VALUES_NODE_ENUM,0);
  1027. }
  1028. void la_AddValuesNodeEnumValue(laProp* p){
  1029. laAddEnumItemAs(p,"IDLE","Idle","Idle",0,0);
  1030. laAddEnumItemAs(p,"ACTIVE","Active","Active",1,0);
  1031. }
  1032. void la_RegisterInputMapperOperators(){
  1033. laPropContainer *pc; laProp *p;
  1034. laOperatorType *at;
  1035. laEnumProp *ep;
  1036. laCreateOperatorType("LA_add_input_mapping_page", "Add Page", "Add a page for inpur mapping", 0,0,0,OPINV_AddInputMapperPage,0,'+',0);
  1037. laCreateOperatorType("LA_add_rack", "Add Rack", "Add a rack for nodes", 0,0,0,OPINV_AddNodesRack,0,'+',0);
  1038. at=laCreateOperatorType("OPINV_AddNode", "Add Node", "Add a node to the rack",0,0,0,OPINV_AddNode,OPMOD_AddNode,'+',0);
  1039. at->UiDefine=laui_AddNode;
  1040. laCreateOperatorType("LA_input_mapping_rebuild", "Rebuild Input Mapping", "Rebuild input mapping for evaluation",0,0,0,OPINV_RebuildInputMapping,0,U'⭮',0);
  1041. laCreateOperatorType("LA_move_node_to_rack", "Move Node", "Move node to another rack",0,0,0,OPINV_MoveNodeToRack,0,0,0);
  1042. laCreateOperatorType("LA_delete_node", "Delete Node", "Delete this node",0,0,0,OPINV_DeleteNode,0,0,0);
  1043. laCreateOperatorType("LA_move_rack", "Move Rack", "Move this rack",0,0,0,OPINV_MoveRack,0,0,0);
  1044. laCreateOperatorType("LA_insert_rack", "Insert Rack", "Insert a new rack",0,0,0,OPINV_InsertRack,0,0,0);
  1045. at=laCreateOperatorType("LA_delete_rack", "Delete Rack", "Delete a rack",0,0,0,OPINV_DeleteRack,OPMOD_FinishOnData,U'❌',0);
  1046. at->UiDefine=laui_DeleteRack;
  1047. pc=laAddPropertyContainer("la_node_rack", "Input Rack", "Input rack for putting input mapping nodes",0,0,sizeof(laNodeRack),0,0,1);
  1048. laAddStringProperty(pc,"name","Name","Name of this rack",0,0,0,0,1,offsetof(laNodeRack,Name),0,0,0,0,LA_AS_IDENTIFIER);
  1049. p=laAddSubGroup(pc,"nodes","Nodes","Nodes under this rack","la_base_node",laget_BaseNodeType,0,0,-1,0,0,0,0,0,0,offsetof(laNodeRack,Nodes),0);
  1050. laSubGroupExtraFunctions(p,0,laget_NodeGetTheme,laget_BaseNodeGap,0);
  1051. laAddSubGroup(pc,"parent_page","Parent Page","Parent page of this rack","la_rack_page",0,0,0,offsetof(laNodeRack,ParentPage),0,0,0,0,0,0,0,LA_UDF_REFER);
  1052. laAddIntProperty(pc,"type", "Type", "Type of the rack", 0,0,0,0,0,0,0,0,offsetof(laNodeRack,RackType),0,0,0,0,0,0,0,0,0,0,LA_READ_ONLY);
  1053. laAddOperatorProperty(pc,"add_node","Add Node","Add a node into this rack","OPINV_AddNode",'+',0);
  1054. laAddOperatorProperty(pc,"insert_rack","Insert Rack","Insert a rack","LA_insert_rack",'+',0);
  1055. laAddOperatorProperty(pc,"move","Move Rack","Move this rack","LA_move_rack",0,0);
  1056. laAddOperatorProperty(pc,"delete","Delete Rack","Delete this rack","LA_delete_rack",0,0);
  1057. pc=laAddPropertyContainer("la_base_node", "Input Node", "Input logic node",0,0,sizeof(laBaseNode),0,0,1);
  1058. LA_PC_IDN_GENERIC=pc;
  1059. laAddStringProperty(pc,"name","Name","Name of this input node",0,0,0,0,1,offsetof(laBaseNode,Name),0,0,0,0,LA_AS_IDENTIFIER);
  1060. laAddIntProperty(pc,"__gap", "Gap", "Gap of the node", 0,0,0,0,0,0,0,0,offsetof(laBaseNode,Gap),0,laset_BaseNodeGap,0,0,0,0,0,0,laread_BaseNodeGap,0,0);
  1061. laAddSubGroup(pc,"internal_type","Internal Type","Internal node type","any_pointer",0,0,0,offsetof(laBaseNode,Type),0,0,0,0,0,0,0,LA_READ_ONLY|LA_UDF_REFER);
  1062. laAddOperatorProperty(pc,"move","Move","Move node across racks","LA_move_node_to_rack",0,0);
  1063. laAddOperatorProperty(pc,"delete","Delete","Delete node","LA_delete_node",0,0);
  1064. laAddSubGroup(pc,"in_rack","In Rack","The rack this node is in","la_node_rack",0,0,0,offsetof(laBaseNode,InRack),0,0,0,0,0,0,0,LA_UDF_REFER);
  1065. pc=laAddPropertyContainer("la_input_controller_node", "Controller output", "Output controller values",0,laui_ControllerNode,sizeof(laInputControllerNode),lapost_Node,0,1);
  1066. LA_PC_IDN_CONTROLLER=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1067. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1068. laAddIntProperty(pc,"user_id", "User ID", "Which controller should the data come from", 0,0,0,0,0,0,0,0,offsetof(laInputControllerNode,UserID),0,0,0,0,0,0,0,0,0,0,0);
  1069. laAddSubGroup(pc,"out0","Out 0","Output 0","la_input_controller_node_socket",0,0,0,offsetof(laInputControllerNode, Sockets[0]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1070. laAddSubGroup(pc,"out1","Out 1","Output 1","la_input_controller_node_socket",0,0,0,offsetof(laInputControllerNode, Sockets[1]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1071. laAddSubGroup(pc,"out2","Out 2","Output 2","la_input_controller_node_socket",0,0,0,offsetof(laInputControllerNode, Sockets[2]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1072. laAddSubGroup(pc,"out3","Out 3","Output 3","la_input_controller_node_socket",0,0,0,offsetof(laInputControllerNode, Sockets[3]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1073. laAddSubGroup(pc,"out4","Out 4","Output 4","la_input_controller_node_socket",0,0,0,offsetof(laInputControllerNode, Sockets[4]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1074. laAddSubGroup(pc,"out5","Out 5","Output 5","la_input_controller_node_socket",0,0,0,offsetof(laInputControllerNode, Sockets[5]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1075. laAddSubGroup(pc,"out6","Out 6","Output 6","la_input_controller_node_socket",0,0,0,offsetof(laInputControllerNode, Sockets[6]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1076. laAddSubGroup(pc,"out7","Out 7","Output 7","la_input_controller_node_socket",0,0,0,offsetof(laInputControllerNode, Sockets[7]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1077. pc=laAddPropertyContainer("la_input_controller_node_socket", "Controller Socket", "One value from a controller output",0,0,sizeof(laInputControllerNodeSocket),0,0,1|LA_PROP_OTHER_ALLOC);
  1078. laAddStringProperty(pc,"which","Which","Select which output from the controller",0,0,0,0,1,offsetof(laInputControllerNodeSocket,Which),0,0,laset_InputControllerNodeSocketWhich,0,LA_AS_IDENTIFIER);
  1079. laAddFloatProperty(pc,"axis", "🡘", "Axis value", LA_WIDGET_VALUE_METER,0,0,1,-1,0,0,0,offsetof(laInputControllerNodeSocket,RealVal),0,0,0,0,0,0,0,0,0,0,LA_READ_ONLY|LA_UDF_IGNORE);
  1080. laAddFloatProperty(pc,"axis2d", "2D Axis", "2D Axis value", LA_WIDGET_VALUE_METER,0,0,1,-1,0,0,0,offsetof(laInputControllerNodeSocket,RealVal),0,0,2,0,0,0,0,0,0,0,LA_READ_ONLY|LA_UDF_IGNORE);
  1081. p=laAddEnumProperty(pc,"switch", "SW", "Switch value", LA_WIDGET_ENUM_HIGHLIGHT,0,0,0,0,offsetof(laInputControllerNodeSocket,IntVal),0,0,0,laget_SocketEnumArrayLength,0,0,0,0,0,LA_READ_ONLY|LA_UDF_IGNORE);
  1082. laAddEnumItemAs(p,"IDLE", "Idle", "Button is not pressed", 0, 0);
  1083. laAddEnumItemAs(p,"ACTIVE", "Active", "Button is pressed", 1, 0);
  1084. laAddSubGroup(pc, "out", "Out","Output value","la_out_socket",0,0,0,offsetof(laInputControllerNodeSocket,Out),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1085. pc=laAddPropertyContainer("la_input_visualizer_node", "Visualizer", "Visualizer node",0,laui_InputVisualizeNode,sizeof(laInputVisualizerNode),lapost_Node,0,1);
  1086. LA_PC_IDN_VISUALIZER=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1087. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1088. laAddSubGroup(pc, "in", "In","Input value","la_in_socket",0,0,0,offsetof(laInputVisualizerNode,In),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1089. laAddFloatProperty(pc,"axis", "🡘", "Axis value", LA_WIDGET_VALUE_METER,0,0,1,-1,0,0,0,offsetof(laInputVisualizerNode,RealVal),0,0,0,0,0,0,0,0,0,0,LA_READ_ONLY|LA_UDF_IGNORE);
  1090. laAddFloatProperty(pc,"axis2d", "2D Axis", "2D Axis value", LA_WIDGET_VALUE_METER_2D,0,0,1,-1,0,0,0,offsetof(laInputVisualizerNode,RealVal),0,0,2,0,0,0,0,0,0,0,LA_READ_ONLY|LA_UDF_IGNORE);
  1091. p=laAddEnumProperty(pc,"switch", "SW", "Switch value", LA_WIDGET_ENUM_HIGHLIGHT,0,0,0,0,offsetof(laInputVisualizerNode,IntVal),0,0,0,laget_VisualizerArrayLength,0,0,0,0,0,LA_READ_ONLY|LA_UDF_IGNORE);
  1092. laAddEnumItemAs(p,"IDLE", "Idle", "Button is not pressed", 0, 0);
  1093. laAddEnumItemAs(p,"ACTIVE", "Active", "Button is pressed", 1, 0);
  1094. pc=laAddPropertyContainer("la_split_node", "Split", "Split node",0,laui_SplitNode,sizeof(laSplitNode),0,0,1);
  1095. LA_PC_IDN_SPLIT=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1096. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1097. laAddSubGroup(pc,"in", "In","Input value","la_in_socket",0,0,0,offsetof(laSplitNode,In),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1098. laAddSubGroup(pc,"out0","Out 0","Output 0","la_split_node_out_socket",0,0,0,offsetof(laSplitNode, Out[0]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1099. laAddSubGroup(pc,"out1","Out 1","Output 1","la_split_node_out_socket",0,0,0,offsetof(laSplitNode, Out[1]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1100. laAddSubGroup(pc,"out2","Out 2","Output 2","la_split_node_out_socket",0,0,0,offsetof(laSplitNode, Out[2]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1101. laAddSubGroup(pc,"out3","Out 3","Output 3","la_split_node_out_socket",0,0,0,offsetof(laSplitNode, Out[3]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1102. laAddSubGroup(pc,"out4","Out 4","Output 4","la_split_node_out_socket",0,0,0,offsetof(laSplitNode, Out[4]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1103. laAddSubGroup(pc,"out5","Out 5","Output 5","la_split_node_out_socket",0,0,0,offsetof(laSplitNode, Out[5]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1104. laAddSubGroup(pc,"out6","Out 6","Output 6","la_split_node_out_socket",0,0,0,offsetof(laSplitNode, Out[6]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1105. laAddSubGroup(pc,"out7","Out 7","Output 7","la_split_node_out_socket",0,0,0,offsetof(laSplitNode, Out[7]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1106. laAddIntProperty(pc, "array_length", "Array Length", "Array length of data", 0, 0, 0, 0, 0, 0, 0, 0, offsetof(laSplitNode, ArrLen), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,LA_READ_ONLY);
  1107. pc=laAddPropertyContainer("la_split_node_out_socket", "Split Out", "One value from an array input",0,0,sizeof(laSplitNodeOutSocket),0,0,1|LA_PROP_OTHER_ALLOC);
  1108. laAddSubGroup(pc, "out", "Out","Output value","la_out_socket",0,0,0,offsetof(laSplitNodeOutSocket,Out),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1109. pc=laAddPropertyContainer("la_switch_node", "Switch", "Switch node",0,laui_SwitchNode,sizeof(laSwitchNode),0,0,1);
  1110. LA_PC_IDN_SWITCH=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1111. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1112. laAddSubGroup(pc,"out", "Out","Output value","la_out_socket",0,0,0,offsetof(laSwitchNode, Out),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1113. laAddSubGroup(pc,"in0","In 0","Input 0","la_switch_node_in_socket",0,0,0,offsetof(laSwitchNode, In[0]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1114. laAddSubGroup(pc,"in1","In 1","Input 1","la_switch_node_in_socket",0,0,0,offsetof(laSwitchNode, In[1]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1115. laAddSubGroup(pc,"in2","In 2","Input 2","la_switch_node_in_socket",0,0,0,offsetof(laSwitchNode, In[2]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1116. laAddSubGroup(pc,"in3","In 3","Input 3","la_switch_node_in_socket",0,0,0,offsetof(laSwitchNode, In[3]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1117. laAddSubGroup(pc,"in4","In 4","Input 4","la_switch_node_in_socket",0,0,0,offsetof(laSwitchNode, In[4]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1118. laAddSubGroup(pc,"in5","In 5","Input 5","la_switch_node_in_socket",0,0,0,offsetof(laSwitchNode, In[5]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1119. laAddSubGroup(pc,"in6","In 6","Input 6","la_switch_node_in_socket",0,0,0,offsetof(laSwitchNode, In[6]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1120. laAddSubGroup(pc,"in7","In 7","Input 7","la_switch_node_in_socket",0,0,0,offsetof(laSwitchNode, In[7]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1121. laAddIntProperty(pc, "switch", "Switch", "Switch which input to use", 0, 0, 0, 0, 0, 0, 0, 0, offsetof(laSwitchNode, Switch), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  1122. laAddSubGroup(pc,"switch_in", "Switch In","Switch control","la_in_socket",0,0,0,offsetof(laSwitchNode,SwitchIn),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1123. pc=laAddPropertyContainer("la_switch_node_in_socket", "Switch In", "Input of many values",0,0,sizeof(laSwitchNodeInSocket),0,0,1|LA_PROP_OTHER_ALLOC);
  1124. laAddSubGroup(pc, "in", "In","Input value","la_in_socket",0,0,0,offsetof(laSwitchNodeInSocket,In),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1125. pc=laAddPropertyContainer("la_combine_node", "Combine", "Combine node",0,laui_CombineNode,sizeof(laCombineNode),0,0,1);
  1126. LA_PC_IDN_COMBINE=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1127. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1128. laAddSubGroup(pc,"out", "Out","Output value","la_out_socket",0,0,0,offsetof(laCombineNode, Out),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1129. laAddSubGroup(pc,"out_int", "Out Int","Output value in int format","la_out_socket",0,0,0,offsetof(laCombineNode, OutInt),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1130. laAddSubGroup(pc,"out_enum", "Out Enum","Output value in Enum format","la_out_socket",0,0,0,offsetof(laCombineNode, OutEnum),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1131. laAddSubGroup(pc,"in0","In 0","Input 0","la_switch_node_in_socket",0,0,0,offsetof(laCombineNode, In[0]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1132. laAddSubGroup(pc,"in1","In 1","Input 1","la_switch_node_in_socket",0,0,0,offsetof(laCombineNode, In[1]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1133. laAddSubGroup(pc,"in2","In 2","Input 2","la_switch_node_in_socket",0,0,0,offsetof(laCombineNode, In[2]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1134. laAddSubGroup(pc,"in3","In 3","Input 3","la_switch_node_in_socket",0,0,0,offsetof(laCombineNode, In[3]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1135. laAddSubGroup(pc,"in4","In 4","Input 4","la_switch_node_in_socket",0,0,0,offsetof(laCombineNode, In[4]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1136. laAddSubGroup(pc,"in5","In 5","Input 5","la_switch_node_in_socket",0,0,0,offsetof(laCombineNode, In[5]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1137. laAddSubGroup(pc,"in6","In 6","Input 6","la_switch_node_in_socket",0,0,0,offsetof(laCombineNode, In[6]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1138. laAddSubGroup(pc,"in7","In 7","Input 7","la_switch_node_in_socket",0,0,0,offsetof(laCombineNode, In[7]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1139. pc=laAddPropertyContainer("la_values_node", "Values", "Values node",0,laui_ValuesNode,sizeof(laValuesNode),lapost_Node,0,1);
  1140. LA_PC_IDN_VALUES=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1141. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1142. laAddSubGroup(pc,"out0","Out 0","Output 0","la_split_node_out_socket",0,0,0,offsetof(laValuesNode, Out[0]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1143. laAddSubGroup(pc,"out1","Out 1","Output 1","la_split_node_out_socket",0,0,0,offsetof(laValuesNode, Out[1]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1144. laAddSubGroup(pc,"out2","Out 2","Output 2","la_split_node_out_socket",0,0,0,offsetof(laValuesNode, Out[2]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1145. laAddSubGroup(pc,"out3","Out 3","Output 3","la_split_node_out_socket",0,0,0,offsetof(laValuesNode, Out[3]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1146. laAddSubGroup(pc,"out4","Out 4","Output 4","la_split_node_out_socket",0,0,0,offsetof(laValuesNode, Out[4]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1147. laAddSubGroup(pc,"out5","Out 5","Output 5","la_split_node_out_socket",0,0,0,offsetof(laValuesNode, Out[5]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1148. laAddSubGroup(pc,"out6","Out 6","Output 6","la_split_node_out_socket",0,0,0,offsetof(laValuesNode, Out[6]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1149. laAddSubGroup(pc,"out7","Out 7","Output 7","la_split_node_out_socket",0,0,0,offsetof(laValuesNode, Out[7]),0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1150. p=laAddEnumProperty(pc,"mode0","Mode 0","Mode 0",LA_WIDGET_ENUM_CYCLE,0,0,0,0,offsetof(laValuesNode, Modes[0]),0,0,0,0,0,0,0,0,0,0); la_AddValuesNodeEnum(p);
  1151. p=laAddEnumProperty(pc,"mode1","Mode 1","Mode 1",LA_WIDGET_ENUM_CYCLE,0,0,0,0,offsetof(laValuesNode, Modes[1]),0,0,0,0,0,0,0,0,0,0); la_AddValuesNodeEnum(p);
  1152. p=laAddEnumProperty(pc,"mode2","Mode 2","Mode 2",LA_WIDGET_ENUM_CYCLE,0,0,0,0,offsetof(laValuesNode, Modes[2]),0,0,0,0,0,0,0,0,0,0); la_AddValuesNodeEnum(p);
  1153. p=laAddEnumProperty(pc,"mode3","Mode 3","Mode 3",LA_WIDGET_ENUM_CYCLE,0,0,0,0,offsetof(laValuesNode, Modes[3]),0,0,0,0,0,0,0,0,0,0); la_AddValuesNodeEnum(p);
  1154. p=laAddEnumProperty(pc,"mode4","Mode 4","Mode 4",LA_WIDGET_ENUM_CYCLE,0,0,0,0,offsetof(laValuesNode, Modes[4]),0,0,0,0,0,0,0,0,0,0); la_AddValuesNodeEnum(p);
  1155. p=laAddEnumProperty(pc,"mode5","Mode 5","Mode 5",LA_WIDGET_ENUM_CYCLE,0,0,0,0,offsetof(laValuesNode, Modes[5]),0,0,0,0,0,0,0,0,0,0); la_AddValuesNodeEnum(p);
  1156. p=laAddEnumProperty(pc,"mode6","Mode 6","Mode 6",LA_WIDGET_ENUM_CYCLE,0,0,0,0,offsetof(laValuesNode, Modes[6]),0,0,0,0,0,0,0,0,0,0); la_AddValuesNodeEnum(p);
  1157. p=laAddEnumProperty(pc,"mode7","Mode 7","Mode 7",LA_WIDGET_ENUM_CYCLE,0,0,0,0,offsetof(laValuesNode, Modes[7]),0,0,0,0,0,0,0,0,0,0); la_AddValuesNodeEnum(p);
  1158. laAddIntProperty(pc, "valuei0", "Value", "Int value 0", 0,0,0,0,0,0,0,0,offsetof(laValuesNode, ValuesI[0]),0,0,0,0,0,0,0,0,0,0,0);
  1159. laAddIntProperty(pc, "valuei1", "Value", "Int value 1", 0,0,0,0,0,0,0,0,offsetof(laValuesNode, ValuesI[1]),0,0,0,0,0,0,0,0,0,0,0);
  1160. laAddIntProperty(pc, "valuei2", "Value", "Int value 2", 0,0,0,0,0,0,0,0,offsetof(laValuesNode, ValuesI[2]),0,0,0,0,0,0,0,0,0,0,0);
  1161. laAddIntProperty(pc, "valuei3", "Value", "Int value 3", 0,0,0,0,0,0,0,0,offsetof(laValuesNode, ValuesI[3]),0,0,0,0,0,0,0,0,0,0,0);
  1162. laAddIntProperty(pc, "valuei4", "Value", "Int value 4", 0,0,0,0,0,0,0,0,offsetof(laValuesNode, ValuesI[4]),0,0,0,0,0,0,0,0,0,0,0);
  1163. laAddIntProperty(pc, "valuei5", "Value", "Int value 5", 0,0,0,0,0,0,0,0,offsetof(laValuesNode, ValuesI[5]),0,0,0,0,0,0,0,0,0,0,0);
  1164. laAddIntProperty(pc, "valuei6", "Value", "Int value 6", 0,0,0,0,0,0,0,0,offsetof(laValuesNode, ValuesI[6]),0,0,0,0,0,0,0,0,0,0,0);
  1165. laAddIntProperty(pc, "valuei7", "Value", "Int value 7", 0,0,0,0,0,0,0,0,offsetof(laValuesNode, ValuesI[7]),0,0,0,0,0,0,0,0,0,0,0);
  1166. laAddFloatProperty(pc, "value0", "Value", "Float value 0", 0,0,0,0,0,0,0,0,offsetof(laValuesNode, Values[0]),0,0,0,0,0,0,0,0,0,0,0);
  1167. laAddFloatProperty(pc, "value1", "Value", "Float value 1", 0,0,0,0,0,0,0,0,offsetof(laValuesNode, Values[1]),0,0,0,0,0,0,0,0,0,0,0);
  1168. laAddFloatProperty(pc, "value2", "Value", "Float value 2", 0,0,0,0,0,0,0,0,offsetof(laValuesNode, Values[2]),0,0,0,0,0,0,0,0,0,0,0);
  1169. laAddFloatProperty(pc, "value3", "Value", "Float value 3", 0,0,0,0,0,0,0,0,offsetof(laValuesNode, Values[3]),0,0,0,0,0,0,0,0,0,0,0);
  1170. laAddFloatProperty(pc, "value4", "Value", "Float value 4", 0,0,0,0,0,0,0,0,offsetof(laValuesNode, Values[4]),0,0,0,0,0,0,0,0,0,0,0);
  1171. laAddFloatProperty(pc, "value5", "Value", "Float value 5", 0,0,0,0,0,0,0,0,offsetof(laValuesNode, Values[5]),0,0,0,0,0,0,0,0,0,0,0);
  1172. laAddFloatProperty(pc, "value6", "Value", "Float value 6", 0,0,0,0,0,0,0,0,offsetof(laValuesNode, Values[6]),0,0,0,0,0,0,0,0,0,0,0);
  1173. laAddFloatProperty(pc, "value7", "Value", "Float value 7", 0,0,0,0,0,0,0,0,offsetof(laValuesNode, Values[7]),0,0,0,0,0,0,0,0,0,0,0);
  1174. p=laAddEnumProperty(pc,"valuee0","SW","Enum Value 0",LA_WIDGET_ENUM_CYCLE,0,0,0,0,offsetof(laValuesNode, ValuesE[0]),0,0,0,0,0,0,0,0,0,0);la_AddValuesNodeEnumValue(p);
  1175. p=laAddEnumProperty(pc,"valuee1","SW","Enum Value 1",LA_WIDGET_ENUM_CYCLE,0,0,0,0,offsetof(laValuesNode, ValuesE[1]),0,0,0,0,0,0,0,0,0,0);la_AddValuesNodeEnumValue(p);
  1176. p=laAddEnumProperty(pc,"valuee2","SW","Enum Value 2",LA_WIDGET_ENUM_CYCLE,0,0,0,0,offsetof(laValuesNode, ValuesE[2]),0,0,0,0,0,0,0,0,0,0);la_AddValuesNodeEnumValue(p);
  1177. p=laAddEnumProperty(pc,"valuee3","SW","Enum Value 3",LA_WIDGET_ENUM_CYCLE,0,0,0,0,offsetof(laValuesNode, ValuesE[3]),0,0,0,0,0,0,0,0,0,0);la_AddValuesNodeEnumValue(p);
  1178. p=laAddEnumProperty(pc,"valuee4","SW","Enum Value 4",LA_WIDGET_ENUM_CYCLE,0,0,0,0,offsetof(laValuesNode, ValuesE[4]),0,0,0,0,0,0,0,0,0,0);la_AddValuesNodeEnumValue(p);
  1179. p=laAddEnumProperty(pc,"valuee5","SW","Enum Value 5",LA_WIDGET_ENUM_CYCLE,0,0,0,0,offsetof(laValuesNode, ValuesE[5]),0,0,0,0,0,0,0,0,0,0);la_AddValuesNodeEnumValue(p);
  1180. p=laAddEnumProperty(pc,"valuee6","SW","Enum Value 6",LA_WIDGET_ENUM_CYCLE,0,0,0,0,offsetof(laValuesNode, ValuesE[6]),0,0,0,0,0,0,0,0,0,0);la_AddValuesNodeEnumValue(p);
  1181. p=laAddEnumProperty(pc,"valuee7","SW","Enum Value 7",LA_WIDGET_ENUM_CYCLE,0,0,0,0,offsetof(laValuesNode, ValuesE[7]),0,0,0,0,0,0,0,0,0,0);la_AddValuesNodeEnumValue(p);
  1182. pc=laAddPropertyContainer("la_matrix_node", "Matrix", "Matrix node",0,laui_MatrixNode,sizeof(laMatrixNode),lapost_Node,0,1);
  1183. LA_PC_IDN_MATRIX=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1184. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1185. laAddSubGroup(pc,"in_l", "L","Left input","la_in_socket",0,0,0,offsetof(laMatrixNode, InL),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1186. laAddSubGroup(pc,"in_r", "R","Right input","la_in_socket",0,0,0,offsetof(laMatrixNode, InR),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1187. laAddSubGroup(pc,"out", "Out","Output value","la_out_socket",0,0,0,offsetof(laMatrixNode, Out),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1188. p=laAddEnumProperty(pc,"operation", "Operation", "Operation", 0,0,0,0,0,offsetof(laMatrixNode,Operation),0,0,0,0,0,0,0,0,0,0);
  1189. laAddEnumItemAs(p,"MUL", "Multiply", "L x R", LA_MATRIX_NODE_OP_MUL, 0);
  1190. laAddEnumItemAs(p,"INV", "Invert", "Invert L or R", LA_MATRIX_NODE_OP_INV, 0);
  1191. #define REGISTER_MATH_NODE \
  1192. laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine); \
  1193. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);\
  1194. laAddFloatProperty(pc, "vl", "L", "Left value", 0,0,0,0,0,0,0,0,offsetof(laMathNode, ValueL),0,0,0,0,0,0,0,0,0,0,0);\
  1195. laAddFloatProperty(pc, "vr", "R", "Right value", 0,0,0,0,0,0,0,0,offsetof(laMathNode, ValueR),0,0,0,0,0,0,0,0,0,0,0);\
  1196. laAddSubGroup(pc,"in_l", "L","Left input","la_in_socket",0,0,0,offsetof(laMathNode, InL),0,0,0,0,0,0,0,LA_UDF_SINGLE);\
  1197. laAddSubGroup(pc,"in_r", "R","Right input","la_in_socket",0,0,0,offsetof(laMathNode, InR),0,0,0,0,0,0,0,LA_UDF_SINGLE);\
  1198. laAddSubGroup(pc,"out", "Out","Output value","la_out_socket",0,0,0,offsetof(laMathNode, Out),0,0,0,0,0,0,0,LA_UDF_SINGLE);\
  1199. laAddSubGroup(pc,"out_int", "Out Int","Output value in Integer","la_out_socket",0,0,0,offsetof(laMathNode, OutInt),0,0,0,0,0,0,0,LA_UDF_SINGLE);\
  1200. p=laAddEnumProperty(pc,"operation", "Operation", "Operation", 0,0,0,0,0,offsetof(laMathNode, Operation),0,0,0,0,0,0,0,0,0,0);\
  1201. laAddEnumItemAs(p,"ADD", "Add", "L + R", LA_MATH_NODE_OP_ADD, 0);\
  1202. laAddEnumItemAs(p,"SUB", "Subtract", "L - R", LA_MATH_NODE_OP_SUB, 0);\
  1203. laAddEnumItemAs(p,"MUL", "Multiply", "L x R", LA_MATH_NODE_OP_MUL, 0);\
  1204. laAddEnumItemAs(p,"DIV", "Divide", "L / R", LA_MATH_NODE_OP_DIV, 0);\
  1205. laAddEnumItemAs(p,"POW", "Power", "pow(L,R)", LA_MATH_NODE_OP_POW, 0);\
  1206. laAddEnumItemAs(p,"LOG", "Log", "log(L)base(R)", LA_MATH_NODE_OP_LOG, 0);\
  1207. laAddEnumItemAs(p,"SIN", "Sine", "sin(L)", LA_MATH_NODE_OP_SIN, 0);\
  1208. laAddEnumItemAs(p,"COS", "Cosine", "cos(L)", LA_MATH_NODE_OP_COS, 0);\
  1209. laAddEnumItemAs(p,"TAN", "Tangent", "tan(L)", LA_MATH_NODE_OP_TAN, 0);\
  1210. laAddEnumItemAs(p,"ASIN", "Arcsin", "asin(L)", LA_MATH_NODE_OP_ASIN, 0);\
  1211. laAddEnumItemAs(p,"ACOS", "Arccosine", "acos(L)", LA_MATH_NODE_OP_ACOS, 0);\
  1212. laAddEnumItemAs(p,"ATAN", "Arctangent", "atan(L)", LA_MATH_NODE_OP_ATAN, 0);\
  1213. laAddEnumItemAs(p,"ATAN2", "Atan2", "atan2(L,R) where L or R can be zero", LA_MATH_NODE_OP_ATAN2, 0);\
  1214. laAddEnumItemAs(p,"MOD", "Mod", "L \% R", LA_MATH_NODE_OP_MOD, 0);
  1215. pc=laAddPropertyContainer("la_math_node", "Math", "Math node",0,laui_MathNode,sizeof(laMathNode),lapost_Node,0,1); LA_PC_IDN_MATH=pc; REGISTER_MATH_NODE
  1216. pc=laAddPropertyContainer("la_small_math_node", "Small Math", "Small Math node",0,laui_SmallMathNode,sizeof(laMathNode),lapost_Node,0,1); LA_PC_IDN_SMALL_MATH=pc; REGISTER_MATH_NODE
  1217. pc=laAddPropertyContainer("la_mapper_node", "Mapper", "Mapper node",0,laui_MapperNode,sizeof(laMapperNode),lapost_Node,0,1);
  1218. LA_PC_IDN_MAPPER=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1219. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1220. laAddSubGroup(pc,"in", "In","Input value","la_in_socket",0,0,0,offsetof(laMapperNode, In),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1221. laAddSubGroup(pc,"in_min", "In Min","Minimum input value","la_in_socket",0,0,0,offsetof(laMapperNode, InMin),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1222. laAddSubGroup(pc,"in_max", "In Max","Maximum input value","la_in_socket",0,0,0,offsetof(laMapperNode, InMax),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1223. laAddSubGroup(pc,"out_min", "Out Min","Minimum output value","la_in_socket",0,0,0,offsetof(laMapperNode, OutMin),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1224. laAddSubGroup(pc,"out_max", "Out Max","Maximum output value","la_in_socket",0,0,0,offsetof(laMapperNode, OutMax),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1225. laAddSubGroup(pc,"out", "Out","Output value","la_out_socket",0,0,0,offsetof(laMapperNode, Out),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1226. laAddSubGroup(pc,"mapper", "Mapper","Value mapper","la_value_mapper",0,LA_WIDGET_MAPPER,0,offsetof(laMapperNode, Mapper),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1227. p=laAddEnumProperty(pc,"clamp_input", "Clamp Input", "Clamp input", LA_WIDGET_ENUM_HIGHLIGHT,0,0,0,0,offsetof(laMapperNode,ClampInput),0,0,0,0,0,0,0,0,0,0);
  1228. laAddEnumItemAs(p,"NONE", "None", "Don't clamp", 0, 0); laAddEnumItemAs(p,"CLAMP", "Clamp", "Clamp to specified range", 1, 0);
  1229. p=laAddEnumProperty(pc,"clamp_output", "Clamp Output", "Clamp output", LA_WIDGET_ENUM_HIGHLIGHT,0,0,0,0,offsetof(laMapperNode,ClampOutput),0,0,0,0,0,0,0,0,0,0);
  1230. laAddEnumItemAs(p,"NONE", "None", "Don't clamp", 0, 0); laAddEnumItemAs(p,"CLAMP", "Clamp", "Clamp to specified range", 1, 0);
  1231. pc=laAddPropertyContainer("la_random_node", "Random", "Random node",0,laui_RandomNode,sizeof(laRandomNode),lapost_Node,0,1);
  1232. LA_PC_IDN_RANDOM=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1233. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1234. laAddSubGroup(pc,"out", "Out","Output value","la_out_socket",0,0,0,offsetof(laRandomNode, Out),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1235. laAddSubGroup(pc,"min", "Min","Minimum output value","la_in_socket",0,0,0,offsetof(laRandomNode, InMin),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1236. laAddSubGroup(pc,"max", "Max","Maximum output value","la_in_socket",0,0,0,offsetof(laRandomNode, InMax),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1237. laAddFloatProperty(pc, "range", "Range", "Range of the random values", 0,0,0,0,0,0,0,0,offsetof(laRandomNode, Min),0,0,2,0,0,0,0,0,0,0,0);
  1238. pc=laAddPropertyContainer("la_vector_math_node", "Vector Math", "Math node",0,laui_VectorMathNode,sizeof(laVectorMathNode),lapost_Node,0,1);
  1239. LA_PC_IDN_VECTOR_MATH=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1240. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1241. laAddSubGroup(pc,"in_l", "L","Left input","la_in_socket",0,0,0,offsetof(laVectorMathNode, InL),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1242. laAddSubGroup(pc,"in_r", "R","Right input","la_in_socket",0,0,0,offsetof(laVectorMathNode, InR),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1243. laAddSubGroup(pc,"out", "Out","Output value","la_out_socket",0,0,0,offsetof(laVectorMathNode, Out),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1244. p=laAddEnumProperty(pc,"operation", "Operation", "Operation", 0,0,0,0,0,offsetof(laVectorMathNode, Operation),0,0,0,0,0,0,0,0,0,0);
  1245. laAddEnumItemAs(p,"ADD", "Add", "L + R", LA_VECTOR_MATH_OP_ADD, 0);
  1246. laAddEnumItemAs(p,"SUB", "Subtract", "L - R", LA_VECTOR_MATH_OP_SUB, 0);
  1247. laAddEnumItemAs(p,"MUL", "Multiply (component)", "L x R (component)", LA_VECTOR_MATH_OP_MUL, 0);
  1248. laAddEnumItemAs(p,"DIV", "Divide (component)", "L / R (component)", LA_VECTOR_MATH_OP_DIV, 0);
  1249. laAddEnumItemAs(p,"CROSS", "Cross", "L x R", LA_VECTOR_MATH_OP_CROSS, 0);
  1250. laAddEnumItemAs(p,"DOT", "Dot", "L . R", LA_VECTOR_MATH_OP_DOT, 0);
  1251. laAddEnumItemAs(p,"POW", "Power", "pow(L,R)", LA_VECTOR_MATH_OP_POW, 0);
  1252. laAddEnumItemAs(p,"LOG", "Log", "log(L)base(R)", LA_VECTOR_MATH_OP_LOG, 0);
  1253. laAddEnumItemAs(p,"LEN", "Length", "Length(L)", LA_VECTOR_MATH_OP_LEN, 0);
  1254. laAddEnumItemAs(p,"NORM", "Normalize", "Normalize(L)", LA_VECTOR_MATH_OP_NORMALIZE, 0);
  1255. pc=laAddPropertyContainer("la_comment_node", "Comment", "Comment",0,laui_CommentNode,sizeof(laCommentNode),lapost_Node,0,1);
  1256. LA_PC_IDN_COMMENT=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1257. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1258. laAddStringProperty(pc,"content","Content","Content of the comment",LA_WIDGET_STRING_MULTI,0,0,0,1,offsetof(laCommentNode,Content),0,0,0,0,0);
  1259. pc=laAddPropertyContainer("la_rgb_to_okhsl_node", "RGB 2 OKHSL", "RGB color to OKHSL values",0,laui_RGB2OKHSLNode,sizeof(laRGB2OKHSLNode),lapost_Node,0,1);
  1260. LA_PC_IDN_RGB2OKHSL=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1261. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1262. laAddSubGroup(pc,"in", "In","Input color","la_in_socket",0,0,0,offsetof(laRGB2OKHSLNode, In),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1263. laAddSubGroup(pc,"out_h", "H","Hue","la_out_socket",0,0,0,offsetof(laRGB2OKHSLNode, OutH),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1264. laAddSubGroup(pc,"out_s", "S","Chroma","la_out_socket",0,0,0,offsetof(laRGB2OKHSLNode, OutS),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1265. laAddSubGroup(pc,"out_l", "L","Brightness","la_out_socket",0,0,0,offsetof(laRGB2OKHSLNode, OutL),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1266. laAddFloatProperty(pc, "color", "Color", "Default color", LA_WIDGET_FLOAT_COLOR,0,0,0,0,0,0,0,offsetof(laRGB2OKHSLNode, RGB),0,0,3,0,0,0,0,0,0,0,0);
  1267. pc=laAddPropertyContainer("la_okhsl_to_rgb_node", "OKHSL 2 RGB", "OKHSL values to RGB color",0,laui_OKHSL2RGBNode,sizeof(laOKHSL2RGBNode),lapost_Node,0,1);
  1268. LA_PC_IDN_OKHSL2RGB=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1269. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1270. laAddSubGroup(pc,"out", "Out","Output color","la_out_socket",0,0,0,offsetof(laOKHSL2RGBNode, Out),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1271. laAddSubGroup(pc,"in_h", "H","Hue","la_in_socket",0,0,0,offsetof(laOKHSL2RGBNode, InH),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1272. laAddSubGroup(pc,"in_s", "S","Chroma","la_in_socket",0,0,0,offsetof(laOKHSL2RGBNode, InS),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1273. laAddSubGroup(pc,"in_l", "L","Brightness","la_in_socket",0,0,0,offsetof(laOKHSL2RGBNode, InL),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1274. pc=laAddPropertyContainer("la_loop_node", "Loop", "Repeat a series of operations for a few times",0,laui_LoopNode,sizeof(laLoopNode),lapost_Node,0,1);
  1275. LA_PC_IDN_LOOP=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1276. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1277. laAddIntProperty(pc, "iterations", "Iterations", "Loop iterations", 0,0,0,0,0,0,0,0,offsetof(laLoopNode, Iterations),0,0,0,0,0,0,0,0,0,0,0);
  1278. laAddSubGroup(pc,"in_iterations", "In Iterations","Hue","la_in_socket",0,0,0,offsetof(laLoopNode, InIterations),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1279. laAddSubGroup(pc,"branch", "Branch","Control branch","la_in_socket",0,0,0,offsetof(laLoopNode, Branch),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1280. laAddSubGroup(pc,"index", "Index","Index node","la_in_socket",0,0,0,offsetof(laLoopNode, InIndex),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1281. laAddSubGroup(pc,"prev", "Next","Next node in sequence","la_in_socket",0,0,0,offsetof(laLoopNode, Prev),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1282. laAddSubGroup(pc,"next", "Next","Next node in sequence","la_out_socket",0,0,0,offsetof(laLoopNode, Next),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1283. pc=laAddPropertyContainer("la_loop_index_node", "Loop Index", "Index reference of the loop node",0,laui_LoopIndexNode,sizeof(laLoopIndexNode),lapost_Node,0,1);
  1284. LA_PC_IDN_LOOP_INDEX=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
  1285. laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  1286. laAddSubGroup(pc,"index", "Index","Index output","la_out_socket",0,0,0,offsetof(laLoopIndexNode, Out),0,0,0,0,0,0,0,LA_UDF_SINGLE);
  1287. typedef laMathNode laSmallMathNode;
  1288. LA_IDN_REGISTER("Controller",U'🕹',LA_IDN_CONTROLLER,LA_PC_IDN_CONTROLLER, IDN_ControllerInit, IDN_ControllerDestroy, IDN_ControllerVisit, IDN_ControllerEval, laInputControllerNode);
  1289. LA_IDN_REGISTER("Visualizer",U'🔍',LA_IDN_VISUALIZER,LA_PC_IDN_VISUALIZER, IDN_InputVisualizeInit, IDN_InputVisualizeDestroy, IDN_InputVisualizeVisit, IDN_InputVisualizerEval, laInputVisualizerNode);
  1290. LA_IDN_REGISTER("Split",U'⚟',LA_IDN_SPLIT,LA_PC_IDN_SPLIT, IDN_SplitInit, IDN_SplitDestroy, IDN_SplitVisit, IDN_SplitEval, laSplitNode);
  1291. LA_IDN_REGISTER("Switch",U'🚦',LA_IDN_SWITCH,LA_PC_IDN_SWITCH, IDN_SwitchInit, IDN_SwitchDestroy, IDN_SwitchVisit, IDN_SwitchEval, laSwitchNode);
  1292. LA_IDN_REGISTER("Combine",U'⚞',LA_IDN_COMBINE,LA_PC_IDN_COMBINE, IDN_CombineInit, IDN_CombineDestroy, IDN_CombineVisit, IDN_CombineEval, laCombineNode);
  1293. LA_IDN_REGISTER("Values",0,LA_IDN_VALUES,LA_PC_IDN_VALUES, IDN_ValuesInit, IDN_ValuesDestroy, IDN_ValuesVisit, IDN_ValuesEval, laValuesNode);
  1294. LA_IDN_REGISTER("Matrix",0,LA_IDN_MATRIX,LA_PC_IDN_MATRIX, IDN_MatrixInit, IDN_MatrixDestroy, IDN_MatrixVisit, IDN_MatrixEval, laMatrixNode);
  1295. LA_IDN_REGISTER("Math",0,LA_IDN_MATH,LA_PC_IDN_MATH, IDN_MathInit, IDN_MathDestroy, IDN_MathVisit, IDN_MathEval, laMathNode);
  1296. LA_IDN_REGISTER("Small Math",0,LA_IDN_SMALL_MATH,LA_PC_IDN_SMALL_MATH, IDN_MathInit, IDN_MathDestroy, IDN_MathVisit, IDN_MathEval, laSmallMathNode);
  1297. LA_IDN_REGISTER("Mapper",0,LA_IDN_MAPPER,LA_PC_IDN_MAPPER, IDN_MapperInit, IDN_MapperDestroy, IDN_MapperVisit, IDN_MapperEval, laMapperNode);
  1298. LA_IDN_REGISTER("Random",0,LA_IDN_RANDOM,LA_PC_IDN_RANDOM, IDN_RandomInit, IDN_RandomDestroy, IDN_RandomVisit, IDN_RandomEval, laRandomNode);
  1299. LA_IDN_REGISTER("Vector Math",0,LA_IDN_VECTOR_MATH,LA_PC_IDN_VECTOR_MATH, IDN_VectorMathInit, IDN_VectorMathDestroy, IDN_VectorMathVisit, IDN_VectorMathEval, laVectorMathNode);
  1300. LA_IDN_REGISTER("Comment",0,LA_IDN_COMMENT,LA_PC_IDN_COMMENT, IDN_CommentInit, IDN_CommentDestroy, IDN_CommentVisit, IDN_CommentEval, laCommentNode);
  1301. LA_IDN_REGISTER("RGB to OKHSL",0,LA_IDN_RGB2OKHSL,LA_PC_IDN_RGB2OKHSL, IDN_RGB2OKHSLInit, IDN_RGB2OKHSLDestroy, IDN_RGB2OKHSLVisit, IDN_RGB2OKHSLEval, laRGB2OKHSLNode);
  1302. LA_IDN_REGISTER("OKHSL to RGB",0,LA_IDN_OKHSL2RGB,LA_PC_IDN_OKHSL2RGB, IDN_OKHSL2RGBInit, IDN_OKHSL2RGBDestroy, IDN_OKHSL2RGBVisit, IDN_OKHSL2RGBEval, laOKHSL2RGBNode);
  1303. LA_IDN_REGISTER("Loop",0,LA_IDN_LOOP,LA_PC_IDN_LOOP, IDN_LoopInit, IDN_LoopDestroy, IDN_LoopVisit, IDN_LoopEval, laLoopNode);
  1304. LA_IDN_REGISTER("Loop Index",0,LA_IDN_LOOP_INDEX,LA_PC_IDN_LOOP_INDEX, IDN_LoopIndexInit, IDN_LoopIndexDestroy, IDN_LoopIndexVisit, IDN_LoopIndexEval, laLoopIndexNode);
  1305. LA_NODE_CATEGORY_INPUT=laAddNodeCategory("Input",0,LA_RACK_TYPE_INPUT);
  1306. LA_NODE_CATEGORY_MATH=laAddNodeCategory("Math",0,LA_RACK_TYPE_ALL);
  1307. LA_NODE_CATEGORY_COLOR=laAddNodeCategory("Color",0,LA_RACK_TYPE_ALL);
  1308. LA_NODE_CATEGORY_ROUTE=laAddNodeCategory("Route",0,LA_RACK_TYPE_ALL);
  1309. LA_NODE_CATEGORY_AUX=laAddNodeCategory("Auxiliary",0,LA_RACK_TYPE_ALL);
  1310. laNodeCategoryAddNodeTypes(LA_NODE_CATEGORY_INPUT, &LA_IDN_CONTROLLER,0);
  1311. laNodeCategoryAddNodeTypes(LA_NODE_CATEGORY_MATH, &LA_IDN_MATH, &LA_IDN_SMALL_MATH,&LA_IDN_VECTOR_MATH,&LA_IDN_MAPPER,&LA_IDN_RANDOM,&LA_IDN_MATRIX, &LA_IDN_VALUES,0);
  1312. laNodeCategoryAddNodeTypes(LA_NODE_CATEGORY_ROUTE, &LA_IDN_SPLIT, &LA_IDN_SWITCH, &LA_IDN_COMBINE, &LA_IDN_LOOP, &LA_IDN_LOOP_INDEX,0);
  1313. laNodeCategoryAddNodeTypes(LA_NODE_CATEGORY_AUX, &LA_IDN_COMMENT, &LA_IDN_VISUALIZER,0);
  1314. laNodeCategoryAddNodeTypes(LA_NODE_CATEGORY_COLOR, &LA_IDN_RGB2OKHSL, &LA_IDN_OKHSL2RGB,0);
  1315. MAIN.tNodeIn=laCreateInSocket("TIN",0);
  1316. MAIN.tNodeOut=laCreateOutSocket(0,"TOUT",0);
  1317. }
  1318. void laGraphRequestRebuild(){ MAIN.GraphNeedsRebuild=1; }
  1319. void laMappingRequestEval(){ MAIN.InputNeedsEval=1; }
  1320. int __DEBUG_PAGE_EVAL__=1;
  1321. void la_PageClearBranch(laRackPage* rp, int mask){
  1322. for(laListItemPointer*lip=rp->Eval.pFirst;lip;lip=lip->pNext){
  1323. laBaseNode* n=lip->p; if(!n->InitDone){ n->Type->Init(n,1); n->InitDone=1; }
  1324. if(n->Branch&mask){ n->EvalMagic=0; }
  1325. }
  1326. }
  1327. int laRebuildPageEval(laRackPage* rp){
  1328. if(!rp)return LA_DAG_FLAG_PERM;
  1329. while(lstPopPointer(&rp->Eval)); while(lstPopPointer(&rp->AlwaysBranchers));
  1330. laListHandle pending={0};
  1331. for(laNodeRack* ir=rp->Racks.pFirst;ir;ir=ir->Item.pNext){
  1332. for(laBaseNode*bn=ir->Nodes.pFirst;bn;bn=bn->Item.pNext){ if(!bn->InitDone){ bn->Type->Init(bn,1); bn->InitDone=1; }
  1333. lstAppendPointer(&pending,bn); bn->Branch=0; bn->BranchTemp=0;
  1334. }
  1335. }
  1336. laBaseNode*n; int result=LA_DAG_FLAG_PERM; laListItemPointer*NextLip;
  1337. laNodeVisitInfo vi;
  1338. vi.Branch=1; vi.NextBranch=2; vi.l=&rp->Eval; vi.br=&rp->AlwaysBranchers; vi.Page=rp;
  1339. for(laListItemPointer*lip=pending.pFirst;lip;lip=NextLip){ n=lip->p; NextLip=lip->pNext;
  1340. if(n->Branch & 1) continue;
  1341. result=n->Type->Visit(n,&vi); if(result==LA_DAG_FLAG_ERR){ while(lstPopPointer(&pending)); break; }
  1342. }
  1343. if(result==LA_DAG_FLAG_ERR){ while(lstPopPointer(&rp->Eval)); while(lstPopPointer(&rp->AlwaysBranchers)); return LA_DAG_FLAG_ERR; }
  1344. return LA_DAG_FLAG_PERM;
  1345. }
  1346. int laRunPage(laRackPage* rp, uint64_t mask){
  1347. static uint64_t magic=3; if(!magic){ magic=3; }
  1348. if(!rp || (!rp->Eval.pFirst && !rp->AlwaysBranchers.pFirst)) return 0;
  1349. if(__DEBUG_PAGE_EVAL__ && mask==1){ printf("Page eval %s\n",(rp->Name&&rp->Name->Ptr)?rp->Name->Ptr:""); }
  1350. if(mask==1){
  1351. for(laListItemPointer*lip=rp->AlwaysBranchers.pFirst;lip;lip=lip->pNext){
  1352. laBaseNode* n=lip->p; if(!n->InitDone){ n->Type->Init(n,1); n->InitDone=1; }
  1353. if(n->EvalMagic==magic) continue; if(__DEBUG_PAGE_EVAL__){ printf(" BR %.6x\n",n); }
  1354. n->EvalMagic=magic; n->Type->Eval(n);
  1355. }
  1356. }
  1357. for(laListItemPointer*lip=rp->Eval.pFirst;lip;lip=lip->pNext){
  1358. laBaseNode* n=lip->p; if(!n->InitDone){ n->Type->Init(n,1); n->InitDone=1; }
  1359. if((!(n->Branch&mask)) || (mask==1&&n->Branch!=1) || n->EvalMagic==magic) continue;
  1360. if(__DEBUG_PAGE_EVAL__){ printf(" -- %d %s %.6x\n",mask,n->Type->Name,n); }
  1361. n->EvalMagic=magic; n->Type->Eval(n);
  1362. }
  1363. if(__DEBUG_PAGE_EVAL__ && mask==1){ printf("End\n"); }
  1364. if(mask==1){ magic++; }
  1365. return 1;
  1366. }
  1367. int la_RunInputMapping(){
  1368. MAIN.InputNeedsEval = 0;
  1369. return laRunPage(MAIN.InputMapping->CurrentPage, 1);
  1370. }
  1371. int la_RebuildInputMapping(){
  1372. return laRebuildPageEval(MAIN.InputMapping->CurrentPage);
  1373. }
  1374. //==================================================================================================
  1375. laNodeOutSocket* laCreateOutSocket(void* NodeParentOptional, char* label, int DataType){
  1376. laNodeOutSocket* os=memAcquire(sizeof(laNodeOutSocket));
  1377. strSafeSet(&os->Label, label); os->DataType = DataType; os->Parent=NodeParentOptional;
  1378. return os;
  1379. }
  1380. laNodeInSocket* laCreateInSocket(char* label, int DataType){
  1381. laNodeInSocket* is=memAcquire(sizeof(laNodeInSocket));
  1382. strSafeSet(&is->Label, label); is->DataType = DataType;
  1383. return is;
  1384. }
  1385. void laDestroyInSocket(laNodeInSocket* s){ strSafeDestroy(&s->Label); memLeave(s); }
  1386. void laDestroyOutSocket(laNodeOutSocket* s){ strSafeDestroy(&s->Label); memLeave(s); }
  1387. laNodeCategory* laAddNodeCategory(char* Name,laUiDefineFunc* Ui,int ForRackTypes){
  1388. laNodeCategory* nc=memAcquire(sizeof(laNodeCategory));
  1389. lstAppendItem(&MAIN.NodeCategories,nc);
  1390. strSafeSet(&nc->Name, Name); nc->Ui=Ui; nc->For=ForRackTypes;
  1391. return nc;
  1392. }
  1393. void laNodeCategoryAddNodeTypes(laNodeCategory* nc, ...){
  1394. va_list list; va_start(list,nc);
  1395. laBaseNodeType* nt;
  1396. while(nt=va_arg(list,laBaseNodeType*)){
  1397. lstAppendPointer(&nc->NodeTypes, nt);
  1398. }
  1399. va_end(list);
  1400. }