feat: Added accel socket, fixed default units.

blender-plugin-mvp
Sofus Albert Høgsbro Rose 2024-02-19 16:03:32 +01:00
parent de8d64b5b3
commit 586d6fa74b
Signed by: so-rose
GPG Key ID: AD901CB0F3701434
2 changed files with 28 additions and 5 deletions

View File

@ -221,7 +221,7 @@ SocketType_to_units = {
}, },
SocketType.PhysicalMass: { SocketType.PhysicalMass: {
"default": "UM", "default": "UG",
"values": { "values": {
"E_REST": spu.electron_rest_mass, "E_REST": spu.electron_rest_mass,
"DAL": spu.dalton, "DAL": spu.dalton,
@ -234,7 +234,7 @@ SocketType_to_units = {
}, },
SocketType.PhysicalSpeed: { SocketType.PhysicalSpeed: {
"default": "UM", "default": "UM_S",
"values": { "values": {
"PM_S": spu.picometer / spu.second, "PM_S": spu.picometer / spu.second,
"NM_S": spu.nanometer / spu.second, "NM_S": spu.nanometer / spu.second,
@ -248,7 +248,7 @@ SocketType_to_units = {
}, },
}, },
SocketType.PhysicalAccel: { SocketType.PhysicalAccel: {
"default": "UM", "default": "UM_S_SQ",
"values": { "values": {
"PM_S_SQ": spu.picometer / spu.second**2, "PM_S_SQ": spu.picometer / spu.second**2,
"NM_S_SQ": spu.nanometer / spu.second**2, "NM_S_SQ": spu.nanometer / spu.second**2,

View File

@ -1,5 +1,6 @@
import typing as typ import typing as typ
import bpy
import pydantic as pyd import pydantic as pyd
from .. import base from .. import base
@ -11,17 +12,39 @@ from ... import contracts
class PhysicalAccelBLSocket(base.BLSocket): class PhysicalAccelBLSocket(base.BLSocket):
socket_type = contracts.SocketType.PhysicalAccel socket_type = contracts.SocketType.PhysicalAccel
bl_label = "PhysicalAccel" bl_label = "PhysicalAccel"
use_units = True
####################
# - Properties
####################
raw_value: bpy.props.FloatProperty(
name="Unitless Acceleration",
description="Represents the unitless part of the acceleration",
default=0.0,
precision=6,
)
####################
# - Socket UI
####################
def draw_label_row(self, label_col_row: bpy.types.UILayout, text: str) -> None:
label_col_row.label(text=text)
label_col_row.prop(self, "raw_unit", text="")
def draw_value(self, col: bpy.types.UILayout) -> None:
col_row = col.row(align=True)
col_row.prop(self, "raw_value", text="")
#################### ####################
# - Default Value # - Default Value
#################### ####################
@property @property
def default_value(self) -> None: def default_value(self) -> None:
pass return self.raw_value * self.unit
@default_value.setter @default_value.setter
def default_value(self, value: typ.Any) -> None: def default_value(self, value: typ.Any) -> None:
pass self.raw_value = self.value_as_unit(value)
#################### ####################
# - Socket Configuration # - Socket Configuration