socket_definitions.py 113 KB

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