socket_definitions.py 125 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354
  1. import bpy
  2. from bpy.types import NodeSocket, NodeSocketStandard
  3. # Classes which do not have default_value
  4. # needed to detect when there is an error updating dynamic nodes
  5. no_default_value= [
  6. 'MantisSocket',
  7. 'RelationshipSocket',
  8. 'DeformerSocket',
  9. 'xFormSocket',
  10. 'GeometrySocket',
  11. 'GenericRotationSocket',
  12. 'EnumCustomPropTypeSocket',
  13. 'CustomPropSocket',
  14. 'FCurveSocket',
  15. 'DriverSocket',
  16. 'DriverVariableSocket',
  17. 'xFormParameterSocket',
  18. 'MorphTargetSocket',
  19. 'KeyframeSocket',
  20. 'WildcardSocket',
  21. ]
  22. # the sockets that do not have this field do not transfer data.
  23. # instead, it is the link itself which is meaningful.
  24. from bpy.app import version as bpy_version
  25. if bpy_version == (4,5,0): # THere is a bug that requires the socket type to inherit from a Blender class
  26. from bpy.types import NodeSocketGeometry # so we will just inherit from NodeSocketGeometry
  27. class MantisSocket(NodeSocketGeometry, NodeSocket): # even though that is kinda silly
  28. is_valid_interface_type=False
  29. category : bpy.props.StringProperty()
  30. @property # making this a classmethod is apparently not gonna work
  31. def interface_type(self):
  32. return NodeSocketGeometry.bl_idname
  33. else:
  34. class MantisSocket(NodeSocket):
  35. is_valid_interface_type=False
  36. category : bpy.props.StringProperty()
  37. @property
  38. def interface_type(self):
  39. # this is stupid but it is the fastest way to implement this
  40. # TODO: refactor this, it should be a class property
  41. if hasattr(self, "color"):
  42. return map_color_to_socket_type(self.color)
  43. return map_color_to_socket_type(self.color_simple)
  44. from .utilities import (prRed, prGreen, prPurple, prWhite,
  45. prOrange,
  46. wrapRed, wrapGreen, wrapPurple, wrapWhite,
  47. wrapOrange,)
  48. transform_spaces_bone_to = (('WORLD', "World", "World Space"),
  49. ('LOCAL', "Local", "Local Space"),
  50. ('POSE', "Pose", "Pose Space"),
  51. ('CUSTOM', "Custom", "Custom Space"),
  52. ('LOCAL_WITH_PARENT', "Local (With Parent)", "Local Space"),
  53. ('LOCAL_OWNER_ORIENT', "Local (Owner Orientation)", "Local Space"),)
  54. transform_spaces_bone_from = (('WORLD', "World", "World Space"),
  55. ('LOCAL', "Local", "Local Space"),
  56. ('POSE', "Pose", "Pose Space"),
  57. ('CUSTOM', "Custom", "Custom Space"),
  58. ('LOCAL_WITH_PARENT', "Local (With Parent)", "Local Space"),)
  59. transform_spaces_bone_object = (('WORLD', "World", "World Space"),
  60. ('LOCAL', "Local", "Local Space"),
  61. ('POSE', "Pose", "Pose Space"),
  62. ('CUSTOM', "Custom", "Custom Space"),)
  63. transform_spaces_object = (('WORLD', "World", "World Space"),
  64. ('LOCAL', "Local", "Local Space"),
  65. ('CUSTOM', "Custom", "Custom Space"),)
  66. enumRotationOrder =(('AUTO', 'Auto', 'Auto'),
  67. ('XYZ', "XYZ", "XYZ"),
  68. ('XZY', "XZY", "XZY"),
  69. ('ZXY', "ZXY", "ZXY"),
  70. ('ZYX', "ZYX", "ZYX"),
  71. ('YXZ', "YXZ", "YXZ"),
  72. ('YZX', "YZX", "YZX"),
  73. ('QUATERNION', "Quaternion", "Quaternion"),
  74. ('AXIS_ANGLE', "Axis Angle", "Axis Angle"),)
  75. # node socket colors:
  76. cFloat = (0.631373, 0.631373, 0.631373, 1.000000)
  77. cColor = (0.780392, 0.780392, 0.160784, 1.000000)
  78. cVector = (0.388235, 0.388235, 0.780392, 1.000000)
  79. cShader = (0.388235, 0.780392, 0.388235, 1.000000)
  80. cInt = (0.058824, 0.521569, 0.149020, 1.000000)
  81. cString = (0.388235, 0.388235, 0.388235, 1.000000)
  82. # cBool = (0.698039, 0.650980, 0.188235, 1.000000)
  83. cParameter = (0.48, 0.24, 0.24, 1.0)
  84. cDriver = (0.88, 0.11, 0.88, 1.0)
  85. cDriverVariable = (0.66, 0.33, 0.04, 1.0)
  86. cFCurve = (0.77, 0.77, 0.11, 1.0)
  87. cKeyframe = (0.06, 0.22, 0.88, 1.0)
  88. cEnable = (0.92, 0.92, 0.92, 1.0)
  89. cBoneCollection = (0.82, 0.82, 0.82, 1.0)
  90. cDeformer = (0.05, 0.08, 0.45, 1.0)
  91. cShapeKey = (0.95, 0.32, 0.05, 1.0)
  92. # custom colors:
  93. cIK = (0.596078, 0.596078, 0.364706, 1.000000) #because it's yellow in Blender
  94. cRelationship = (0.352941, 0.584314, 0.431373, 1.000000) #constraint color
  95. cMatrix = (0.0, 1.0, 0.75, 1)
  96. cxForm = (0.843137, 0.592157, 0.388235, 1.000000) #could even fetch the theme colors...
  97. cTransformSpace = (1.0, 0.4, 0.216, 1.0)
  98. cBool = (0.1, 0.1, 0.1, 1.0)
  99. cBool3 = (0.35, 0.25, 0.18, 1.0)
  100. cRotationOrder = (0.0, 0.8, 0.0, 1.0)
  101. cQuaternion = (0.85, 0.25, 0.18, 1.0)
  102. #
  103. cGeometry = (0.000000, 0.672443, 0.366253, 1.000000)
  104. # think about making colors that are representative of the data's purpose:
  105. # location
  106. # rotation
  107. # scale
  108. # OR make all of it a reference to the type of data within?
  109. def color_equivalent(color_a, color_b):
  110. # because Blender's floating point numbers are not quite equal. pain.
  111. from .base_definitions import FLOAT_EPSILON
  112. for channel_a, channel_b in zip(color_a, color_b):
  113. if abs(channel_a-channel_b) > FLOAT_EPSILON:
  114. return False
  115. return True
  116. def map_color_to_socket_type(socket_color):
  117. # let's get the socket type by color for e.g. wildcard sockets.
  118. # for some reason I can't use match-case here. dumb.
  119. if color_equivalent(socket_color, cFloat):
  120. return "FloatSocket"
  121. if color_equivalent(socket_color, cColor):
  122. return "ColorSetSocket"
  123. if color_equivalent(socket_color, cVector):
  124. return "VectorSocket"
  125. if color_equivalent(socket_color, cInt):
  126. return "IntSocket"
  127. if color_equivalent(socket_color, cDriver):
  128. return "DriverSocket"
  129. if color_equivalent(socket_color, cDriverVariable):
  130. return "DriverVariableSocket"
  131. if color_equivalent(socket_color, cFCurve):
  132. return "FCurveSocket"
  133. if color_equivalent(socket_color, cKeyframe):
  134. return "KeyframeSocket"
  135. if color_equivalent(socket_color, cEnable):
  136. return "BooleanSocket"
  137. if color_equivalent(socket_color, cDeformer):
  138. return "DeformerSocket"
  139. if color_equivalent(socket_color, cShapeKey):
  140. return "MorphTargetSocket"
  141. if color_equivalent(socket_color, cMatrix):
  142. return "MatrixSocket"
  143. if color_equivalent(socket_color, cxForm):
  144. return "xFormSocket"
  145. if color_equivalent(socket_color, cBool):
  146. return "BooleanSocket"
  147. if color_equivalent(socket_color, cBool3):
  148. return "BooleanThreeTupleSocket"
  149. return "StringSocket"
  150. # Hybrid approach: Make same-data, similar purpose have similar colors.
  151. from typing import List
  152. def TellClasses() -> List[MantisSocket]:
  153. return [ #MantisSocket,
  154. #DefaultSocket,
  155. #InputSocket,
  156. MatrixSocket,
  157. xFormSocket,
  158. RelationshipSocket,
  159. DeformerSocket,
  160. GeometrySocket,
  161. GenericRotationSocket,
  162. EnableSocket,
  163. HideSocket,
  164. # InverseKinematicsSocket,
  165. DriverSocket,
  166. DriverVariableSocket,
  167. FCurveSocket,
  168. # LayerMaskSocket,
  169. # LayerMaskInputSocket,
  170. BoneCollectionSocket,
  171. EnumArrayGetOptions,
  172. EnumCustomPropTypeSocket,
  173. CustomPropSocket,
  174. xFormParameterSocket,
  175. ParameterBoolSocket,
  176. ParameterIntSocket,
  177. ParameterFloatSocket,
  178. ParameterVectorSocket,
  179. ParameterStringSocket,
  180. TransformSpaceSocket,
  181. BooleanSocket,
  182. InvertedBooleanSocket,
  183. BooleanThreeTupleSocket,
  184. RotationOrderSocket,
  185. QuaternionSocket,
  186. QuaternionSocketAA,
  187. UnsignedIntSocket,
  188. IntSocket,
  189. StringSocket,
  190. CollectionDeclarationSocket,
  191. ColorSetDisplaySocket,
  192. ColorSetSocket,
  193. EnumMetaRigSocket,
  194. EnumMetaBoneSocket,
  195. EnumArmature,
  196. EnumExistingBoneSocket,
  197. EnumCurveSocket,
  198. EnumWidgetLibrarySocket,
  199. BoolUpdateParentNode,
  200. # LabelSocket,
  201. IKChainLengthSocket,
  202. EnumInheritScale,
  203. EnumRotationMix,
  204. EnumRotationMixCopyTransforms,
  205. EnumMaintainVolumeStretchTo,
  206. EnumRotationStretchTo,
  207. EnumTrackAxis,
  208. EnumUpAxis,
  209. EnumFollowPathForwardAxis,
  210. EnumFloorAxis,
  211. EnumLockAxis,
  212. EnumLimitMode,
  213. EnumYScaleMode,
  214. EnumXZScaleMode,
  215. EnumTransformationMap,
  216. EnumTransformationRotationMode,
  217. EnumTransformationRotationOrder,
  218. EnumTransformationTranslationMixMode,
  219. EnumTransformationRotationMixMode,
  220. EnumTransformationScaleMixMode,
  221. EnumTransformationAxes,
  222. EnumBBoneHandleType,
  223. # Shrinkwrap
  224. EnumShrinkwrapTypeSocket,
  225. EnumShrinkwrapFaceCullSocket,
  226. EnumShrinkwrapProjectAxisSocket,
  227. EnumShrinkwrapModeSocket,
  228. # Geometry Attribute
  229. EnumGeometryAttributeDataTypeSocket,
  230. EnumGeometryAttributeDomainSocket,
  231. EnumMixModeGeometryAttribute,
  232. # Deformers
  233. EnumSkinning,
  234. MorphTargetSocket,
  235. #
  236. FloatSocket,
  237. FloatPositiveSocket,
  238. FloatFactorSocket,
  239. FloatAngleSocket,
  240. VectorSocket,
  241. VectorEulerSocket,
  242. VectorTranslationSocket,
  243. VectorScaleSocket,
  244. # Drivers
  245. EnumDriverVariableType,
  246. EnumDriverVariableEvaluationSpace,
  247. EnumDriverVariableTransformChannel,
  248. EnumDriverRotationMode,
  249. EnumDriverType,
  250. KeyframeSocket,
  251. EnumKeyframeInterpolationTypeSocket,
  252. EnumKeyframeBezierHandleTypeSocket,
  253. EnumLatticeInterpolationTypeSocket,
  254. EnumCorrectiveSmoothTypeSocket,
  255. eFCrvExtrapolationMode,
  256. # Math
  257. MathFloatOperation,
  258. MathVectorOperation,
  259. MatrixTransformOperation,
  260. #conditions
  261. EnumCompareOperation,
  262. # Schema
  263. WildcardSocket,
  264. # xFormArraySocket,
  265. # RelationshipArraySocket,
  266. # BooleanArraySocket,
  267. # IntArraySocket,
  268. # FloatArraySocket,
  269. # BooleanThreeTupleArraySocket,
  270. # VectorArraySocket,
  271. # QuaternionArraySocket,
  272. # MatrixArraySocket,
  273. # StringArraySocket,
  274. ]
  275. def Tell_bl_idnames(): # reroute nodes
  276. return [cls.bl_idname for cls in TellClasses()]#+["NodeSocketColor"]
  277. def tell_valid_bl_idnames():
  278. valid_classes = filter(lambda cls : cls.is_valid_interface_type, [cls for cls in TellClasses()])
  279. return (cls.bl_idname for cls in valid_classes)
  280. enum_default_xForm_values =(
  281. ('NONE', "None", "None - fail if unconnected (RECOMMENDED)."),
  282. ('ARMATURE', "Generated Armature", "Generate an armature automatically. "
  283. "PLEASE use this only for development and testing. "
  284. "If you use this as a feature in your rigs you will be sorry."),)
  285. # Custom Interface Types give the user the ability to set properties for the interface
  286. # we'll define a base class, and generate the individual classes from the base class
  287. # but we'll leave the option to define a few of them directly.
  288. from bpy.types import NodeTreeInterfaceSocket
  289. def interface_socket_update(self, context):
  290. # we're just gonna do this the dumb way for now and invalidate the tree
  291. # BUG HACK TODO actually I am gonna do this stuff later
  292. # later, I can do this based on the connections in the tree
  293. # and the socket updater can use the same code for group interface modifications
  294. # TODO do this stuff because the tree will be a lot snappier
  295. pass
  296. interface_default_value_description="The default value of the socket when it is not connected."
  297. class MantisInterfaceSocketBaseClass():
  298. is_array : bpy.props.BoolProperty(default =False, update=interface_socket_update,
  299. description="Whether the socket is an array, otherwise it is constant." )
  300. is_connection : bpy.props.BoolProperty(default =False, update=interface_socket_update,
  301. description="If the socket is a connection or not. Ensure this is always paired"
  302. " with an input and an output." )
  303. connected_to : bpy.props.StringProperty(default="", update=interface_socket_update,
  304. description="The name of the socket this one is connected to." )
  305. # we are just gonna use ONE base class (it's easier)
  306. # so generate ALL properties and show only what is needed.
  307. default_string : bpy.props.StringProperty(default="", update=interface_socket_update,
  308. description=interface_default_value_description, )
  309. default_float : bpy.props.FloatProperty(default=0.0, update=interface_socket_update,
  310. description=interface_default_value_description, )
  311. default_vector : bpy.props.FloatVectorProperty( size = 3, default = (0.0, 0.0, 0.0, ),
  312. description=interface_default_value_description, update=interface_socket_update,)
  313. default_int : bpy.props.IntProperty(default=0, update=interface_socket_update,
  314. description=interface_default_value_description, )
  315. default_bool : bpy.props.BoolProperty(default=False, update=interface_socket_update,
  316. description=interface_default_value_description, )
  317. default_bool_vector : bpy.props.BoolVectorProperty(subtype = "XYZ", update=interface_socket_update,
  318. description=interface_default_value_description, )
  319. default_xForm : bpy.props.EnumProperty( default = 'NONE', update = interface_socket_update,
  320. items=enum_default_xForm_values, description=interface_default_value_description,)
  321. def interface_draw(self, context, layout):
  322. if not self.is_connection:
  323. layout.prop(self, "is_array", text="Is Array", toggle=True,)
  324. if not self.is_array and self.id_data.bl_idname == 'SchemaTree':
  325. layout.prop(self, "is_connection", text="Is Connection", toggle=True,)
  326. if False: # DISABLED for now because it will take a big change to Schema to make this work.
  327. if self.is_connection: # only show this if in a Schema AND set to is_connection
  328. layout.prop(self, "connected_to", text="Connected To", toggle=True,)
  329. # Different classes to handle different data types. In the future, these should also
  330. # have settable min/max and such where appropriate
  331. def interface_string_draw(self, context, layout):
  332. layout.prop(self, "default_string", text="Default Value", toggle=True,)
  333. interface_draw(self, context, layout)
  334. def interface_float_draw(self, context, layout):
  335. layout.prop(self, "default_float", text="Default Value", toggle=True,)
  336. interface_draw(self, context, layout)
  337. def interface_vector_draw(self, context, layout):
  338. layout.prop(self, "default_vector", text="Default Value", toggle=True,)
  339. interface_draw(self, context, layout)
  340. def interface_int_draw(self, context, layout):
  341. layout.prop(self, "default_int", text="Default Value", toggle=True,)
  342. interface_draw(self, context, layout)
  343. def interface_bool_draw(self, context, layout):
  344. layout.prop(self, "default_bool", text="Default Value", toggle=True,)
  345. interface_draw(self, context, layout)
  346. def interface_bool_vector_draw(self, context, layout):
  347. layout.prop(self, "default_bool_vector", text="Default Value", toggle=True,)
  348. interface_draw(self, context, layout)
  349. def interface_xform_draw(self, context, layout):
  350. if self.in_out == 'INPUT':
  351. layout.prop(self, "default_xForm", text="Default Value", toggle=True,)
  352. interface_draw(self, context, layout)
  353. def generate_custom_interface_types():
  354. generated_classes = []
  355. # copied from above
  356. valid_classes = filter(lambda cls : cls.is_valid_interface_type, [cls for cls in TellClasses()])
  357. for cls in valid_classes:
  358. name = cls.__name__ + "Interface"
  359. my_interface_draw = interface_draw
  360. # set the right draw function by the value's type
  361. match map_color_to_socket_type(cls.color_simple): #there has to be a better way to do this
  362. case "BooleanSocket":
  363. my_interface_draw = interface_bool_draw
  364. case "IntSocket":
  365. my_interface_draw = interface_int_draw
  366. case "FloatSocket":
  367. my_interface_draw = interface_float_draw
  368. case "BooleanThreeTupleSocket":
  369. my_interface_draw = interface_bool_vector_draw
  370. case "VectorSocket":
  371. my_interface_draw = interface_vector_draw
  372. case "StringSocket":
  373. my_interface_draw = interface_string_draw
  374. case "xFormSocket":
  375. my_interface_draw = interface_xform_draw
  376. interface = type(
  377. name,
  378. (MantisInterfaceSocketBaseClass, NodeTreeInterfaceSocket,),
  379. {
  380. "draw" : my_interface_draw,
  381. "bl_idname" : name,
  382. "bl_socket_idname" : cls.bl_idname,
  383. "socket_type" : cls.bl_idname,
  384. },
  385. )
  386. generated_classes.append(interface)
  387. return generated_classes
  388. # Was setting color like this:
  389. # color : bpy.props.FloatVectorProperty(size = 4, default = cFCurve,)
  390. # but this didn't work when Blender automatically generated interface classes?
  391. # so changed it to color = cVariable
  392. # but for color-changing sockets, if I make them, this won' work? Maybe?
  393. #
  394. # I actually think I was wrong about all of that lol
  395. # TODO change it back, dingus
  396. ########################################################################
  397. # Update Callbacks
  398. ########################################################################
  399. def socket_update(mantis_node, ui_socket, socket_name=None):
  400. node_updated = mantis_node.ui_modify_socket(ui_socket, socket_name)
  401. if not node_updated: # so that we can tag its dependencies
  402. mantis_node.reset_execution_recursive()
  403. return node_updated
  404. def default_update(ui_socket, context, do_execute=True):
  405. context = bpy.context
  406. if not context.space_data:
  407. return
  408. if not hasattr(context.space_data, "path"):
  409. return
  410. try:
  411. node_tree = context.space_data.path[0].node_tree
  412. except IndexError: # not in the UI, for example, in a script instead.
  413. return
  414. if node_tree is None:
  415. return
  416. if node_tree.is_executing or node_tree.is_exporting or not node_tree.do_live_update:
  417. return
  418. # if it is a Schema Node, it will fail the checks below -- but we need it to update the tree.
  419. from .base_definitions import SchemaUINode
  420. if isinstance(ui_socket.node, SchemaUINode):
  421. node_tree.update_tree(context, force = True)
  422. prPurple(f"Executing tree after socket change: {ui_socket.node.name}:{ui_socket.name}")
  423. node_tree.execute_tree(context)
  424. return
  425. if hasattr(ui_socket.node, "initialized"):
  426. if not ui_socket.node.initialized: return
  427. elif hasattr(ui_socket.node, 'is_updating'):
  428. if ui_socket.node.is_updating: return
  429. else: return
  430. # if the socket has survived THAT ordeal, then the context is OK.
  431. # first, we try to update the Mantis tree in-situ.
  432. # Some nodes can update their b-objects, others will have to force-update the tree
  433. # because we just modified the data without modifying the topology of the graph.
  434. # finally, try and execute it if mantis couldn't update the b_objects itself.
  435. from .base_definitions import array_output_types
  436. mantis_updated=True
  437. if (ui_socket.node.bl_idname in ["MantisNodeGroup", "MantisSchemaGroup"]):
  438. mantis_updated=False # this kind of socket can't be updated here (yet)
  439. node_tree.update_tree(context, force=True)
  440. elif ui_socket.node.bl_idname in array_output_types:
  441. mantis_updated=False
  442. node_tree.update_tree(context, force=True)
  443. elif hasattr(ui_socket, 'default_value'):
  444. # we may not have to regenerate the tree; try and update the socket
  445. from .utilities import tree_from_mantis_node
  446. for mantis_node in node_tree.parsed_tree.values():
  447. # check to see if the mantis node is in the same ui-tree as this ui_socket
  448. if mantis_node.ui_signature is None: continue # autogenerated nodes
  449. if mantis_node.ui_signature[-1] == ui_socket.node.name and \
  450. tree_from_mantis_node(mantis_node.ui_signature, node_tree) == ui_socket.node.id_data:
  451. node_updated = True
  452. from .misc_nodes import SimpleInputNode
  453. if isinstance(mantis_node, SimpleInputNode):
  454. node_updated = socket_update(mantis_node, ui_socket)
  455. for l in mantis_node.outputs[ui_socket.name].links:
  456. node_updated = node_updated and socket_update(l.to_node, ui_socket, l.to_socket)
  457. else:
  458. node_updated = socket_update(mantis_node, ui_socket)
  459. # execute the tree if even one node didn't update
  460. mantis_updated = node_updated and mantis_updated
  461. # we want to force it if we have made an unhandled change inside of a schema.
  462. node_tree.update_tree(context, force = (mantis_updated == False))
  463. node_tree.display_update(context)
  464. if mantis_updated==False:
  465. try:
  466. prPurple(f"Executing tree after socket change: {ui_socket.node.name}:{ui_socket.name}")
  467. node_tree.execute_tree(context)
  468. except Exception as e:
  469. prRed("Automatic Tree Execution failed because of %s" % e)
  470. def update_socket(self, context,):
  471. default_update(self,context)
  472. def driver_variable_socket_update(self, context):
  473. default_update(self,context)
  474. def driver_socket_update(self, context):
  475. default_update(self,context)
  476. def update_mute_socket(self, context):
  477. self.node.mute = not self.default_value
  478. default_update(self,context)
  479. def update_hide_socket(self, context):
  480. self.node.mute = self.default_value
  481. default_update(self,context)
  482. def ik_chain_length_update_socket(self, context):
  483. default_update(self,context)
  484. # self.node.update_chain_length(context)
  485. def update_parent_node(self, context):
  486. default_update(self,context)
  487. if hasattr(self.node, "display_update"):
  488. self.node.display_update(context)
  489. def update_metarig_armature(self, context,):
  490. if self.search_prop:
  491. self.node.armature = self.search_prop.name
  492. self.node.inputs[1].armature = self.search_prop
  493. default_update(self,context)
  494. def update_metarig_posebone(self, context,):
  495. self.node.pose_bone = self.default_value
  496. default_update(self,context)
  497. def update_socket_external_load(self, context):
  498. # this is a socket update for sockets that load data from a pack
  499. # e.g. widget, metarig, curve, or component selector sockets
  500. # currently no plans to add any but widgets, but whatever
  501. default_update(self, context)
  502. self.previous_value = self.default_value # this is all I need to do lol
  503. items = get_widget_library_items(self, context) # feels silly to do this here
  504. for item in items:
  505. if item[0] == self.default_value:
  506. self.previous_index = item[-1]
  507. break
  508. ########################################################################
  509. # Sockets
  510. ########################################################################
  511. text_only_output_types = ["NodeGroupInput", "NodeGroupOutput", "SchemaArrayInput",
  512. "SchemaArrayInputGet", "SchemaArrayInputAll", "SchemaConstInput",
  513. "SchemaIncomingConnection"]
  514. def ChooseDraw(self, context, layout, node, text, icon = "NONE", use_enum=True, nice_bool=True, icon_only=False):
  515. invert_checkbox = False
  516. if hasattr(self, "invert") and self.invert == True:
  517. invert_checkbox=True
  518. # TEXT ONLY
  519. if self.node.bl_idname in text_only_output_types:
  520. layout.label(text=text)
  521. elif hasattr(self, "display_text") and self.display_text and self.is_linked:
  522. layout.label(text=self.display_text)
  523. else:
  524. # ENUM VALUES (this is a HACK, fix it later)
  525. if ('Enum' in self.bl_idname) and (use_enum):
  526. if not (self.is_output or self.is_linked):
  527. layout.prop_tabs_enum(self, "default_value",)
  528. else:
  529. layout.label(text=text)
  530. # for OUTPUT sockets that take INPUT (confusing name!)
  531. elif ((hasattr(self, "default_value")) and hasattr(self, "input") and getattr(self, "input")):
  532. # for simple input nodes
  533. layout.prop(self, "default_value", text=text, toggle=nice_bool, slider=True)
  534. # for INPUTS that are NOT CONNECTED
  535. elif (hasattr(self, "default_value")) and not (self.is_output or self.is_linked):
  536. # DO: expose these values as parameters for this function
  537. # and set them for each socket.
  538. if icon == 'NONE': icon_only = False
  539. elif icon_only == True : text = "" # "real" icon-only looks bad for strings, need to check other props types.
  540. layout.prop(self, "default_value", text=text, toggle=nice_bool, slider=True, icon=icon,
  541. invert_checkbox=invert_checkbox)
  542. # CONNECTED sockets and outputs without input fields
  543. else:
  544. layout.label(text=text)
  545. def CollectionSocketDraw(socket, context, layout, node, text):
  546. # create the UI objects
  547. indent_length = len(socket.collection_path.split('>'))
  548. layout.alignment = 'EXPAND'
  549. # label_col = layout.row()
  550. label_col = layout.split(factor=0.20)
  551. label_col.alignment = 'LEFT' # seems backwards?
  552. label_col.scale_x = 9.0
  553. x_split = label_col.split(factor=0.35)
  554. x_split.scale_x=2.0
  555. x_split.alignment = 'RIGHT'
  556. operator_col = layout.row()
  557. # operator_col = layout
  558. operator_col.alignment = 'RIGHT' # seems backwards?
  559. operator_col.scale_x = 1.0
  560. # x_split = operator_col.split(factor=0.5)
  561. # x_split.scale_x = 0.5
  562. # x_split.alignment = 'RIGHT'
  563. # Now fill in the text and operators and such
  564. label_text = socket.collection_path.split('>')[-1]
  565. if indent_length > 1:
  566. label_text = '└'+label_text #┈ use this character to extend
  567. for indent in range(indent_length):
  568. if indent <= 1: continue
  569. indent_text = ' ▹ '
  570. label_text=indent_text+label_text
  571. op_props = x_split.operator('mantis.collection_remove')
  572. op_props.socket_invoked = socket.identifier
  573. label_col.label(text=label_text)
  574. op_props = operator_col.operator('mantis.collection_add_new')
  575. op_props.socket_invoked = socket.identifier
  576. # this works well enough!
  577. class RelationshipSocket(MantisSocket):
  578. # Description string
  579. '''Relationship'''
  580. # Optional identifier string. If not explicitly defined, the python class name is used.
  581. bl_idname = 'RelationshipSocket'
  582. bl_label = "Relationship"
  583. color_simple = cRelationship
  584. color : bpy.props.FloatVectorProperty(default=cRelationship, size=4)
  585. input : bpy.props.BoolProperty(default =False,)
  586. is_valid_interface_type=True
  587. def draw(self, context, layout, node, text):
  588. ChooseDraw(self, context, layout, node, text)
  589. def draw_color(self, context, node):
  590. return self.color
  591. @classmethod
  592. def draw_color_simple(self):
  593. return self.color_simple
  594. class DeformerSocket(MantisSocket):
  595. # Description string
  596. '''Deformer'''
  597. # Optional identifier string. If not explicitly defined, the python class name is used.
  598. bl_idname = 'DeformerSocket'
  599. bl_label = "Deformer"
  600. is_valid_interface_type=True
  601. color_simple = cDeformer
  602. color : bpy.props.FloatVectorProperty(default=cDeformer, size=4)
  603. input : bpy.props.BoolProperty(default =False,)
  604. def draw(self, context, layout, node, text):
  605. ChooseDraw(self, context, layout, node, text)
  606. def draw_color(self, context, node):
  607. return self.color
  608. @classmethod
  609. def draw_color_simple(self):
  610. return self.color_simple
  611. class MatrixSocket(MantisSocket):
  612. '''Matrix Input Output'''
  613. bl_idname = 'MatrixSocket'
  614. bl_label = "Matrix"
  615. default_value : bpy.props.FloatVectorProperty(
  616. default = (1.0, 0.0, 0.0, 0.0,
  617. 0.0, 1.0, 0.0, 0.0,
  618. 0.0, 0.0, 1.0, 0.0,
  619. 0.0, 0.0, 0.0, 1.0),
  620. size=16,
  621. update = update_socket,)
  622. color_simple = cMatrix
  623. color : bpy.props.FloatVectorProperty(default=cMatrix, size=4)
  624. input : bpy.props.BoolProperty(default =False,)
  625. is_valid_interface_type=True
  626. # Optional function for drawing the socket input value
  627. def draw(self, context, layout, node, text):
  628. layout.label(text=text)
  629. def draw_color(self, context, node):
  630. return self.color
  631. @classmethod
  632. def draw_color_simple(self):
  633. return self.color_simple
  634. # Utility functions to make handling the 16 numbers more bearable
  635. def SetValue(self, mat):
  636. self.default_value = ( mat[0][0], mat[0][1], mat[0][2], mat[0][3],
  637. mat[1][0], mat[1][1], mat[1][2], mat[1][3],
  638. mat[2][0], mat[2][1], mat[2][2], mat[2][3],
  639. mat[3][0], mat[3][1], mat[3][2], mat[3][3], )
  640. def TellValue(self):
  641. from mathutils import Matrix
  642. v = self.default_value
  643. return Matrix( ( ( v[ 0], v[ 1], v[ 2], v[ 3],),
  644. ( v[ 4], v[ 5], v[ 6], v[ 7],),
  645. ( v[ 8], v[ 9], v[10], v[11],),
  646. ( v[12], v[13], v[14], v[15]), ) )
  647. #NOTE, we're not using the last row
  648. # so we're gonna use it to store data
  649. # unused, unused, unused, bone_length
  650. # but we're not going to make it
  651. # available except by accessor functions
  652. # would like to make this stuff easier to deal with tho
  653. def TellBoneLength(self):
  654. return self.default_value[15]
  655. class xFormSocket(MantisSocket):
  656. '''xFrom Input Output'''
  657. bl_idname = 'xFormSocket'
  658. bl_label = "xForm"
  659. color_simple = cxForm
  660. color : bpy.props.FloatVectorProperty(default=cxForm, size=4)
  661. input : bpy.props.BoolProperty(default =False,)
  662. is_valid_interface_type=True
  663. def draw(self, context, layout, node, text):
  664. ChooseDraw(self, context, layout, node, text)
  665. def draw_color(self, context, node):
  666. return self.color
  667. @classmethod
  668. def draw_color_simple(self):
  669. return self.color_simple
  670. class GeometrySocket(MantisSocket):
  671. '''Geometry Input Output'''
  672. bl_idname = 'GeometrySocket'
  673. bl_label = "Geometry"
  674. color_simple = cGeometry
  675. color : bpy.props.FloatVectorProperty(default=cGeometry, size=4)
  676. input : bpy.props.BoolProperty(default =False,)
  677. is_valid_interface_type=True
  678. def draw(self, context, layout, node, text):
  679. ChooseDraw(self, context, layout, node, text)
  680. def draw_color(self, context, node):
  681. return self.color
  682. @classmethod
  683. def draw_color_simple(self):
  684. return self.color_simple
  685. class GenericRotationSocket(MantisSocket):
  686. '''Custom node socket type'''
  687. bl_idname = 'GenericRotationSocket'
  688. bl_label = "Rotation"
  689. color = (0.0,0.0,0.0,0.0)
  690. input : bpy.props.BoolProperty(default =False,)
  691. def draw(self, context, layout, node, text):
  692. ChooseDraw(self, context, layout, node, text)
  693. def draw_color(self, context, node):
  694. return self.color
  695. @classmethod
  696. def draw_color_simple(self):
  697. return self.color_simple
  698. ###############################
  699. class EnableSocket(MantisSocket):
  700. '''Custom node socket type'''
  701. bl_idname = 'EnableSocket'
  702. bl_label = "Enable"
  703. default_value: bpy.props.BoolProperty(default=True, update = update_mute_socket,)
  704. color_simple = cEnable
  705. color : bpy.props.FloatVectorProperty(default=cEnable, size=4)
  706. input : bpy.props.BoolProperty(default =False,)
  707. def draw(self, context, layout, node, text):
  708. ChooseDraw(self, context, layout, node, text, nice_bool=False)
  709. def draw_color(self, context, node):
  710. return self.color
  711. @classmethod
  712. def draw_color_simple(self):
  713. return self.color_simple
  714. class HideSocket(MantisSocket):
  715. '''Custom node socket type'''
  716. bl_idname = 'HideSocket'
  717. bl_label = "Hide"
  718. default_value: bpy.props.BoolProperty(default=False, update = update_hide_socket,)
  719. color_simple = cEnable
  720. color : bpy.props.FloatVectorProperty(default=cEnable, size=4)
  721. input : bpy.props.BoolProperty(default =False,)
  722. def draw(self, context, layout, node, text):
  723. ChooseDraw(self, context, layout, node, text, nice_bool=False)
  724. def draw_color(self, context, node):
  725. return self.color
  726. @classmethod
  727. def draw_color_simple(self):
  728. return self.color_simple
  729. class FCurveSocket(MantisSocket):
  730. '''fCurve'''
  731. bl_idname = 'FCurveSocket'
  732. bl_label = "fCurve"
  733. color_simple = cFCurve
  734. color : bpy.props.FloatVectorProperty(default=cFCurve, size=4)
  735. input : bpy.props.BoolProperty(default =False, update = update_socket)
  736. is_valid_interface_type=True
  737. def init(self):
  738. self.display_shape = 'CIRCLE_DOT'
  739. def draw(self, context, layout, node, text):
  740. ChooseDraw(self, context, layout, node, text)
  741. def draw_color(self, context, node):
  742. return self.color
  743. @classmethod
  744. def draw_color_simple(self):
  745. return self.color_simple
  746. class DriverSocket(MantisSocket):
  747. '''Driver'''
  748. bl_idname = 'DriverSocket'
  749. bl_label = "Driver"
  750. color_simple = cDriver
  751. color : bpy.props.FloatVectorProperty(default=cDriver, size=4)
  752. input : bpy.props.BoolProperty(default =False, update = update_socket)
  753. is_valid_interface_type=True
  754. def init(self):
  755. self.display_shape = 'CIRCLE_DOT'
  756. def draw(self, context, layout, node, text):
  757. ChooseDraw(self, context, layout, node, text)
  758. def draw_color(self, context, node):
  759. return self.color
  760. @classmethod
  761. def draw_color_simple(self):
  762. return self.color_simple
  763. class DriverVariableSocket(MantisSocket):
  764. '''Driver'''
  765. bl_idname = 'DriverVariableSocket'
  766. bl_label = "Driver Variable"
  767. color_simple = cDriverVariable
  768. color : bpy.props.FloatVectorProperty(default=cDriverVariable, size=4)
  769. input : bpy.props.BoolProperty(default =False, update = update_socket)
  770. is_valid_interface_type=True
  771. def init(self):
  772. self.display_shape = 'CIRCLE_DOT'
  773. def draw(self, context, layout, node, text):
  774. ChooseDraw(self, context, layout, node, text)
  775. def draw_color(self, context, node):
  776. return self.color
  777. @classmethod
  778. def draw_color_simple(self):
  779. return self.color_simple
  780. # transform_spaces
  781. # transform_spaces_bone_object
  782. # transform_spaces_object
  783. # def get_transform_space_enum(self, context):
  784. # pass
  785. def get_transform_space(self, context):
  786. if "Owner" in self.name:
  787. return transform_spaces_bone_from
  788. else:
  789. return transform_spaces_bone_to
  790. class TransformSpaceSocket(MantisSocket):
  791. '''Custom node socket type'''
  792. bl_idname = 'TransformSpaceSocket'
  793. bl_label = "Transform Space"
  794. default_value: bpy.props.EnumProperty(
  795. name="Space Transform",
  796. description="Space Transform",
  797. items=get_transform_space,
  798. default=0,
  799. update = update_socket,)
  800. color_simple = cTransformSpace
  801. color : bpy.props.FloatVectorProperty(default=cTransformSpace, size=4)
  802. input : bpy.props.BoolProperty(default =False,)
  803. def draw(self, context, layout, node, text):
  804. ChooseDraw(self, context, layout, node, text)
  805. def draw_color(self, context, node):
  806. return self.color
  807. @classmethod
  808. def draw_color_simple(self):
  809. return self.color_simple
  810. class BooleanSocket(MantisSocket):
  811. '''Custom node socket type'''
  812. bl_idname = 'BooleanSocket'
  813. bl_label = "Boolean"
  814. default_value: bpy.props.BoolProperty(update = update_socket,)
  815. color_simple = cBool
  816. color : bpy.props.FloatVectorProperty(default=cBool, size=4)
  817. input : bpy.props.BoolProperty(default =False,)
  818. is_valid_interface_type=True
  819. def draw(self, context, layout, node, text):
  820. ChooseDraw(self, context, layout, node, text)
  821. def draw_color(self, context, node):
  822. return self.color
  823. @classmethod
  824. def draw_color_simple(self):
  825. return self.color_simple
  826. class InvertedBooleanSocket(MantisSocket):
  827. '''Custom node socket type'''
  828. bl_idname = 'InvertedBooleanSocket'
  829. bl_label = "Inverted Boolean"
  830. default_value: bpy.props.BoolProperty(update = update_socket,)
  831. color_simple = cBool
  832. color : bpy.props.FloatVectorProperty(default=cBool, size=4)
  833. input : bpy.props.BoolProperty(default =False,)
  834. invert : bpy.props.BoolProperty(default=True,)
  835. is_valid_interface_type=False
  836. def draw(self, context, layout, node, text):
  837. ChooseDraw(self, context, layout, node, text)
  838. def draw_color(self, context, node):
  839. return self.color
  840. @classmethod
  841. def draw_color_simple(self):
  842. return self.color_simple
  843. class BooleanThreeTupleSocket(MantisSocket):
  844. # Description string
  845. '''Custom node socket type'''
  846. # Optional identifier string. If not explicitly defined, the python class name is used.
  847. bl_idname = 'BooleanThreeTupleSocket'
  848. bl_label = "Boolean Vector"
  849. default_value: bpy.props.BoolVectorProperty(subtype = "XYZ",update = update_socket,)
  850. color_simple = cBool3
  851. color : bpy.props.FloatVectorProperty(default=cBool3, size=4)
  852. input : bpy.props.BoolProperty(default =False,)
  853. is_valid_interface_type=True
  854. def draw(self, context, layout, node, text):
  855. ChooseDraw(self, context, layout, node, text)
  856. def draw_color(self, context, node):
  857. return self.color
  858. @classmethod
  859. def draw_color_simple(self):
  860. return self.color_simple
  861. def TellValue(self):
  862. return (self.default_value[0], self.default_value[1], self.default_value[2])
  863. class RotationOrderSocket(MantisSocket):
  864. '''Custom node socket type'''
  865. bl_idname = 'RotationOrderSocket'
  866. bl_label = "Rotation Order"
  867. default_value: bpy.props.EnumProperty(
  868. name="Rotation Order",
  869. description="Rotation Order",
  870. items=enumRotationOrder,
  871. default='AUTO',
  872. update = update_socket,)
  873. color_simple = cRotationOrder
  874. color : bpy.props.FloatVectorProperty(default=cRotationOrder, size=4)
  875. input : bpy.props.BoolProperty(default =False,)
  876. def draw(self, context, layout, node, text):
  877. ChooseDraw(self, context, layout, node, text)
  878. def draw_color(self, context, node):
  879. return self.color
  880. @classmethod
  881. def draw_color_simple(self):
  882. return self.color_simple
  883. class QuaternionSocket(MantisSocket):
  884. '''Custom node socket type'''
  885. bl_idname = 'QuaternionSocket'
  886. bl_label = "Quaternion"
  887. default_value: bpy.props.FloatVectorProperty(
  888. subtype = "QUATERNION",
  889. size = 4,
  890. default = (1.0, 0.0, 0.0, 0.0,),
  891. update = update_socket,)
  892. color_simple = cQuaternion
  893. color : bpy.props.FloatVectorProperty(default=cQuaternion, size=4)
  894. input : bpy.props.BoolProperty(default =False,)
  895. def draw(self, context, layout, node, text):
  896. ChooseDraw(self, context, layout, node, text)
  897. def draw_color(self, context, node):
  898. return self.color
  899. @classmethod
  900. def draw_color_simple(self):
  901. return self.color_simple
  902. class QuaternionSocketAA(MantisSocket):
  903. '''Custom node socket type'''
  904. bl_idname = 'QuaternionSocketAA'
  905. bl_label = "Axis Angle Quaternion"
  906. color_simple = cQuaternion
  907. color : bpy.props.FloatVectorProperty(default=cQuaternion, size=4)
  908. input : bpy.props.BoolProperty(default =False,)
  909. default_value: bpy.props.FloatVectorProperty(
  910. subtype = "AXISANGLE",
  911. size = 4,
  912. default = (1.0, 0.0, 0.0, 0.0,),
  913. update = update_socket,)
  914. def draw(self, context, layout, node, text):
  915. ChooseDraw(self, context, layout, node, text)
  916. def draw_color(self, context, node):
  917. return self.color
  918. @classmethod
  919. def draw_color_simple(self):
  920. return self.color_simple
  921. class IntSocket(MantisSocket):
  922. '''Custom node socket type'''
  923. bl_idname = 'IntSocket'
  924. bl_label = "Integer"
  925. default_value: bpy.props.IntProperty(default=0, update = update_socket, soft_min=-256, soft_max=256)
  926. color_simple = cInt
  927. color : bpy.props.FloatVectorProperty(default=cInt, size=4)
  928. input : bpy.props.BoolProperty(default =False,)
  929. is_valid_interface_type=True
  930. def draw(self, context, layout, node, text):
  931. ChooseDraw(self, context, layout, node, text)
  932. def draw_color(self, context, node):
  933. return self.color
  934. @classmethod
  935. def draw_color_simple(self):
  936. return self.color_simple
  937. class UnsignedIntSocket(MantisSocket):
  938. '''Unsigned Integer Socket'''
  939. bl_idname = 'UnsignedIntSocket'
  940. bl_label = "Unsigned Integer"
  941. default_value: bpy.props.IntProperty(default=0, update = update_socket, min=0, soft_max=256, max=2**13)
  942. color_simple = cInt
  943. color : bpy.props.FloatVectorProperty(default=cInt, size=4)
  944. input : bpy.props.BoolProperty(default =False,)
  945. is_valid_interface_type=True
  946. def draw(self, context, layout, node, text):
  947. ChooseDraw(self, context, layout, node, text)
  948. def draw_color(self, context, node):
  949. return self.color
  950. @classmethod
  951. def draw_color_simple(self):
  952. return self.color_simple
  953. class StringSocket(MantisSocket):
  954. """Float Input socket"""
  955. bl_idname = 'StringSocket'
  956. bl_label = "String"
  957. default_value : bpy.props.StringProperty(default = "", update = update_socket,)
  958. color_simple = cString
  959. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  960. icon : bpy.props.StringProperty(default = "NONE",)
  961. input : bpy.props.BoolProperty(default =False,)
  962. display_text : bpy.props.StringProperty(default="")
  963. is_valid_interface_type=True
  964. # def init(self):
  965. # if self.node.bl_idname == 'UtilityBoneProperties':
  966. # self.display_shape='CIRCLE_DOT'
  967. def draw(self, context, layout, node, text):
  968. ChooseDraw(self, context, layout, node, text, icon=self.icon, icon_only=True,)
  969. def draw_color(self, context, node):
  970. return self.color
  971. @classmethod
  972. def draw_color_simple(self):
  973. return self.color_simple
  974. def collection_declaration_get_default_value(self):
  975. return self.collection_path
  976. class CollectionDeclarationSocket(MantisSocket):
  977. """Socket for declaring a collection"""
  978. bl_idname = 'CollectionDeclarationSocket'
  979. bl_label = "Collection"
  980. default_value : bpy.props.StringProperty(get=collection_declaration_get_default_value)
  981. collection_path : bpy.props.StringProperty(default="")
  982. color_simple = cBoneCollection
  983. color : bpy.props.FloatVectorProperty(default=cBoneCollection, size=4)
  984. icon : bpy.props.StringProperty(default = "NONE",)
  985. input : bpy.props.BoolProperty(default =True,)
  986. display_text : bpy.props.StringProperty(default="")
  987. is_valid_interface_type=False
  988. def draw(self, context, layout, node, text):
  989. CollectionSocketDraw(self, context, layout, node, text)
  990. def draw_color(self, context, node):
  991. return self.color
  992. @classmethod
  993. def draw_color_simple(self):
  994. return self.color_simple
  995. class BoneCollectionSocket(MantisSocket):
  996. """Collection socket"""
  997. bl_idname = 'BoneCollectionSocket'
  998. bl_label = "Collection"
  999. default_value: bpy.props.StringProperty(default = "Collection", update = update_socket,)
  1000. input : bpy.props.BoolProperty(default =False,)
  1001. color_simple = cBoneCollection
  1002. color : bpy.props.FloatVectorProperty(default=cBoneCollection, size=4)
  1003. is_valid_interface_type=True
  1004. def draw(self, context, layout, node, text):
  1005. ChooseDraw(self, context, layout, node, text)
  1006. def draw_color(self, context, node):
  1007. return self.color
  1008. @classmethod
  1009. def draw_color_simple(self):
  1010. return self.color_simple
  1011. def get_bone_theme_color(socket, prop,):
  1012. from bpy import context
  1013. color_index=socket.color_index
  1014. color_set = context.preferences.themes[0].bone_color_sets[color_index]
  1015. return getattr(color_set, prop )
  1016. def get_active_color(socket):
  1017. if socket is None:
  1018. from bpy import context
  1019. return context.preferences.themes[0].view_3d.bone_pose_active
  1020. return get_bone_theme_color(socket, 'active')
  1021. def get_normal_color(socket):
  1022. if socket is None:
  1023. from bpy import context
  1024. return context.preferences.themes[0].view_3d.bone_solid
  1025. return get_bone_theme_color(socket, 'normal')
  1026. def get_select_color(socket):
  1027. if socket is None:
  1028. from bpy import context
  1029. return context.preferences.themes[0].view_3d.bone_pose
  1030. return get_bone_theme_color(socket, 'select')
  1031. def get_color_set_value(socket,):
  1032. return [ socket.active_color[0],
  1033. socket.active_color[1],
  1034. socket.active_color[2],
  1035. socket.normal_color[0],
  1036. socket.normal_color[1],
  1037. socket.normal_color[2],
  1038. socket.selected_color[0],
  1039. socket.selected_color[1],
  1040. socket.selected_color[2],]
  1041. class ColorSetDisplaySocket(MantisSocket):
  1042. """Socket for displaying a bone color theme"""
  1043. bl_idname = 'ColorSetDisplaySocket'
  1044. bl_label = "Color Set"
  1045. default_value : bpy.props.FloatVectorProperty(get=get_color_set_value, size=9)
  1046. color_simple = cColor
  1047. color : bpy.props.FloatVectorProperty(default=cColor, size=4)
  1048. icon : bpy.props.StringProperty(default = "NONE",)
  1049. input : bpy.props.BoolProperty(default =False,)
  1050. display_text : bpy.props.StringProperty(default="")
  1051. color_index : bpy.props.IntProperty(default=0)
  1052. active_color : bpy.props.FloatVectorProperty(
  1053. name='Active Color', size=3, subtype='COLOR_GAMMA',
  1054. get=get_active_color )
  1055. normal_color : bpy.props.FloatVectorProperty(
  1056. name='Normal Color', size=3, subtype='COLOR_GAMMA',
  1057. get=get_normal_color )
  1058. selected_color : bpy.props.FloatVectorProperty(
  1059. name='Selected Color', size=3, subtype='COLOR_GAMMA',
  1060. get=get_select_color )
  1061. is_valid_interface_type=False
  1062. def draw(self, context, layout, node, text):
  1063. layout.prop( text='', data=self,
  1064. property='active_color', )
  1065. layout.prop( text='', data=self,
  1066. property='normal_color',)
  1067. layout.prop( text='', data=self,
  1068. property='selected_color',)
  1069. def draw_color(self, context, node):
  1070. return self.color
  1071. @classmethod
  1072. def draw_color_simple(self):
  1073. return self.color_simple
  1074. class ColorSetSocket(MantisSocket):
  1075. """Socket for setting a bone color"""
  1076. bl_idname = 'ColorSetSocket'
  1077. bl_label = "Custom Color Set"
  1078. default_value : bpy.props.FloatVectorProperty(get=get_color_set_value, size=9)
  1079. color_simple = cColor
  1080. color : bpy.props.FloatVectorProperty(default=cColor, size=4)
  1081. icon : bpy.props.StringProperty(default = "NONE",)
  1082. input : bpy.props.BoolProperty(default = True,)
  1083. display_text : bpy.props.StringProperty(default="")
  1084. active_color : bpy.props.FloatVectorProperty(
  1085. name='Active Color', size=3, subtype='COLOR_GAMMA',
  1086. default=get_active_color(None),)
  1087. normal_color : bpy.props.FloatVectorProperty(
  1088. name='Normal Color', size=3, subtype='COLOR_GAMMA',
  1089. default=get_normal_color(None),)
  1090. selected_color : bpy.props.FloatVectorProperty(
  1091. name='Selected Color', size=3, subtype='COLOR_GAMMA',
  1092. default=get_select_color(None),)
  1093. is_valid_interface_type=True
  1094. def draw(self, context, layout, node, text):
  1095. inherit_color_socket = self.node.inputs.get("Inherit Color")
  1096. if (self.is_output == False) and (self.is_linked == True):
  1097. layout.label(text=self.name)
  1098. elif self.node.bl_idname in text_only_output_types:
  1099. layout.label(text=self.name)
  1100. elif inherit_color_socket and inherit_color_socket.default_value == True:
  1101. layout.label(text='Using Inherit Color.')
  1102. else:
  1103. layout.prop( text='Color Set', data=self,
  1104. property='active_color', )
  1105. layout.prop( text='', data=self,
  1106. property='normal_color',)
  1107. layout.prop( text='', data=self,
  1108. property='selected_color',)
  1109. if self.node.bl_idname == 'InputColorSetPallete':
  1110. ops_props = layout.operator('mantis.color_pallete_socket_remove')
  1111. ops_props.tree_invoked = self.node.id_data.name
  1112. ops_props.node_invoked = self.node.name
  1113. ops_props.socket_invoked = self.identifier
  1114. def draw_color(self, context, node):
  1115. return self.color
  1116. @classmethod
  1117. def draw_color_simple(self):
  1118. return self.color_simple
  1119. eArrayGetOptions =(
  1120. ('CAP', "Cap", "Fail if the index is out of bounds."),
  1121. ('WRAP', "Wrap", "Wrap around to the beginning of the array once the idex goes out of bounds."),
  1122. ('HOLD', "Hold", "Reuse the last element of the array if the index is out of bounds."),)
  1123. class EnumArrayGetOptions(MantisSocket):
  1124. '''Custom node socket type'''
  1125. bl_idname = 'EnumArrayGetOptions'
  1126. bl_label = "OoB Behaviour"
  1127. default_value: bpy.props.EnumProperty(
  1128. items=eArrayGetOptions,
  1129. name="OoB Behaviour",
  1130. description="Out-of-bounds behaviour.",
  1131. default = 'HOLD',
  1132. update = update_socket,)
  1133. color_simple = cString
  1134. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1135. input : bpy.props.BoolProperty(default =False,)
  1136. def draw(self, context, layout, node, text):
  1137. ChooseDraw(self, context, layout, node, text)
  1138. def draw_color(self, context, node):
  1139. return self.color
  1140. @classmethod
  1141. def draw_color_simple(self):
  1142. return self.color_simple
  1143. #####################################################################################
  1144. # Parameters
  1145. #####################################################################################
  1146. eCustomPropType = (
  1147. ('BOOL' , "Boolean", "Boolean", 0),
  1148. ('INT' , "Int" , "Integer", 1),
  1149. ('FLOAT' , "Float" , "Floating Point Number", 2),
  1150. ('VECTOR' , "Vector" , "Vector", 3),
  1151. ('STRING' , "String" , "String", 4),
  1152. )
  1153. class EnumCustomPropTypeSocket(MantisSocket):
  1154. """Custom Property Type"""
  1155. bl_idname = 'EnumCustomPropTypeSocket'
  1156. bl_label = "Property Type"
  1157. color_simple = cString
  1158. default_value: bpy.props.EnumProperty(
  1159. items=eCustomPropType,
  1160. description="Custom Property Type",
  1161. default = 'BOOL',
  1162. update = update_socket,)
  1163. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1164. input : bpy.props.BoolProperty(default =False,)
  1165. def draw(self, context, layout, node, text):
  1166. ChooseDraw(self, context, layout, node, text)
  1167. def draw_color(self, context, node):
  1168. return self.color
  1169. @classmethod
  1170. def draw_color_simple(self):
  1171. return self.color_simple
  1172. # what is this one again?
  1173. class CustomPropSocket(MantisSocket):
  1174. '''Custom Property'''
  1175. bl_idname = 'CustomPropSocket'
  1176. bl_label = "Custom Property"
  1177. color_simple = cString
  1178. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1179. input : bpy.props.BoolProperty(default =False,)
  1180. def init(self):
  1181. self.display_shape = 'CIRCLE_DOT'
  1182. def draw(self, context, layout, node, text):
  1183. ChooseDraw(self, context, layout, node, text)
  1184. def draw_color(self, context, node):
  1185. return self.color
  1186. @classmethod
  1187. def draw_color_simple(self):
  1188. return self.color_simple
  1189. class xFormParameterSocket(MantisSocket):
  1190. '''xFrom Parameter'''
  1191. bl_idname = 'xFormParameterSocket'
  1192. bl_label = "xForm Parameter"
  1193. color_simple = cxForm
  1194. color : bpy.props.FloatVectorProperty(default=cxForm, size=4)
  1195. input : bpy.props.BoolProperty(default =False,)
  1196. def init(self):
  1197. self.display_shape = 'CIRCLE_DOT'
  1198. def draw(self, context, layout, node, text):
  1199. ChooseDraw(self, context, layout, node, text)
  1200. def draw_color(self, context, node):
  1201. return self.color
  1202. @classmethod
  1203. def draw_color_simple(self):
  1204. return self.color_simple
  1205. # what is this one again?
  1206. class ParameterBoolSocket(MantisSocket):
  1207. """Boolean Parameter Socket"""
  1208. bl_idname = 'ParameterBoolSocket'
  1209. bl_label = "Boolean Parameter"
  1210. color_simple = cBool
  1211. color : bpy.props.FloatVectorProperty(default=cBool, size=4)
  1212. input : bpy.props.BoolProperty(default =False,)
  1213. #custom properties:
  1214. min:bpy.props.FloatProperty(default = 0)
  1215. max:bpy.props.FloatProperty(default = 1)
  1216. soft_min:bpy.props.FloatProperty(default = 0)
  1217. soft_max:bpy.props.FloatProperty(default = 1)
  1218. description:bpy.props.StringProperty(default = "")
  1219. default_value : bpy.props.BoolProperty(default = False, update = update_socket,)
  1220. def init(self):
  1221. self.display_shape = 'CIRCLE_DOT'
  1222. # if True:
  1223. # print (self.is_property_set("default_value"))
  1224. # ui_data = self.id_properties_ui("default_value")
  1225. # ui_data.update(
  1226. # description=self.description,
  1227. # default=0,) # for now
  1228. # ui_data.update(
  1229. # min = self.min,
  1230. # max = self.max,
  1231. # soft_min = self.soft_min,
  1232. # soft_max = self.soft_max,)
  1233. def draw(self, context, layout, node, text):
  1234. ChooseDraw(self, context, layout, node, text)
  1235. def draw_color(self, context, node):
  1236. return self.color
  1237. @classmethod
  1238. def draw_color_simple(self):
  1239. return self.color_simple
  1240. class ParameterIntSocket(MantisSocket):
  1241. """Integer Parameter socket"""
  1242. bl_idname = 'ParameterIntSocket'
  1243. bl_label = "Integer Parameter"
  1244. default_value : bpy.props.IntProperty(default = 0, update = update_socket,)
  1245. color_simple = cInt
  1246. color : bpy.props.FloatVectorProperty(default=cInt, size=4)
  1247. input : bpy.props.BoolProperty(default =False,)
  1248. #custom properties:
  1249. min:bpy.props.FloatProperty(default = 0)
  1250. max:bpy.props.FloatProperty(default = 1)
  1251. soft_min:bpy.props.FloatProperty(default = 0)
  1252. soft_max:bpy.props.FloatProperty(default = 1)
  1253. description:bpy.props.StringProperty(default = "")
  1254. def init(self):
  1255. self.display_shape = 'CIRCLE_DOT'
  1256. def draw(self, context, layout, node, text):
  1257. ChooseDraw(self, context, layout, node, text)
  1258. def draw_color(self, context, node):
  1259. return self.color
  1260. @classmethod
  1261. def draw_color_simple(self):
  1262. return self.color_simple
  1263. class ParameterFloatSocket(MantisSocket):
  1264. """Float Parameter socket"""
  1265. bl_idname = 'ParameterFloatSocket'
  1266. bl_label = "Float Parameter"
  1267. default_value : bpy.props.FloatProperty(default = 0.0, update = update_socket,)
  1268. color_simple = cFloat
  1269. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  1270. input : bpy.props.BoolProperty(default =False,)
  1271. #custom properties:
  1272. min:bpy.props.FloatProperty(default = 0)
  1273. max:bpy.props.FloatProperty(default = 1)
  1274. soft_min:bpy.props.FloatProperty(default = 0)
  1275. soft_max:bpy.props.FloatProperty(default = 1)
  1276. description:bpy.props.StringProperty(default = "")
  1277. def init(self):
  1278. self.display_shape = 'CIRCLE_DOT'
  1279. def draw(self, context, layout, node, text):
  1280. ChooseDraw(self, context, layout, node, text)
  1281. def draw_color(self, context, node):
  1282. return self.color
  1283. @classmethod
  1284. def draw_color_simple(self):
  1285. return self.color_simple
  1286. class ParameterVectorSocket(MantisSocket):
  1287. """Vector Parameter socket"""
  1288. bl_idname = 'ParameterVectorSocket'
  1289. bl_label = "Vector Parameter"
  1290. default_value : bpy.props.FloatVectorProperty(
  1291. default = (0.0, 0.0, 0.0),
  1292. update = update_socket,)
  1293. color_simple = cVector
  1294. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  1295. input : bpy.props.BoolProperty(default =False,)
  1296. #custom properties:
  1297. description:bpy.props.StringProperty(default = "")
  1298. def init(self):
  1299. self.display_shape = 'CIRCLE_DOT'
  1300. def draw(self, context, layout, node, text):
  1301. ChooseDraw(self, context, layout, node, text)
  1302. def draw_color(self, context, node):
  1303. return self.color
  1304. @classmethod
  1305. def draw_color_simple(self):
  1306. return self.color_simple
  1307. class ParameterStringSocket(MantisSocket):
  1308. """String Parameter socket"""
  1309. bl_idname = 'ParameterStringSocket'
  1310. bl_label = "String Parameter"
  1311. default_value : bpy.props.StringProperty(default = "", update = update_socket,)
  1312. color_simple = cString
  1313. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1314. input : bpy.props.BoolProperty(default =False,)
  1315. #custom properties:
  1316. description:bpy.props.StringProperty(default = "")
  1317. def init(self):
  1318. self.display_shape = 'CIRCLE_DOT'
  1319. def draw(self, context, layout, node, text):
  1320. ChooseDraw(self, context, layout, node, text)
  1321. def draw_color(self, context, node):
  1322. return self.color
  1323. @classmethod
  1324. def draw_color_simple(self):
  1325. return self.color_simple
  1326. #####################################################################################
  1327. # Additional socket types, for special cases
  1328. #####################################################################################
  1329. from bpy.props import PointerProperty, StringProperty
  1330. def poll_is_armature(self, obj):
  1331. return obj.type == "ARMATURE"
  1332. # def poll_is_armature(self, obj):
  1333. # return obj.type == "ARMATURE"
  1334. class EnumMetaRigSocket(MantisSocket):
  1335. '''Custom node socket type'''
  1336. bl_idname = 'EnumMetaRigSocket'
  1337. bl_label = "Meta Rig"
  1338. color_simple = cString
  1339. search_prop:PointerProperty(type=bpy.types.Object, poll=poll_is_armature, update=update_metarig_armature)
  1340. def get_default_value(self):
  1341. if self.search_prop:
  1342. return self.search_prop.name
  1343. return ""
  1344. def set_default_value(self, value):
  1345. if ob:= bpy.data.objects.get(value):
  1346. if ob.type == 'ARMATURE':
  1347. self.search_prop=ob
  1348. default_value : StringProperty(name = "", get=get_default_value, set=set_default_value)
  1349. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1350. def draw(self, context, layout, node, text):
  1351. if self.is_output:
  1352. layout.label(text=self.name)
  1353. elif not (self.is_linked):
  1354. layout.prop_search(data=self, property="search_prop", search_data=bpy.data, search_property="objects", text="", icon="OUTLINER_OB_ARMATURE", results_are_suggestions=True)
  1355. elif hasattr(self.node, "armature"):
  1356. layout.label(text=self.node.armature)
  1357. # TODO: we should actually use the parsed tree to query this info directly, since this socket may belong to a node group in/out
  1358. # which doesn't have this parameter. whatever.
  1359. else:
  1360. layout.label(text=self.name)
  1361. def draw_color(self, context, node):
  1362. return self.color
  1363. @classmethod
  1364. def draw_color_simple(self):
  1365. return self.color_simple
  1366. # I donno why but I can't just subclass the above. hmm.so this is a duplicate
  1367. class EnumArmature(MantisSocket):
  1368. bl_idname = "EnumArmature"
  1369. bl_label = "Armature"
  1370. color_simple = cString
  1371. search_prop:PointerProperty(type=bpy.types.Object, poll=poll_is_armature, update=update_metarig_armature)
  1372. def get_default_value(self):
  1373. if self.search_prop:
  1374. return self.search_prop.name
  1375. return ""
  1376. def set_default_value(self, value):
  1377. if ob:= bpy.data.objects.get(value):
  1378. if ob.type == 'ARMATURE':
  1379. self.search_prop=ob
  1380. default_value : StringProperty(name = "", get=get_default_value, set=set_default_value)
  1381. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1382. def draw(self, context, layout, node, text):
  1383. if self.is_output:
  1384. layout.label(text=self.name)
  1385. elif not (self.is_linked):
  1386. layout.prop_search(data=self, property="search_prop", search_data=bpy.data, search_property="objects", text="", icon="OUTLINER_OB_ARMATURE", results_are_suggestions=True)
  1387. elif hasattr(self.node, "armature"):
  1388. layout.label(text=self.node.armature)
  1389. # TODO: we should actually use the parsed tree to query this info directly, since this socket may belong to a node group in/out
  1390. # which doesn't have this parameter. whatever.
  1391. else:
  1392. layout.label(text=self.name)
  1393. def draw_color(self, context, node):
  1394. return self.color
  1395. @classmethod
  1396. def draw_color_simple(self):
  1397. return self.color_simple
  1398. def poll_is_curve(self, obj):
  1399. return obj.type == "CURVE"
  1400. class EnumCurveSocket(MantisSocket):
  1401. '''Choose a curve'''
  1402. bl_idname = 'EnumCurveSocket'
  1403. bl_label = "Curve"
  1404. is_valid_interface_type=True
  1405. search_prop:PointerProperty(type=bpy.types.Object, poll=poll_is_curve, update=update_socket)
  1406. def get_default_value(self):
  1407. if self.search_prop:
  1408. return self.search_prop.name
  1409. return ""
  1410. def set_default_value(self, value):
  1411. if ob:= bpy.data.objects.get(value):
  1412. if ob.type == 'CURVE':
  1413. self.search_prop=ob
  1414. default_value : StringProperty(name = "", get=get_default_value, set=set_default_value)
  1415. color_simple = cString
  1416. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1417. def draw(self, context, layout, node, text):
  1418. if not (self.is_linked) and not self.is_output:
  1419. layout.prop_search(data=self, property="search_prop", search_data=bpy.data, search_property="objects", text="", icon="CURVE_DATA", results_are_suggestions=True)
  1420. else:
  1421. try:
  1422. layout.label(text=self.search_prop.name)
  1423. except AttributeError: # TODO make this show the graph's result
  1424. layout.label(text=self.name)
  1425. def draw_color(self, context, node):
  1426. return self.color
  1427. @classmethod
  1428. def draw_color_simple(self):
  1429. return self.color_simple
  1430. def SearchPBDraw(self, context, layout, node, text, icon = "NONE", use_enum=True, nice_bool=True, icon_only=False):
  1431. layout.prop_search(data=self, property="default_value", search_data=self.armature.data, search_property="bones", text=text, icon=icon, results_are_suggestions=True)
  1432. class EnumMetaBoneSocket(MantisSocket):
  1433. '''Socket to Get a Bone from an object'''
  1434. bl_idname = 'EnumMetaBoneSocket'
  1435. bl_label = "Bone"
  1436. # this armature property is set by the parent node.
  1437. armature:PointerProperty(type=bpy.types.Object)
  1438. bone:StringProperty()
  1439. def populate_bones_list(self, context):
  1440. # just gonna hardcode the value
  1441. if (meta_rig := self.armature):
  1442. retList = []; i = -1
  1443. retList.append( ('NONE', '', '', 'NONE', i:=i+1 ) )
  1444. for b in meta_rig.data.bones:
  1445. retList.append( (b.name, b.name, "Bone to copy matrix from", "BONE_DATA", i:=i+1 ) )
  1446. return(retList)
  1447. return None
  1448. default_value : StringProperty(name = "", update=update_metarig_posebone)
  1449. color_simple = cString
  1450. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1451. def draw(self, context, layout, node, text):
  1452. if not (self.is_linked):
  1453. if self.armature is None:
  1454. layout.prop(self, "default_value", text="", icon="BONE_DATA",)
  1455. else:
  1456. SearchPBDraw(self, context, layout, node, text="")
  1457. else:
  1458. layout.label(text=self.node.pose_bone)
  1459. def draw_color(self, context, node):
  1460. return self.color
  1461. @classmethod
  1462. def draw_color_simple(self):
  1463. return self.color_simple
  1464. # I don't know why but I can't subclass the above and I had to duplicate it here
  1465. class EnumExistingBoneSocket(MantisSocket):
  1466. '''Socket to Get a Bone from an object'''
  1467. bl_idname = 'EnumExistingBoneSocket'
  1468. bl_label = "Bone"
  1469. color_simple = cString
  1470. # this armature property is set by the parent node.
  1471. armature:PointerProperty(type=bpy.types.Object)
  1472. bone:StringProperty()
  1473. def populate_bones_list(self, context):
  1474. # just gonna hardcode the value
  1475. if (meta_rig := self.armature):
  1476. retList = []; i = -1
  1477. retList.append( ('NONE', '', '', 'NONE', i:=i+1 ) )
  1478. for b in meta_rig.data.bones:
  1479. retList.append( (b.name, b.name, "Bone to copy matrix from", "BONE_DATA", i:=i+1 ) )
  1480. return(retList)
  1481. return None
  1482. default_value : StringProperty(name = "", update=update_metarig_posebone)
  1483. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1484. def draw(self, context, layout, node, text):
  1485. if not (self.is_linked):
  1486. if self.armature is None:
  1487. layout.prop(self, "default_value", text="", icon="BONE_DATA",)
  1488. else:
  1489. SearchPBDraw(self, context, layout, node, text="")
  1490. else:
  1491. layout.label(text=self.node.pose_bone)
  1492. def draw_color(self, context, node):
  1493. return self.color
  1494. @classmethod
  1495. def draw_color_simple(self):
  1496. return self.color_simple
  1497. # TODO: make it so that this makes an item for "missing" widgets
  1498. # for when a widget is moved or deleted
  1499. # Make it read .blend
  1500. # make it read the current directory, too?
  1501. def get_widget_library_items(self, context):
  1502. from .preferences import get_bl_addon_object
  1503. bl_mantis_addon = get_bl_addon_object()
  1504. from os import path as os_path
  1505. prev_name = os_path.split(self.previous_value)[-1]
  1506. default_missing_value = ('MISSING', f'MISSING: {prev_name}', self.previous_value, 'ERROR', self.previous_index)
  1507. return_value = [default_missing_value]
  1508. widget_names={}
  1509. if bl_mantis_addon and bl_mantis_addon.preferences:
  1510. widgets_path = bl_mantis_addon.preferences.WidgetsLibraryFolder
  1511. from os import walk as os_walk
  1512. for path_root, dirs, files, in os_walk(widgets_path):
  1513. # TODO handle .blend files
  1514. for file in files:
  1515. relative_file_name = os_path.join(os_path.sep.join(dirs), file)
  1516. if file.endswith('.obj'):
  1517. widget_names[relative_file_name[:-4]] = relative_file_name
  1518. if widget_names.keys():
  1519. return_value=[]
  1520. # first we select the previous value if it exists
  1521. add_missing_key=False
  1522. add_one=0
  1523. if self.previous_value and self.previous_value not in widget_names.values():
  1524. add_missing_key=True # we need to add the missing key at the previous index
  1525. sorted_keys = list(widget_names.keys())
  1526. sorted_keys.sort()
  1527. for i, name in enumerate(sorted_keys):
  1528. path = widget_names[name]
  1529. if add_missing_key and i == self.previous_index:
  1530. add_one+=1; return_value.append(default_missing_value)
  1531. return_value.append( (path, name, path, 'GIZMO', i+add_one) )
  1532. return return_value
  1533. # THIS is a special socket type that finds the widgets in your widgets library (set in preferences)
  1534. class EnumWidgetLibrarySocket(MantisSocket):
  1535. '''Choose a Wdiget'''
  1536. bl_idname = 'EnumWidgetLibrarySocket'
  1537. bl_label = "Widget"
  1538. is_valid_interface_type=False
  1539. default_value : bpy.props.EnumProperty(
  1540. items=get_widget_library_items,
  1541. name="Widget",
  1542. description="Which widget to use",
  1543. default = 0,
  1544. update = update_socket_external_load,)
  1545. color_simple = cString
  1546. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1547. previous_value : bpy.props.StringProperty(default="")
  1548. previous_index : bpy.props.IntProperty(default=0)
  1549. def draw(self, context, layout, node, text):
  1550. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1551. def draw_color(self, context, node):
  1552. return self.color
  1553. @classmethod
  1554. def draw_color_simple(self):
  1555. return self.color_simple
  1556. class BoolUpdateParentNode(MantisSocket):
  1557. '''Custom node socket type'''
  1558. bl_idname = 'BoolUpdateParentNode'
  1559. bl_label = "Boolean"
  1560. default_value: bpy.props.BoolProperty(default=False, update = update_parent_node)
  1561. color_simple = cBool
  1562. color : bpy.props.FloatVectorProperty(default=cBool, size=4)
  1563. input : bpy.props.BoolProperty(default =False,)
  1564. def draw(self, context, layout, node, text):
  1565. ChooseDraw(self, context, layout, node, text)
  1566. def draw_color(self, context, node):
  1567. return self.color
  1568. @classmethod
  1569. def draw_color_simple(self):
  1570. return self.color_simple
  1571. class IKChainLengthSocket(MantisSocket):
  1572. '''Custom node socket type'''
  1573. bl_idname = 'IKChainLengthSocket'
  1574. bl_label = "IK Chain Length"
  1575. default_value: bpy.props.IntProperty(default=0, update = ik_chain_length_update_socket, min = 0, max = 255)
  1576. color_simple = cInt
  1577. color : bpy.props.FloatVectorProperty(default=cInt, size=4)
  1578. input : bpy.props.BoolProperty(default =False,)
  1579. def draw(self, context, layout, node, text):
  1580. ChooseDraw(self, context, layout, node, text)
  1581. def draw_color(self, context, node):
  1582. return self.color
  1583. @classmethod
  1584. def draw_color_simple(self):
  1585. return self.color_simple
  1586. # Inherit
  1587. eInheritScale = (
  1588. ('FULL', "Full", "Fully inherit scale", 1),
  1589. ('AVERAGE', "Average", "todo", 2),
  1590. ('ALIGNED', "Aligned", "todo", 3),
  1591. ('FIX_SHEAR', "Fix Shear", "todo", 4),
  1592. ('NONE', "None", "todo", 5),
  1593. )
  1594. class EnumInheritScale(MantisSocket):
  1595. '''Custom node socket type'''
  1596. bl_idname = 'EnumInheritScale'
  1597. bl_label = "Inherit Scale"
  1598. default_value: bpy.props.EnumProperty(
  1599. items=eInheritScale,
  1600. name="Inherit Scale",
  1601. description="Inherit Scale",
  1602. default = 'FULL',
  1603. #options = set(),
  1604. update = update_socket,)
  1605. color_simple = cString
  1606. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1607. input : bpy.props.BoolProperty(default =False,)
  1608. def draw(self, context, layout, node, text):
  1609. ChooseDraw(self, context, layout, node, text)
  1610. def draw_color(self, context, node):
  1611. return self.color
  1612. @classmethod
  1613. def draw_color_simple(self):
  1614. return self.color_simple
  1615. # Copy Rotation
  1616. eRotationMix =(
  1617. ('REPLACE', "Replace", "Fully inherit scale", 0),
  1618. ('BEFORE', "Before", "Fully inherit scale", 1),
  1619. ('AFTER', "After", "Fully inherit scale", 2),
  1620. ('ADD', "Add", "Fully inherit scale", 3),
  1621. #todo, but i don't care much
  1622. )
  1623. # TODO HACK
  1624. # I am trying to figure out how to do enum_flag as
  1625. # mutually exclusive options
  1626. # but! I don't think it's possible
  1627. # I just like the UI for it :P
  1628. class EnumRotationMix(MantisSocket):
  1629. '''Custom node socket type'''
  1630. bl_idname = 'EnumRotationMix'
  1631. bl_label = "Rotation Mix"
  1632. default_value: bpy.props.EnumProperty(
  1633. items=eRotationMix,
  1634. name="Rotation Mix",
  1635. description="Rotation Mix",
  1636. default = 'REPLACE',#{'REPLACE'},
  1637. options = set(), # this has to be a set lol
  1638. update = update_socket,)
  1639. color_simple = cString
  1640. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1641. input : bpy.props.BoolProperty(default =False,)
  1642. def draw(self, context, layout, node, text):
  1643. ChooseDraw(self, context, layout, node, text)
  1644. def draw_color(self, context, node):
  1645. return self.color
  1646. @classmethod
  1647. def draw_color_simple(self):
  1648. return self.color_simple
  1649. eRotationMix_copytransforms =(
  1650. ('REPLACE', "Replace (Aligned)", "Fully inherit scale"),
  1651. ('BEFORE', "Before (Aligned)", "Fully inherit scale"),
  1652. ('AFTER', "After (Aligned)", "Fully inherit scale"),
  1653. ('REPLACE_SPLIT', "Replace (Split Channels)", "Fully inherit scale"),
  1654. ('BEFORE_SPLIT', "Before (Split Channels)", "Fully inherit scale"),
  1655. ('AFTER_SPLIT', "After (Split Channels)", "Fully inherit scale"),
  1656. ('REPLACE_FULL', "Replace (Full)", "Fully inherit scale"),
  1657. ('BEFORE_FULL', "Before (Full)", "Fully inherit scale"),
  1658. ('AFTER_FULL', "After (Full)", "Fully inherit scale"),)
  1659. class EnumRotationMixCopyTransforms(MantisSocket):
  1660. '''Custom node socket type'''
  1661. bl_idname = 'EnumRotationMixCopyTransforms'
  1662. bl_label = "Rotation Mix"
  1663. default_value: bpy.props.EnumProperty(
  1664. items=eRotationMix_copytransforms,
  1665. name="Rotation Mix",
  1666. description="Rotation Mix",
  1667. default = 'REPLACE', #{'REPLACE'},
  1668. #options = {'ENUM_FLAG'}, # this sux
  1669. update = update_socket,)
  1670. color_simple = cString
  1671. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1672. input : bpy.props.BoolProperty(default =False,)
  1673. def draw(self, context, layout, node, text):
  1674. ChooseDraw(self, context, layout, node, text)
  1675. def draw_color(self, context, node):
  1676. return self.color
  1677. @classmethod
  1678. def draw_color_simple(self):
  1679. return self.color_simple
  1680. # STRETCH TO
  1681. eMaintainVolumeStretchTo = (('VOLUME_XZX', "XZ", "XZ", 1),
  1682. ('VOLUME_X', "X", "X", 2),
  1683. ('VOLUME_Z', "Z", "Z", 4),
  1684. ('NO_VOLUME', "None", "None", 8),)
  1685. class EnumMaintainVolumeStretchTo(MantisSocket):
  1686. '''Custom node socket type'''
  1687. bl_idname = 'EnumMaintainVolumeStretchToSocket'
  1688. bl_label = "Maintain Volume"
  1689. default_value: bpy.props.EnumProperty(
  1690. items=eMaintainVolumeStretchTo,
  1691. name="Maintain Volume",
  1692. description="Maintain Volume",
  1693. default = 'VOLUME_XZX',
  1694. #options = {'ENUM_FLAG'},
  1695. update = update_socket,)
  1696. color_simple = cString
  1697. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1698. input : bpy.props.BoolProperty(default =False,)
  1699. def draw(self, context, layout, node, text):
  1700. ChooseDraw(self, context, layout, node, text)
  1701. def draw_color(self, context, node):
  1702. return self.color
  1703. @classmethod
  1704. def draw_color_simple(self):
  1705. return self.color_simple
  1706. eRotationStretchTo = (('PLANE_X', "XZ", "XZ", 1),
  1707. ('PLANE_Z', "ZX", "ZX", 2),
  1708. ('SWING_Y', "Swing", "Swing", 4),)
  1709. class EnumRotationStretchTo(MantisSocket):
  1710. '''Custom node socket type'''
  1711. bl_idname = 'EnumRotationStretchTo'
  1712. bl_label = "Rotation"
  1713. default_value: bpy.props.EnumProperty(
  1714. items=eRotationStretchTo,
  1715. name="Rotation",
  1716. description="Rotation",
  1717. default = 'PLANE_X',
  1718. #options = {'ENUM_FLAG'},
  1719. update = update_socket,)
  1720. color_simple = cString
  1721. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1722. input : bpy.props.BoolProperty(default =False,)
  1723. def draw(self, context, layout, node, text):
  1724. ChooseDraw(self, context, layout, node, text)
  1725. def draw_color(self, context, node):
  1726. return self.color
  1727. @classmethod
  1728. def draw_color_simple(self):
  1729. return self.color_simple
  1730. # Track-To
  1731. eTrackAxis = (('TRACK_X', "X", "X", 1),
  1732. ('TRACK_Y', "Y", "Y", 2),
  1733. ('TRACK_Z', "Z", "Z", 4),
  1734. ('TRACK_NEGATIVE_X', "-X", "-X", 8),
  1735. ('TRACK_NEGATIVE_Y', "-Y", "-Y", 16),
  1736. ('TRACK_NEGATIVE_Z', "-Z", "-Z", 32,))
  1737. eUpAxis = (('UP_X', "X", "X", 1),
  1738. ('UP_Y', "Y", "Y", 2),
  1739. ('UP_Z', "Z", "Z", 4),)
  1740. # ugly but I can't change it easily without messing up versioning
  1741. class EnumTrackAxis(MantisSocket):
  1742. '''Custom node socket type'''
  1743. bl_idname = 'EnumTrackAxis'
  1744. bl_label = "Track Axis"
  1745. default_value: bpy.props.EnumProperty(
  1746. items=eTrackAxis,
  1747. name="Track Axis",
  1748. description="Track Axis",
  1749. default = 'TRACK_X',
  1750. #options = {'ENUM_FLAG'},
  1751. update = update_socket,)
  1752. color_simple = cString
  1753. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1754. input : bpy.props.BoolProperty(default =False,)
  1755. def draw(self, context, layout, node, text):
  1756. ChooseDraw(self, context, layout, node, text)
  1757. def draw_color(self, context, node):
  1758. return self.color
  1759. @classmethod
  1760. def draw_color_simple(self):
  1761. return self.color_simple
  1762. class EnumUpAxis(MantisSocket):
  1763. '''Custom node socket type'''
  1764. bl_idname = 'EnumUpAxis'
  1765. bl_label = "Up Axis"
  1766. default_value: bpy.props.EnumProperty(
  1767. items=eUpAxis,
  1768. name="Up Axis",
  1769. description="Up Axis",
  1770. default = 'UP_X',
  1771. #options = {'ENUM_FLAG'},
  1772. update = update_socket,)
  1773. color_simple = cString
  1774. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1775. input : bpy.props.BoolProperty(default =False,)
  1776. def draw(self, context, layout, node, text):
  1777. ChooseDraw(self, context, layout, node, text)
  1778. def draw_color(self, context, node):
  1779. return self.color
  1780. @classmethod
  1781. def draw_color_simple(self):
  1782. return self.color_simple
  1783. # Follow Track Forward axis
  1784. eForwardAxis = (('FORWARD_X', "X", "X", 0),
  1785. ('FORWARD_Y', "Y", "Y", 1),
  1786. ('FORWARD_Z', "Z", "Z", 2),
  1787. ('TRACK_NEGATIVE_X', "-X", "-X", 3),
  1788. ('TRACK_NEGATIVE_Y', "-Y", "-Y", 4),
  1789. ('TRACK_NEGATIVE_Z', "-Z", "-Z", 5),)
  1790. class EnumFollowPathForwardAxis(MantisSocket):
  1791. '''Custom node socket type'''
  1792. bl_idname = 'EnumFollowPathForwardAxis'
  1793. bl_label = "Forward Axis"
  1794. default_value: bpy.props.EnumProperty(
  1795. items=eForwardAxis,
  1796. name="Forward Axis",
  1797. description="Forward Axis",
  1798. default = 'FORWARD_X',
  1799. update = update_socket,)
  1800. color_simple = cString
  1801. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1802. input : bpy.props.BoolProperty(default =False,)
  1803. def draw(self, context, layout, node, text):
  1804. ChooseDraw(self, context, layout, node, text)
  1805. def draw_color(self, context, node):
  1806. return self.color
  1807. @classmethod
  1808. def draw_color_simple(self):
  1809. return self.color_simple
  1810. # Follow Track Forward axis
  1811. eFloorAxis = (('FLOOR_X', "X", "X", 0),
  1812. ('FLOOR_Y', "Y", "Y", 1),
  1813. ('FLOOR_Z', "Z", "Z", 2),
  1814. ('FLOOR_NEGATIVE_X', "-X", "-X", 3),
  1815. ('FLOOR_NEGATIVE_Y', "-Y", "-Y", 4),
  1816. ('FLOOR_NEGATIVE_Z', "-Z", "-Z", 5),)
  1817. class EnumFloorAxis(MantisSocket):
  1818. '''Floor Constraint Axis'''
  1819. bl_idname = 'EnumFloorAxis'
  1820. bl_label = "Floor Axis"
  1821. default_value: bpy.props.EnumProperty(
  1822. items=eFloorAxis,
  1823. name="Floor Axis",
  1824. description="Floor Axis",
  1825. default = 'FLOOR_X',
  1826. update = update_socket,)
  1827. color_simple = cString
  1828. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1829. input : bpy.props.BoolProperty(default =False,)
  1830. def draw(self, context, layout, node, text):
  1831. ChooseDraw(self, context, layout, node, text)
  1832. def draw_color(self, context, node):
  1833. return self.color
  1834. @classmethod
  1835. def draw_color_simple(self):
  1836. return self.color_simple
  1837. # Locked Track
  1838. eLockAxis = (('LOCK_X', "X", "X", 1),
  1839. ('LOCK_Y', "Y", "Y", 2),
  1840. ('LOCK_Z', "Z", "Z", 4),)
  1841. class EnumLockAxis(MantisSocket):
  1842. '''Custom node socket type'''
  1843. bl_idname = 'EnumLockAxis'
  1844. bl_label = "Lock Axis"
  1845. default_value: bpy.props.EnumProperty(
  1846. items=eLockAxis,
  1847. name="Lock Axis",
  1848. description="Lock Axis",
  1849. default = 'LOCK_X',
  1850. #options = {'ENUM_FLAG'},
  1851. update = update_socket,)
  1852. color_simple = cString
  1853. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1854. input : bpy.props.BoolProperty(default =False,)
  1855. def draw(self, context, layout, node, text):
  1856. ChooseDraw(self, context, layout, node, text)
  1857. def draw_color(self, context, node):
  1858. return self.color
  1859. @classmethod
  1860. def draw_color_simple(self):
  1861. return self.color_simple
  1862. # Limit Distance:
  1863. eLimitMode = (('LIMITDIST_INSIDE', "Inside", "Inside",),
  1864. ('LIMITDIST_OUTSIDE', "Outside", "Outside",),
  1865. ('LIMITDIST_ONSURFACE', "On Surface", "On Surface",),)
  1866. class EnumLimitMode(MantisSocket):
  1867. '''Custom node socket type'''
  1868. bl_idname = 'EnumLimitMode'
  1869. bl_label = "Clamp Region"
  1870. default_value: bpy.props.EnumProperty(
  1871. items=eLimitMode,
  1872. name="Clamp Region",
  1873. description="Clamp Region",
  1874. default = 'LIMITDIST_INSIDE',
  1875. update = update_socket,)
  1876. color_simple = cString
  1877. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1878. input : bpy.props.BoolProperty(default =False,)
  1879. def draw(self, context, layout, node, text):
  1880. ChooseDraw(self, context, layout, node, text)
  1881. def draw_color(self, context, node):
  1882. return self.color
  1883. @classmethod
  1884. def draw_color_simple(self):
  1885. return self.color_simple
  1886. # Spline IK
  1887. eYScaleMode = (('NONE', "None", "Don’t scale the X and Z axes.",),
  1888. ('FIT_CURVE', "Fit Curve", "Scale the bones to fit the entire length of the curve.",),
  1889. ('BONE_ORIGINAL', "Bone Original", "Use the original scaling of the bones.",),)
  1890. eXZScaleMode = (('NONE', "None", "Don’t scale the X and Z axes.",),
  1891. ('BONE_ORIGINAL', "Bone Original", "Use the original scaling of the bones.",),
  1892. ('INVERSE_PRESERVE', "Inverse Scale", "Scale of the X and Z axes is the inverse of the Y-Scale.",),
  1893. ('VOLUME_PRESERVE', "Volume Preservation", "Scale of the X and Z axes are adjusted to preserve the volume of the bones.",),)
  1894. class EnumYScaleMode(MantisSocket):
  1895. '''Custom node socket type'''
  1896. bl_idname = 'EnumYScaleMode'
  1897. bl_label = "Y Scale Mode"
  1898. default_value: bpy.props.EnumProperty(
  1899. items=eYScaleMode,
  1900. name="Y Scale Mode",
  1901. description="Y Scale Mode",
  1902. default = 'FIT_CURVE',
  1903. update = update_socket,)
  1904. color_simple = cString
  1905. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1906. input : bpy.props.BoolProperty(default =False,)
  1907. def draw(self, context, layout, node, text):
  1908. ChooseDraw(self, context, layout, node, text)
  1909. def draw_color(self, context, node):
  1910. return self.color
  1911. @classmethod
  1912. def draw_color_simple(self):
  1913. return self.color_simple
  1914. class EnumXZScaleMode(MantisSocket):
  1915. '''Custom node socket type'''
  1916. bl_idname = 'EnumXZScaleMode'
  1917. bl_label = "XZ Scale Mode"
  1918. default_value: bpy.props.EnumProperty(
  1919. items=eXZScaleMode,
  1920. name="XZ Scale Mode",
  1921. description="XZ Scale Mode",
  1922. default = 'NONE',
  1923. update = update_socket,)
  1924. color_simple = cString
  1925. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1926. input : bpy.props.BoolProperty(default =False,)
  1927. def draw(self, context, layout, node, text):
  1928. ChooseDraw(self, context, layout, node, text)
  1929. def draw_color(self, context, node):
  1930. return self.color
  1931. @classmethod
  1932. def draw_color_simple(self):
  1933. return self.color_simple
  1934. eMapxForm = (('LOCATION', "Location", "Location",),
  1935. ('ROTATION', "Rotation", "Rotation",),
  1936. ('SCALE', "Scale", "Scale",),)
  1937. eRotationMode = (('AUTO', 'Auto', 'Automattically Selected.', 0),
  1938. ('XYZ', "XYZ", "Euler using the XYZ rotation order", 1),
  1939. ('XZY', "XZY", "Euler using the XZY rotation order", 2),
  1940. ('ZXY', "ZXY", "Euler using the ZXY rotation order", 3),
  1941. ('ZYX', "ZYX", "Euler using the ZYX rotation order", 4),
  1942. ('YXZ', "YXZ", "Euler using the YXZ rotation order", 5),
  1943. ('YZX', "YZX", "Euler using the YZX rotation order", 6),
  1944. ('QUATERNION', "Quaternion", "Quaternion", 7),
  1945. ('SWING_TWIST_X', 'Swing and X Twist.', 'Decompose into a swing rotation to aim the X axis, followed by twist around it.', 8),
  1946. ('SWING_TWIST_Y', 'Swing and Y Twist.', 'Decompose into a swing rotation to aim the Y axis, followed by twist around it.', 9),
  1947. ('SWING_TWIST_Z', 'Swing and Z Twist.', 'Decompose into a swing rotation to aim the Z axis, followed by twist around it.', 10),)
  1948. enumTransformationRotationOrder = enumRotationOrder[:6]
  1949. eTranslationMix =(
  1950. ('ADD', "Add", "", 0),
  1951. ('REPLACE', "Replace", "", 1),
  1952. )
  1953. eScaleMix =(
  1954. ('MULTIPLY', "Multiply", "", 0),
  1955. ('REPLACE', "Replace", "", 1),
  1956. )
  1957. class EnumTransformationMap(MantisSocket):
  1958. '''Custom node socket type'''
  1959. bl_idname = 'EnumTransformationMap'
  1960. bl_label = "Map To/From"
  1961. default_value: bpy.props.EnumProperty(
  1962. items=eMapxForm,
  1963. name="Map To/From",
  1964. description="Map To/From",
  1965. default = 'LOCATION',
  1966. update = update_socket,)
  1967. color_simple = cString
  1968. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1969. input : bpy.props.BoolProperty(default =False,)
  1970. def draw(self, context, layout, node, text):
  1971. ChooseDraw(self, context, layout, node, text)
  1972. def draw_color(self, context, node):
  1973. return self.color
  1974. @classmethod
  1975. def draw_color_simple(self):
  1976. return self.color_simple
  1977. class EnumTransformationRotationMode(MantisSocket):
  1978. '''Custom node socket type'''
  1979. bl_idname = 'EnumTransformationRotationMode'
  1980. bl_label = "Map To/From"
  1981. default_value: bpy.props.EnumProperty(
  1982. items=eRotationMode,
  1983. name="Rotation Mode",
  1984. description="Rotation Mode",
  1985. default = 'AUTO',
  1986. update = update_socket,)
  1987. color_simple = cString
  1988. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1989. input : bpy.props.BoolProperty(default =False,)
  1990. def draw(self, context, layout, node, text):
  1991. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1992. def draw_color(self, context, node):
  1993. return self.color
  1994. @classmethod
  1995. def draw_color_simple(self):
  1996. return self.color_simple
  1997. class EnumTransformationRotationOrder(MantisSocket):
  1998. '''Custom node socket type'''
  1999. bl_idname = 'EnumTransformationRotationOrder'
  2000. bl_label = "Map To/From"
  2001. default_value: bpy.props.EnumProperty(
  2002. items=enumTransformationRotationOrder,
  2003. name="Rotation Order",
  2004. description="Rotation Order",
  2005. default = 'AUTO',
  2006. update = update_socket,)
  2007. color_simple = cString
  2008. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2009. input : bpy.props.BoolProperty(default =False,)
  2010. def draw(self, context, layout, node, text):
  2011. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2012. def draw_color(self, context, node):
  2013. return self.color
  2014. @classmethod
  2015. def draw_color_simple(self):
  2016. return self.color_simple
  2017. class EnumTransformationTranslationMixMode(MantisSocket):
  2018. '''Custom node socket type'''
  2019. bl_idname = 'EnumTransformationTranslationMixMode'
  2020. bl_label = "Mix Mode"
  2021. default_value: bpy.props.EnumProperty(
  2022. items=eTranslationMix,
  2023. name="Mix Translation",
  2024. description="Mix Translation",
  2025. default = 'ADD',
  2026. update = update_socket,)
  2027. color_simple = cString
  2028. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2029. input : bpy.props.BoolProperty(default =False,)
  2030. def draw(self, context, layout, node, text):
  2031. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2032. def draw_color(self, context, node):
  2033. return self.color
  2034. @classmethod
  2035. def draw_color_simple(self):
  2036. return self.color_simple
  2037. class EnumTransformationRotationMixMode(MantisSocket):
  2038. '''Custom node socket type'''
  2039. bl_idname = 'EnumTransformationRotationMixMode'
  2040. bl_label = "Mix Mode"
  2041. default_value: bpy.props.EnumProperty(
  2042. items=eRotationMix,
  2043. name="Mix Rotation",
  2044. description="Mix Rotation",
  2045. default = 'ADD',
  2046. update = update_socket,)
  2047. color_simple = cString
  2048. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2049. input : bpy.props.BoolProperty(default =False,)
  2050. def draw(self, context, layout, node, text):
  2051. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2052. def draw_color(self, context, node):
  2053. return self.color
  2054. @classmethod
  2055. def draw_color_simple(self):
  2056. return self.color_simple
  2057. class EnumTransformationScaleMixMode(MantisSocket):
  2058. '''Custom node socket type'''
  2059. bl_idname = 'EnumTransformationScaleMixMode'
  2060. bl_label = "Mix Mode"
  2061. default_value: bpy.props.EnumProperty(
  2062. items=eScaleMix,
  2063. name="Mix Scale",
  2064. description="Mix Scale",
  2065. default = 'REPLACE',
  2066. update = update_socket,)
  2067. color_simple = cString
  2068. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2069. input : bpy.props.BoolProperty(default =False,)
  2070. def draw(self, context, layout, node, text):
  2071. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2072. def draw_color(self, context, node):
  2073. return self.color
  2074. @classmethod
  2075. def draw_color_simple(self):
  2076. return self.color_simple
  2077. eAxes = (
  2078. ('X', "X", "X", 0),
  2079. ('Y', "Y", "Y", 1),
  2080. ('Z', "Z", "Z", 2),
  2081. )
  2082. class EnumTransformationAxes(MantisSocket):
  2083. '''Custom node socket type'''
  2084. bl_idname = 'EnumTransformationAxes'
  2085. bl_label = "Axes"
  2086. default_value: bpy.props.EnumProperty(
  2087. items=eAxes,
  2088. # name="",
  2089. # description="",
  2090. default = 'X',
  2091. update = update_socket,)
  2092. color_simple = cString
  2093. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2094. input : bpy.props.BoolProperty(default =False,)
  2095. def draw(self, context, layout, node, text):
  2096. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2097. def draw_color(self, context, node):
  2098. return self.color
  2099. @classmethod
  2100. def draw_color_simple(self):
  2101. return self.color_simple
  2102. #
  2103. eBBoneHandleType = (
  2104. ('AUTO', "Automatic", "", 0),
  2105. ('ABSOLUTE', "Absolute", "", 1),
  2106. ('RELATIVE', "Relative", "", 2),
  2107. ('TANGENT', "Tangent", "", 3),
  2108. )
  2109. class EnumBBoneHandleType(MantisSocket):
  2110. '''Custom node socket type'''
  2111. bl_idname = 'EnumBBoneHandleType'
  2112. bl_label = "Axes"
  2113. default_value: bpy.props.EnumProperty(
  2114. items=eBBoneHandleType,
  2115. # name="",
  2116. # description="",
  2117. default = 'AUTO',
  2118. update = update_socket,)
  2119. color_simple = cString
  2120. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2121. input : bpy.props.BoolProperty(default =False,)
  2122. def draw(self, context, layout, node, text):
  2123. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2124. def draw_color(self, context, node):
  2125. return self.color
  2126. @classmethod
  2127. def draw_color_simple(self):
  2128. return self.color_simple
  2129. eShrinkwrapType = (
  2130. ('NEAREST_SURFACE', "Nearest Surface Point",
  2131. "Shrink the location to the nearest target surface.", 0),
  2132. ('PROJECT', "Project", "Shrink the location to the nearest target "
  2133. "surface along a given axis.", 1),
  2134. ('NEAREST_VERTEX', "Nearest Vertex", "Shrink the location to the"
  2135. " nearest target vertex.", 2),
  2136. ('TARGET_PROJECT', "Target Normal Project", "Shrink the location to the"
  2137. " nearest target surface along the interpolated vertex"
  2138. " normals of the target.", 3),
  2139. )
  2140. class EnumShrinkwrapTypeSocket(MantisSocket):
  2141. '''Shrinkwrap Type Socket'''
  2142. bl_idname = 'EnumShrinkwrapTypeSocket'
  2143. bl_label = "Shrinkwrap Type"
  2144. default_value: bpy.props.EnumProperty(
  2145. items=eShrinkwrapType,
  2146. description="Select type of shrinkwrap algorithm for target position",
  2147. default = 'TARGET_PROJECT',
  2148. update = update_socket,)
  2149. color_simple = cString
  2150. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2151. input : bpy.props.BoolProperty(default =False,)
  2152. def draw(self, context, layout, node, text):
  2153. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2154. def draw_color(self, context, node):
  2155. return self.color
  2156. @classmethod
  2157. def draw_color_simple(self):
  2158. return self.color_simple
  2159. eShrinkwrapFaceCull = (
  2160. ('OFF', "Off", "No Culling.", 0),
  2161. ('FRONT', "Front", "No projection when in front of the face.", 1),
  2162. ('BACK', "Back", "No projection when behind the face.", 2),
  2163. )
  2164. class EnumShrinkwrapFaceCullSocket(MantisSocket):
  2165. '''Shrinkwrap Face Cull method Socket'''
  2166. bl_idname = 'EnumShrinkwrapFaceCullSocket'
  2167. bl_label = "Shrinkwrap Type"
  2168. default_value: bpy.props.EnumProperty(
  2169. items=eShrinkwrapFaceCull,
  2170. description="Stop vertices from projecting to a face on the target"
  2171. " when facing towards/away",
  2172. default = 'OFF',
  2173. update = update_socket,)
  2174. color_simple = cString
  2175. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2176. input : bpy.props.BoolProperty(default =False,)
  2177. def draw(self, context, layout, node, text):
  2178. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2179. def draw_color(self, context, node):
  2180. return self.color
  2181. @classmethod
  2182. def draw_color_simple(self):
  2183. return self.color_simple
  2184. eShrinkwrapProjectAxis = (
  2185. ('POS_X', "+X", "", 0),
  2186. ('POS_Y', "+Y", "", 1),
  2187. ('POS_Z', "+Z", "", 2),
  2188. ('NEG_X', "-X", "", 3),
  2189. ('NEG_Y', "-Y", "", 4),
  2190. ('NEG_Z', "-Z", "", 5), )
  2191. class EnumShrinkwrapProjectAxisSocket(MantisSocket):
  2192. '''Shrinkwrap Projection Axis Socket'''
  2193. bl_idname = 'EnumShrinkwrapProjectAxisSocket'
  2194. bl_label = "Shrinkwrap Projection Axis"
  2195. default_value: bpy.props.EnumProperty(
  2196. items=eShrinkwrapProjectAxis,
  2197. description="Axis constrain to",
  2198. default = 'POS_X',
  2199. update = update_socket,)
  2200. color_simple = cString
  2201. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2202. input : bpy.props.BoolProperty(default =False,)
  2203. def draw(self, context, layout, node, text):
  2204. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2205. def draw_color(self, context, node):
  2206. return self.color
  2207. @classmethod
  2208. def draw_color_simple(self):
  2209. return self.color_simple
  2210. eShrinkwrapMode = (
  2211. ('ON_SURFACE', "On Surface", "The point is constrained to the surface"
  2212. " of the target object, with distance offset towards the"
  2213. " original point location.", 0),
  2214. ('INSIDE', "Inside", "The point is constrained to be inside the target"
  2215. " object", 1),
  2216. ('OUTSIDE', "Outside", "The point is constrained to be outside the "
  2217. "target object.", 2),
  2218. ('OUTSIDE_SURFACE', "Outside Surface", "The point is constrained to the"
  2219. " surface of the target object, with distance"
  2220. " offset always to the outside, towards or away"
  2221. " from the original location.", 3),
  2222. ('ABOVE_SURFACE', "Above Surface", "The point is constrained to the"
  2223. " surface of the target object, with distance offset "
  2224. "applied exactly along the target normal.", 4), )
  2225. class EnumShrinkwrapModeSocket(MantisSocket):
  2226. '''Shrinkwrap Mode Socket'''
  2227. bl_idname = 'EnumShrinkwrapModeSocket'
  2228. bl_label = "Shrinkwrap Mode"
  2229. default_value: bpy.props.EnumProperty(
  2230. items=eShrinkwrapMode,
  2231. description="Select how to constrain the object to the target surface",
  2232. default = 'ON_SURFACE',
  2233. update = update_socket,)
  2234. color_simple = cString
  2235. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2236. input : bpy.props.BoolProperty(default =False,)
  2237. def draw(self, context, layout, node, text):
  2238. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2239. def draw_color(self, context, node):
  2240. return self.color
  2241. @classmethod
  2242. def draw_color_simple(self):
  2243. return self.color_simple
  2244. eDataTypeMode = (
  2245. ('VECTOR', "Vector", "Vector", 0),
  2246. ('QUATERNION', "Quaternion", "", 1),
  2247. ('FLOAT4X4', "4x4 Matrix", "", 2), )
  2248. class EnumGeometryAttributeDataTypeSocket(MantisSocket):
  2249. '''Shrinkwrap Mode Socket'''
  2250. bl_idname = 'EnumGeometryAttributeDataTypeSocket'
  2251. bl_label = "Datatype"
  2252. default_value: bpy.props.EnumProperty(
  2253. items=eDataTypeMode,
  2254. description="Select the data type of the attribute",
  2255. default = 'VECTOR',
  2256. update = update_socket,)
  2257. color_simple = cString
  2258. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2259. input : bpy.props.BoolProperty(default =False,)
  2260. def draw(self, context, layout, node, text):
  2261. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2262. def draw_color(self, context, node):
  2263. return self.color
  2264. @classmethod
  2265. def draw_color_simple(self):
  2266. return self.color_simple
  2267. eDomaineMode = (
  2268. ('POINT', "Point", "Point", 0),
  2269. ('EDGE', "Edge", "Edge", 1),
  2270. ('FACE', "Face", "Face", 2),
  2271. ('FACE_CORNER', "Face Corner", "Face Corner", 3),
  2272. ('SPLINE', "Spline", "Spline", 4),
  2273. ('INSTANCE', "Instance", "Instance", 5), )
  2274. class EnumGeometryAttributeDomainSocket(MantisSocket):
  2275. '''Shrinkwrap Mode Socket'''
  2276. bl_idname = 'EnumGeometryAttributeDomainSocket'
  2277. bl_label = "Domain"
  2278. default_value: bpy.props.EnumProperty(
  2279. items=eDomaineMode,
  2280. description="Select the data type of the attribute",
  2281. default = 'POINT',
  2282. update = update_socket,)
  2283. color_simple = cString
  2284. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2285. input : bpy.props.BoolProperty(default =False,)
  2286. def draw(self, context, layout, node, text):
  2287. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2288. def draw_color(self, context, node):
  2289. return self.color
  2290. @classmethod
  2291. def draw_color_simple(self):
  2292. return self.color_simple
  2293. eMix_geometryattribute =(
  2294. ('REPLACE', "Replace (Aligned)", "Fully inherit scale"),
  2295. ('BEFORE_SPLIT', "Before (Split Channels)", "Fully inherit scale"),
  2296. ('AFTER_SPLIT', "After (Split Channels)", "Fully inherit scale"),
  2297. ('BEFORE_FULL', "Before (Full)", "Fully inherit scale"),
  2298. ('AFTER_FULL', "After (Full)", "Fully inherit scale"),)
  2299. class EnumMixModeGeometryAttribute(MantisSocket):
  2300. '''Custom node socket type'''
  2301. bl_idname = 'EnumMixModeGeometryAttribute'
  2302. bl_label = "Rotation Mix"
  2303. default_value: bpy.props.EnumProperty(
  2304. items=eMix_geometryattribute,
  2305. name="Mix Mode",
  2306. description="Mix mode",
  2307. default = 'REPLACE', #{'REPLACE'},
  2308. #options = {'ENUM_FLAG'}, # this sux
  2309. update = update_socket,)
  2310. color_simple = cString
  2311. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2312. input : bpy.props.BoolProperty(default =False,)
  2313. def draw(self, context, layout, node, text):
  2314. ChooseDraw(self, context, layout, node, text)
  2315. def draw_color(self, context, node):
  2316. return self.color
  2317. @classmethod
  2318. def draw_color_simple(self):
  2319. return self.color_simple
  2320. eSkinningMethod = (('EXISTING_GROUPS', "Use Existing Groups", "Use the existing vertex groups, or create empty groups if not found.",),
  2321. ('AUTOMATIC_HEAT', "Automatic (Heat)", "Use Blender's heatmap automatic skinning",),
  2322. ('COPY_FROM_OBJECT', "Copy from object", "Copy skin weights from the selected object"),)
  2323. class EnumSkinning(MantisSocket):
  2324. '''Custom node socket type'''
  2325. bl_idname = 'EnumSkinning'
  2326. bl_label = "Skinning Method"
  2327. default_value: bpy.props.EnumProperty(
  2328. items=eSkinningMethod,
  2329. name="Skinning Method",
  2330. description="Skinning Method",
  2331. default = 'AUTOMATIC_HEAT',
  2332. update = update_socket,)
  2333. color_simple = cString
  2334. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2335. input : bpy.props.BoolProperty(default =False,)
  2336. def draw(self, context, layout, node, text):
  2337. ChooseDraw(self, context, layout, node, text)
  2338. def draw_color(self, context, node):
  2339. return self.color
  2340. @classmethod
  2341. def draw_color_simple(self):
  2342. return self.color_simple
  2343. class MorphTargetSocket(MantisSocket):
  2344. """Morph Target"""
  2345. bl_idname = 'MorphTargetSocket'
  2346. bl_label = "Morph Target"
  2347. color_simple = cShapeKey
  2348. color : bpy.props.FloatVectorProperty(default=cShapeKey, size=4)
  2349. input : bpy.props.BoolProperty(default =False,)
  2350. is_valid_interface_type=True
  2351. def draw(self, context, layout, node, text):
  2352. ChooseDraw(self, context, layout, node, text)
  2353. def draw_color(self, context, node):
  2354. return self.color
  2355. @classmethod
  2356. def draw_color_simple(self):
  2357. return self.color_simple
  2358. eDriverVariableType = (
  2359. ( 'SINGLE_PROP',
  2360. "Property",
  2361. "Property",
  2362. 1),
  2363. ( 'LOC_DIFF',
  2364. "Distance",
  2365. "Distance",
  2366. 2),
  2367. ( 'ROTATION_DIFF',
  2368. "Rotational Difference",
  2369. "Rotational Difference",
  2370. 3),
  2371. # ( 'TRANSFORMS',
  2372. # "Transform Channel",
  2373. # "Transform Channel",
  2374. # 4),
  2375. )
  2376. class EnumDriverVariableType(MantisSocket):
  2377. '''Custom node socket type'''
  2378. bl_idname = 'EnumDriverVariableType'
  2379. bl_label = "Variable Type"
  2380. default_value: bpy.props.EnumProperty(
  2381. items = eDriverVariableType,
  2382. name = "Variable Type",
  2383. description = "Variable Type",
  2384. default = 'SINGLE_PROP',
  2385. update = driver_variable_socket_update,)
  2386. color_simple = cString
  2387. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2388. input : bpy.props.BoolProperty(default =False,)
  2389. def draw(self, context, layout, node, text):
  2390. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2391. def draw_color(self, context, node):
  2392. return self.color
  2393. @classmethod
  2394. def draw_color_simple(self):
  2395. return self.color_simple
  2396. eDriverVariableEvaluationSpace = (
  2397. ( 'WORLD_SPACE',
  2398. "World",
  2399. "World",
  2400. 1),
  2401. ( 'TRANSFORM_SPACE',
  2402. "Transform",
  2403. "Transform",
  2404. 2),
  2405. ( 'LOCAL_SPACE',
  2406. "Local",
  2407. "Local",
  2408. 3),
  2409. )
  2410. class EnumDriverVariableEvaluationSpace(MantisSocket):
  2411. '''Custom node socket type'''
  2412. bl_idname = 'EnumDriverVariableEvaluationSpace'
  2413. bl_label = "Evaluation Space"
  2414. default_value: bpy.props.EnumProperty(
  2415. items = eDriverVariableEvaluationSpace,
  2416. name = "Evaluation Space",
  2417. description = "Evaluation Space",
  2418. default = 'WORLD_SPACE',
  2419. update = driver_variable_socket_update,)
  2420. color_simple = cString
  2421. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2422. input : bpy.props.BoolProperty(default =False,)
  2423. def draw(self, context, layout, node, text):
  2424. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2425. def draw_color(self, context, node):
  2426. return self.color
  2427. @classmethod
  2428. def draw_color_simple(self):
  2429. return self.color_simple
  2430. eDriverVariableTransformChannel = (
  2431. ("LOC_X", "X Location", "The X-coordinate of an object's location.", 1),
  2432. ("LOC_Y", "Y Location", "The Y-coordinate of an object's location.", 2),
  2433. ("LOC_Z", "Z Location", "The Z-coordinate of an object's location.", 3),
  2434. ("ROT_X", "X Rotation", "Rotation X-axis.", 4),
  2435. ("ROT_Y", "Y Rotation", "Rotation Y-axis.", 5),
  2436. ("ROT_Z", "Z Rotation", "Rotation Z-axis.", 6),
  2437. ("ROT_W", "W Rotation", "Rotation W-axis.", 7),
  2438. ("SCALE_X", "X Scale", "The X-scale of an object's scale.", 8),
  2439. ("SCALE_Y", "Y Scale", "The Y-scale of an object's scale.", 9),
  2440. ("SCALE_Z", "Z Scale", "The Z-scale of an object's scale.", 10),
  2441. ("SCALE_AVG", "Average Scale", "The scale factor of an object's scale.", 11),
  2442. )
  2443. class EnumDriverVariableTransformChannel(MantisSocket):
  2444. '''Custom node socket type'''
  2445. bl_idname = 'EnumDriverVariableTransformChannel'
  2446. bl_label = "Transform Channel"
  2447. default_value: bpy.props.EnumProperty(
  2448. items = eDriverVariableTransformChannel,
  2449. name = "Transform Channel",
  2450. description = "Transform Channel",
  2451. default = 'LOC_X',
  2452. update = driver_variable_socket_update,)
  2453. color_simple = cString
  2454. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2455. input : bpy.props.BoolProperty(default =False,)
  2456. def draw(self, context, layout, node, text):
  2457. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2458. def draw_color(self, context, node):
  2459. return self.color
  2460. @classmethod
  2461. def draw_color_simple(self):
  2462. return self.color_simple
  2463. class EnumDriverRotationMode(MantisSocket):
  2464. '''Custom node socket type'''
  2465. bl_idname = 'EnumDriverRotationMode'
  2466. bl_label = "Rotaton Mode"
  2467. default_value: bpy.props.EnumProperty(
  2468. items = eRotationMode,
  2469. name = "Rotation Mode",
  2470. description = "Rotation Mode",
  2471. default = 'AUTO',
  2472. update = driver_variable_socket_update,)
  2473. color_simple = cString
  2474. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2475. input : bpy.props.BoolProperty(default =False,)
  2476. def draw(self, context, layout, node, text):
  2477. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2478. def draw_color(self, context, node):
  2479. return self.color
  2480. @classmethod
  2481. def draw_color_simple(self):
  2482. return self.color_simple
  2483. #
  2484. eDriverType = (('AVERAGE', 'Average', 'Average', 0),
  2485. ('SUM', "Sum", "Sum", 1),
  2486. ('SCRIPTED', "Scripted", "Scripted Expression", 2),
  2487. ('MIN', "Min", "Minimum", 3),
  2488. ('MAX', "Max", "Maximum", 4),)
  2489. class EnumDriverType(MantisSocket):
  2490. '''Custom node socket type'''
  2491. bl_idname = 'EnumDriverType'
  2492. bl_label = "Driver Type"
  2493. default_value: bpy.props.EnumProperty(
  2494. items = eDriverType,
  2495. name = "Driver Type",
  2496. description = "Driver Type",
  2497. default = 'AVERAGE',
  2498. update = driver_socket_update,)
  2499. color_simple = cString
  2500. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2501. input : bpy.props.BoolProperty(default =False,)
  2502. def draw(self, context, layout, node, text):
  2503. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2504. def draw_color(self, context, node):
  2505. return self.color
  2506. @classmethod
  2507. def draw_color_simple(self):
  2508. return self.color_simple
  2509. # Keyframe
  2510. # Enum for kf handle type
  2511. # enum for interpolation type
  2512. # eventually gonna make it to the fancy stuff
  2513. class FloatSocket(MantisSocket):
  2514. """Float Input socket"""
  2515. bl_idname = 'FloatSocket'
  2516. bl_label = "Float"
  2517. is_valid_interface_type=True
  2518. default_value : bpy.props.FloatProperty(default = 0.0, update = update_socket,)
  2519. color_simple = cFloat
  2520. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  2521. input : bpy.props.BoolProperty(default =False,)
  2522. def draw(self, context, layout, node, text):
  2523. ChooseDraw(self, context, layout, node, text)
  2524. def draw_color(self, context, node):
  2525. return self.color
  2526. @classmethod
  2527. def draw_color_simple(self):
  2528. return self.color_simple
  2529. class FloatPositiveSocket(MantisSocket):
  2530. """Float Input socket"""
  2531. bl_idname = 'FloatPositiveSocket'
  2532. bl_label = "Float (Positive)"
  2533. is_valid_interface_type=True
  2534. default_value : bpy.props.FloatProperty(default = 0.0, min=0, update = update_socket,)
  2535. color_simple = cFloat
  2536. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  2537. input : bpy.props.BoolProperty(default =False,)
  2538. def draw(self, context, layout, node, text):
  2539. ChooseDraw(self, context, layout, node, text)
  2540. def draw_color(self, context, node):
  2541. return self.color
  2542. @classmethod
  2543. def draw_color_simple(self):
  2544. return self.color_simple
  2545. class FloatFactorSocket(MantisSocket):
  2546. '''xFrom Input Output'''
  2547. bl_idname = 'FloatFactorSocket'
  2548. bl_label = "Float (Factor)"
  2549. is_valid_interface_type=True
  2550. default_value : bpy.props.FloatProperty(
  2551. default = 0.0,
  2552. min = 0.0,
  2553. max=1.0,
  2554. update = update_socket,
  2555. subtype='FACTOR',)
  2556. color_simple = cFloat
  2557. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  2558. input : bpy.props.BoolProperty(default =False,)
  2559. def draw(self, context, layout, node, text):
  2560. ChooseDraw(self, context, layout, node, text)
  2561. def draw_color(self, context, node):
  2562. return self.color
  2563. @classmethod
  2564. def draw_color_simple(self):
  2565. return self.color_simple
  2566. class FloatAngleSocket(MantisSocket):
  2567. '''xFrom Input Output'''
  2568. bl_idname = 'FloatAngleSocket'
  2569. bl_label = "Float (Angle)"
  2570. is_valid_interface_type=True
  2571. default_value : bpy.props.FloatProperty(
  2572. default = 0.0,
  2573. min = -180,
  2574. max=180,
  2575. update = update_socket,
  2576. subtype='ANGLE',)
  2577. color_simple = cFloat
  2578. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  2579. input : bpy.props.BoolProperty(default =False,)
  2580. def draw(self, context, layout, node, text):
  2581. ChooseDraw(self, context, layout, node, text)
  2582. def draw_color(self, context, node):
  2583. return self.color
  2584. @classmethod
  2585. def draw_color_simple(self):
  2586. return self.color_simple
  2587. class VectorSocket(MantisSocket):
  2588. """Vector Input socket"""
  2589. bl_idname = 'VectorSocket'
  2590. bl_label = "Vector"
  2591. is_valid_interface_type=True
  2592. default_value : bpy.props.FloatVectorProperty(
  2593. default = (0.0, 0.0, 0.0),
  2594. update = update_socket,)
  2595. color_simple = cVector
  2596. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  2597. input : bpy.props.BoolProperty(default =False,)
  2598. def draw(self, context, layout, node, text):
  2599. ChooseDraw(self, context, layout, node, text)
  2600. def draw_color(self, context, node):
  2601. return self.color
  2602. @classmethod
  2603. def draw_color_simple(self):
  2604. return self.color_simple
  2605. class VectorEulerSocket(MantisSocket):
  2606. """Vector Input socket"""
  2607. bl_idname = 'VectorEulerSocket'
  2608. bl_label = "Euler"
  2609. is_valid_interface_type=True
  2610. default_value : bpy.props.FloatVectorProperty(
  2611. default = (0.0, 0.0, 0.0),
  2612. update = update_socket,
  2613. subtype='EULER',)
  2614. color_simple = cVector
  2615. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  2616. input : bpy.props.BoolProperty(default =False,)
  2617. def draw(self, context, layout, node, text):
  2618. ChooseDraw(self, context, layout, node, text)
  2619. def draw_color(self, context, node):
  2620. return self.color
  2621. @classmethod
  2622. def draw_color_simple(self):
  2623. return self.color_simple
  2624. class VectorTranslationSocket(MantisSocket):
  2625. """Vector Input socket"""
  2626. bl_idname = 'VectorTranslationSocket'
  2627. bl_label = "Vector (Translation)"
  2628. default_value : bpy.props.FloatVectorProperty(
  2629. default = (0.0, 0.0, 0.0),
  2630. update = update_socket,
  2631. subtype='TRANSLATION',)
  2632. color_simple = cVector
  2633. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  2634. input : bpy.props.BoolProperty(default =False,)
  2635. def draw(self, context, layout, node, text):
  2636. ChooseDraw(self, context, layout, node, text)
  2637. def draw_color(self, context, node):
  2638. return self.color
  2639. @classmethod
  2640. def draw_color_simple(self):
  2641. return self.color_simple
  2642. class VectorScaleSocket(MantisSocket):
  2643. """Vector Input socket"""
  2644. bl_idname = 'VectorScaleSocket'
  2645. bl_label = "Vector (Scale)"
  2646. default_value : bpy.props.FloatVectorProperty(
  2647. default = (1.0, 1.0, 1.0),
  2648. update = update_socket,
  2649. subtype='XYZ',)
  2650. color_simple = cVector
  2651. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  2652. input : bpy.props.BoolProperty(default =False,)
  2653. def draw(self, context, layout, node, text):
  2654. ChooseDraw(self, context, layout, node, text)
  2655. def draw_color(self, context, node):
  2656. return self.color
  2657. @classmethod
  2658. def draw_color_simple(self):
  2659. return self.color_simple
  2660. class KeyframeSocket(MantisSocket):
  2661. '''Keyframe'''
  2662. bl_idname = 'KeyframeSocket'
  2663. bl_label = "Keyframe"
  2664. is_valid_interface_type=True
  2665. color_simple = cKeyframe
  2666. color : bpy.props.FloatVectorProperty(default=cKeyframe, size=4)
  2667. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2668. def init(self):
  2669. self.display_shape = 'CIRCLE_DOT'
  2670. def draw(self, context, layout, node, text):
  2671. ChooseDraw(self, context, layout, node, text)
  2672. def draw_color(self, context, node):
  2673. return self.color
  2674. @classmethod
  2675. def draw_color_simple(self):
  2676. return self.color_simple
  2677. EnumKeyframeInterpolationType = (('CONSTANT', 'Stepped', 'Stepped'),
  2678. ('LINEAR', "Linear", "Linear"),
  2679. ('BEZIER', "Bezier", "Bezier"),)
  2680. class EnumKeyframeInterpolationTypeSocket(MantisSocket):
  2681. '''Keyframe Interpolation Type'''
  2682. bl_idname = 'EnumKeyframeInterpolationTypeSocket'
  2683. bl_label = "Keyframe Interpolation Type"
  2684. default_value :bpy.props.EnumProperty(
  2685. name="",
  2686. description="Interpolation",
  2687. items=EnumKeyframeInterpolationType,
  2688. default='LINEAR',
  2689. update = update_socket,)
  2690. color_simple = cString
  2691. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2692. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2693. def draw(self, context, layout, node, text):
  2694. ChooseDraw(self, context, layout, node, text)
  2695. def draw_color(self, context, node):
  2696. return self.color
  2697. @classmethod
  2698. def draw_color_simple(self):
  2699. return self.color_simple
  2700. EnumKeyframeBezierHandleType = (('FREE', 'Free', 'Completely independent manually set handle.'),
  2701. ('ALIGNED', "Aligned", "Manually set handle with rotation locked together with its pair."),
  2702. ('VECTOR', "Vector", "Automatic handles that create straight lines."),
  2703. ('AUTO', "Automatic", "Automatic handles that create smooth curves."),
  2704. ('AUTO_CLAMPED', "Auto Clamped", "Automatic handles that create smooth curves which only change direction at keyframes."),)
  2705. class EnumKeyframeBezierHandleTypeSocket(MantisSocket):
  2706. '''Keyframe Bezier Handle Type'''
  2707. bl_idname = 'EnumKeyframeBezierHandleTypeSocket'
  2708. bl_label = "Keyframe Bezier Handle Type"
  2709. default_value :bpy.props.EnumProperty(
  2710. name="",
  2711. description="Handle Type",
  2712. items=EnumKeyframeBezierHandleType,
  2713. default='AUTO_CLAMPED',
  2714. update = update_socket,)
  2715. color_simple = cString
  2716. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2717. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2718. def draw(self, context, layout, node, text):
  2719. ChooseDraw(self, context, layout, node, text)
  2720. def draw_color(self, context, node):
  2721. return self.color
  2722. @classmethod
  2723. def draw_color_simple(self):
  2724. return self.color_simple
  2725. enumExtrapolationMode = (('CONSTANT', 'Constant', 'Constant'),
  2726. ('LINEAR', "Linear", "Linear"),)
  2727. class eFCrvExtrapolationMode(MantisSocket):
  2728. '''FCurve Extrapolation Mode'''
  2729. bl_idname = 'eFCrvExtrapolationMode'
  2730. bl_label = "Extrapolation Mode"
  2731. default_value :bpy.props.EnumProperty(
  2732. name="",
  2733. description="Handle Type",
  2734. items=enumExtrapolationMode,
  2735. default='CONSTANT',
  2736. update = update_socket,)
  2737. color_simple = cString
  2738. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2739. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2740. def draw(self, context, layout, node, text):
  2741. ChooseDraw(self, context, layout, node, text)
  2742. def draw_color(self, context, node):
  2743. return self.color
  2744. @classmethod
  2745. def draw_color_simple(self):
  2746. return self.color_simple
  2747. EnumLatticeInterpolationType = (('KEY_LINEAR', 'Linear', 'Linear Interpolation.'),
  2748. ('KEY_CARDINAL', "Cardinal", "Cardinal Interpolation."),
  2749. ('KEY_CATMULL_ROM', "Catmull Rom", "Catmull Rom Interpolation."),
  2750. ('KEY_BSPLINE', "B-Spline", "B Spline Interpolation."),)
  2751. class EnumLatticeInterpolationTypeSocket(MantisSocket):
  2752. '''Lattice Interpolation Type'''
  2753. bl_idname = 'EnumLatticeInterpolationTypeSocket'
  2754. bl_label = "Lattice Interpolation Type"
  2755. default_value :bpy.props.EnumProperty(
  2756. name="",
  2757. description="Interpolation Type",
  2758. items=EnumLatticeInterpolationType,
  2759. default='KEY_BSPLINE',
  2760. update = update_socket,)
  2761. color_simple = cString
  2762. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2763. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2764. def draw(self, context, layout, node, text):
  2765. ChooseDraw(self, context, layout, node, text)
  2766. def draw_color(self, context, node):
  2767. return self.color
  2768. @classmethod
  2769. def draw_color_simple(self):
  2770. return self.color_simple
  2771. EnumCorrectiveSmoothType = (('SIMPLE', 'Simple', 'Use the average of adjacent edge-vertices.'),
  2772. ('LENGTH_WEIGHTED', "Length Weight", "Use the average of adjacent"
  2773. "edge-vertices weighted by their length."),)
  2774. class EnumCorrectiveSmoothTypeSocket(MantisSocket):
  2775. '''Lattice Interpolation Type'''
  2776. bl_idname = 'EnumCorrectiveSmoothTypeSocket'
  2777. bl_label = "Lattice Interpolation Type"
  2778. default_value :bpy.props.EnumProperty(
  2779. name="",
  2780. description="Interpolation Type",
  2781. items=EnumCorrectiveSmoothType,
  2782. default='SIMPLE',
  2783. update = update_socket,)
  2784. color_simple = cString
  2785. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2786. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2787. def draw(self, context, layout, node, text):
  2788. ChooseDraw(self, context, layout, node, text)
  2789. def draw_color(self, context, node):
  2790. return self.color
  2791. @classmethod
  2792. def draw_color_simple(self):
  2793. return self.color_simple
  2794. enumFloatOperations = (('ADD', 'Add', 'Add'),
  2795. ('SUBTRACT', "Subtract", "Subtract"),
  2796. ('MULTIPLY', "Multiply", "Multiply"),
  2797. ('DIVIDE', "Divide", "Divide"),
  2798. ('POWER', "Power", "Power"),
  2799. ('FLOOR_DIVIDE', "Floor Divide", "Floor Divide"),
  2800. ('MODULUS', "Modulus", "Modulus"),
  2801. ('ABSOLUTE', "Absolute", "Absolute Value"),
  2802. ('MAXIMUM', "Maximum", "Maximum"),
  2803. ('MINIMUM', "Minimum", "Minimum"),
  2804. ('GREATER THAN', "Greater Than", "Greater Than"),
  2805. ('LESS THAN', "Less Than", "Less Than"),
  2806. ('ARCTAN2', "atan2", "2-argument arctan function"),
  2807. ('FLOOR', "Floor", "the nearest integer lower than input A"),
  2808. ('CEIL', "Ceiling", "the next integer higher than input A"),
  2809. ('ROUND', "Round", "Round to the nearest integer"),)
  2810. class MathFloatOperation(MantisSocket):
  2811. """Float Math Operation"""
  2812. bl_idname = 'MathFloatOperation'
  2813. bl_label = "Operation"
  2814. default_value :bpy.props.EnumProperty(
  2815. name="",
  2816. description="Operation",
  2817. items=enumFloatOperations,
  2818. default='MULTIPLY',
  2819. update = update_socket,)
  2820. color_simple = cString
  2821. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2822. input : bpy.props.BoolProperty(default =False,)
  2823. def draw(self, context, layout, node, text):
  2824. ChooseDraw(self, context, layout, node, text)
  2825. def draw_color(self, context, node):
  2826. return self.color
  2827. @classmethod
  2828. def draw_color_simple(self):
  2829. return self.color_simple
  2830. enumVectorOperations = (('ADD', 'Add', 'Add (Component-wise)'),
  2831. ('SUBTRACT', "Subtract", "Subtract (Component-wise)"),
  2832. ('MULTIPLY', "Multiply", "Multiply (Component-wise)"),
  2833. ('SCALE', "Scale", "Scales vector by input float or average magnitude of input vector's components."),
  2834. ('DIVIDE', "Divide", "Divide (Component-wise)"),
  2835. ('POWER', "Power", "Power (Component-wise)"),
  2836. ('LENGTH', "Length", "Length"),
  2837. ('CROSS', "Cross Product", "Cross product of A X B"),
  2838. ('NORMALIZE', "Normalize", "Returns a normalized vector."),
  2839. ('DOT', "Dot Product", "Dot product of A . B"),
  2840. ('LINEAR_INTERP', "Linear Interpolation", "Linear Interpolation between vectors A and B by factor"))
  2841. class MathVectorOperation(MantisSocket):
  2842. """Vector Math Operation"""
  2843. bl_idname = 'MathVectorOperation'
  2844. bl_label = "Operation"
  2845. default_value :bpy.props.EnumProperty(
  2846. name="",
  2847. description="Operation",
  2848. items=enumVectorOperations,
  2849. default='MULTIPLY',
  2850. update = update_socket,)
  2851. color_simple = cString
  2852. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2853. input : bpy.props.BoolProperty(default =False,)
  2854. def draw(self, context, layout, node, text):
  2855. ChooseDraw(self, context, layout, node, text)
  2856. def draw_color(self, context, node):
  2857. return self.color
  2858. @classmethod
  2859. def draw_color_simple(self):
  2860. return self.color_simple
  2861. enumMatrixTransform = (('TRANSLATE', 'Translate', 'Translate'),
  2862. ('ROTATE_AXIS_ANGLE', "Rotate (Axis-angle)", "Rotates a number of radians around an axis"),
  2863. # ('ROTATE_EULER', "Rotate (Euler)", "Euler Rotation"),
  2864. # ('ROTATE_QUATERNION', "Rotate (Quaternion)", "Quaternion Rotation"),
  2865. ('SCALE', "Scale", "Scale"),)
  2866. class MatrixTransformOperation(MantisSocket):
  2867. """Matrix Transform Operation"""
  2868. bl_idname = 'MatrixTransformOperation'
  2869. bl_label = "Operation"
  2870. default_value :bpy.props.EnumProperty(
  2871. name="",
  2872. description="Operation",
  2873. items=enumMatrixTransform,
  2874. default='TRANSLATE',
  2875. update = update_socket,)
  2876. color_simple = cString
  2877. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2878. input : bpy.props.BoolProperty(default =False,)
  2879. def draw(self, context, layout, node, text):
  2880. ChooseDraw(self, context, layout, node, text)
  2881. def draw_color(self, context, node):
  2882. return self.color
  2883. @classmethod
  2884. def draw_color_simple(self):
  2885. return self.color_simple
  2886. enumIntOperations = (('ADD', 'Add', 'Add'),
  2887. ('SUBTRACT', "Subtract", "Subtract"),
  2888. ('MULTIPLY', "Multiply", "Multiply"),
  2889. ('FLOOR_DIVIDE', "Floor Divide", "Floor Divide"),
  2890. ('POWER', "Power", "Power"),
  2891. ('MODULUS', "Modulus", "Modulus"),
  2892. ('ABSOLUTE', "Absolute", "Absolute Value"),
  2893. ('MAXIMUM', "Maximum", "Maximum"),
  2894. ('MINIMUM', "Minimum", "Minimum"),
  2895. ('GREATER THAN', "Greater Than", "Greater Than"),
  2896. ('LESS THAN', "Less Than", "Less Than"),)
  2897. class MathIntOperation(MantisSocket):
  2898. """Int Math Operation"""
  2899. bl_idname = 'MathIntOperation'
  2900. bl_label = "Operation"
  2901. default_value :bpy.props.EnumProperty(
  2902. name="",
  2903. description="Operation",
  2904. items=enumIntOperations,
  2905. default='MULTIPLY',
  2906. update = update_socket,)
  2907. color_simple = cString
  2908. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2909. input : bpy.props.BoolProperty(default =False,)
  2910. def draw(self, context, layout, node, text):
  2911. ChooseDraw(self, context, layout, node, text)
  2912. def draw_color(self, context, node):
  2913. return self.color
  2914. @classmethod
  2915. def draw_color_simple(self):
  2916. return self.color_simple
  2917. enumCompareOperations = (('EQUAL', "Equal", "Equal"),
  2918. ('NOT_EQUAL', "Not Equal", "Not Equal"),
  2919. ('GREATER_THAN', "Greater Than", "Greater Than"),
  2920. ('GREATER_THAN_EQUAL', "Greater Than or Equal", "Greater Than or Equal"),
  2921. ('LESS_THAN', "Less Than", "Less Than"),
  2922. ('LESS_THAN_EQUAL', "Equal or Less Than", "Equal or Less Than"),)
  2923. class EnumCompareOperation(MantisSocket):
  2924. """Compare Operation"""
  2925. bl_idname = 'EnumCompareOperation'
  2926. bl_label = "Comparison"
  2927. default_value :bpy.props.EnumProperty(
  2928. name="",
  2929. description="Comparison",
  2930. items=enumCompareOperations,
  2931. default='EQUAL',
  2932. update = update_socket,)
  2933. color_simple = cString
  2934. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2935. input : bpy.props.BoolProperty(default =False,)
  2936. def draw(self, context, layout, node, text):
  2937. ChooseDraw(self, context, layout, node, text)
  2938. def draw_color(self, context, node):
  2939. return self.color
  2940. @classmethod
  2941. def draw_color_simple(self):
  2942. return self.color_simple
  2943. class WildcardSocket(MantisSocket):
  2944. """Some kind of node socket lol I donno"""
  2945. bl_idname = 'WildcardSocket'
  2946. bl_label = ""
  2947. color_simple = (0.0,0.0,0.0,0.0)
  2948. color : bpy.props.FloatVectorProperty(default=(0.0,0.0,0.0,0.0), size=4)
  2949. input : bpy.props.BoolProperty(default =False,)
  2950. def draw(self, context, layout, node, text):
  2951. ChooseDraw(self, context, layout, node, text)
  2952. def draw_color(self, context, node):
  2953. return self.color
  2954. @classmethod
  2955. def draw_color_simple(self):
  2956. return self.color_simple