socket_definitions.py 113 KB

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