Skip to content

Commit

Permalink
Clean up PR
Browse files Browse the repository at this point in the history
  • Loading branch information
lasa01 committed Jun 23, 2024
1 parent 110b869 commit 4d96bea
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 14 deletions.
6 changes: 3 additions & 3 deletions plumber/asset/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def import_light(light: Light, collection: Collection) -> None:
collection.objects.link(obj)

obj.location = light.position()
obj['props'] = light.properties()
obj["props"] = light.properties()


def import_spot_light(light: SpotLight, collection: Collection) -> None:
Expand All @@ -34,7 +34,7 @@ def import_spot_light(light: SpotLight, collection: Collection) -> None:

obj.location = light.position()
obj.rotation_euler = light.rotation()
obj['props'] = light.properties()
obj["props"] = light.properties()


def import_env_light(light: EnvLight, context: Context, collection: Collection) -> None:
Expand All @@ -48,7 +48,7 @@ def import_env_light(light: EnvLight, context: Context, collection: Collection)

obj = bpy.data.objects.new(name, object_data=light_data)
collection.objects.link(obj)
obj['props'] = light.properties()
obj["props"] = light.properties()

obj.location = light.position()
obj.rotation_euler = light.rotation()
Expand Down
3 changes: 1 addition & 2 deletions plumber/asset/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ def import_material(material: Material) -> None:
material_data = bpy.data.materials.get(material_name)
if material_data is None:
material_data = bpy.data.materials.new(material_name)

material_data['path_id'] = material.name()
material_data["path_id"] = material.name()

material_data.use_nodes = True
nt = material_data.node_tree
Expand Down
4 changes: 2 additions & 2 deletions plumber/asset/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def import_model(self, model: Model, collection: Collection) -> None:
material_data = bpy.data.materials.get(material)
if material_data is None:
material_data = bpy.data.materials.new(material)
material_data['path_id'] = material_original_name
material_data["path_id"] = material_original_name
bl_materials.append(material_data)

meshes = model.meshes()
Expand Down Expand Up @@ -161,7 +161,7 @@ def import_mesh(
mesh_data.clear_geometry()
mesh_data.materials.clear()

mesh_data['path_id'] = mesh_name
mesh_data["path_id"] = mesh_name

polygons_len = mesh.polygons_len()

Expand Down
4 changes: 2 additions & 2 deletions plumber/asset/prop.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def import_prop(
) -> None:
model_name = prop.model()
obj = model_tracker.get_model_copy(model_name, collection)
obj['path_id'] = model_name
obj['props'] = prop.properties()
obj["path_id"] = model_name
obj["props"] = prop.properties()

name = f"{prop.class_name()}_{prop.id()}"

Expand Down
2 changes: 1 addition & 1 deletion plumber/asset/unknown_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ def import_unknown_entity(entity: UnknownEntity, collection: Collection) -> None
obj.location = entity.position()
obj.rotation_euler = entity.rotation()
obj.scale = entity.scale()
obj['props'] = entity.properties()
obj["props"] = entity.properties()

collection.objects.link(obj)
3 changes: 2 additions & 1 deletion plumber/asset/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from base64 import urlsafe_b64encode
from posixpath import split, splitext
from typing import Optional
import bpy, os
import bpy

_HASH_LEN = 6
_B64_LEN = 8
Expand All @@ -13,6 +13,7 @@ def _hashed(s: str) -> str:
:_B64_LEN
].decode("ascii")


def truncate_name(name: str, maxlen: int = 59) -> str:
name = name.replace("\\", "/").strip("/")
if len(name) <= maxlen:
Expand Down
5 changes: 5 additions & 0 deletions plumber/plumber.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class LoadedProp:
def rotation(self) -> List[float]: ...
def scale(self) -> List[float]: ...
def color(self) -> List[float]: ...
def properties(self) -> Dict[str, str]: ...

class QuaternionData:
def x_points(self) -> List[float]: ...
Expand Down Expand Up @@ -190,6 +191,7 @@ class Light:
def position(self) -> List[float]: ...
def color(self) -> List[float]: ...
def energy(self) -> float: ...
def properties(self) -> Dict[str, str]: ...

class SpotLight:
def id(self) -> int: ...
Expand All @@ -199,6 +201,7 @@ class SpotLight:
def energy(self) -> float: ...
def spot_size(self) -> float: ...
def spot_blend(self) -> float: ...
def properties(self) -> Dict[str, str]: ...

class EnvLight:
def id(self) -> int: ...
Expand All @@ -209,6 +212,7 @@ class EnvLight:
def ambient_color(self) -> List[float]: ...
def ambient_strength(self) -> float: ...
def angle(self) -> float: ...
def properties(self) -> Dict[str, str]: ...

class SkyCamera:
def id(self) -> int: ...
Expand All @@ -221,6 +225,7 @@ class UnknownEntity:
def position(self) -> List[float]: ...
def rotation(self) -> List[float]: ...
def scale(self) -> List[float]: ...
def properties(self) -> Dict[str, str]: ...

class Importer:
def __init__(
Expand Down
7 changes: 4 additions & 3 deletions src/asset/entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,13 @@ impl PyLoadedProp {
pub fn new(prop: LoadedProp) -> Self {
let rotation = prop.rotation;
let properties = prop
.prop.entity()
.prop
.entity()
.properties
.iter()
.map(|(k, v)| (k.as_str().to_owned(), v.clone()))
.collect();

Self {
model: prop.model_path.into_string(),
class_name: prop.prop.entity().class_name.clone(),
Expand Down Expand Up @@ -195,7 +196,6 @@ pub struct PySpotLight {
rotation: [f32; 3],
pub id: i32,
properties: BTreeMap<String, String>,

}

#[pymethods]
Expand Down Expand Up @@ -263,6 +263,7 @@ impl PySpotLight {
.iter()
.map(|(k, v)| (k.as_str().to_owned(), v.clone()))
.collect();

Ok(Self {
color: color.map(|c| srgb_to_linear(f32::from(c) / 255.)).into(),
energy: brightness * settings.light_factor,
Expand Down

0 comments on commit 4d96bea

Please sign in to comment.