socket_definitions.py 119 KB

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