socket_definitions.py 126 KB

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