socket_definitions.py 113 KB

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