Skip to content

Commit

Permalink
(geometry) moving core types into utils
Browse files Browse the repository at this point in the history
  • Loading branch information
snake-biscuits committed Jan 5, 2024
1 parent ffd4ae5 commit 2f597f2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions bsp_tool/extensions/geometry/brushwork.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import List

from ...utils import geometry
# from ...utils import physics
from ..editor import generic
from . import base


def polygons_of(brush: generic.Brush) -> List[base.Polygon]:
def polygons_of(brush: generic.Brush) -> List[geometry.Polygon]:
# generate a Polygon for each Plane, such that they can be zipped
raise NotImplementedError()
# generic.Brush(...).as_physics() # calculate AABB
Expand Down
3 changes: 2 additions & 1 deletion bsp_tool/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
__all__ = ["physics", "texture", "vector"]
__all__ = ["geometry", "physics", "texture", "vector"]

from . import geometry
from . import physics
from . import texture
from . import vector
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations
from typing import List

from ...utils import vector
from . import vector


# TODO: Mesh, Material, Model
Expand All @@ -15,6 +15,15 @@ class Vertex:
# uv[0] = albedo
# uv[1] = lightmap

def __init__(self, position, normal, *uvs):
self.position = position
self.normal = normal
self.uv = uvs

def __repr__(self) -> str:
args = ", ".join([self.position, self.normal, *self.uv])
return f"{self.__class__.__name__}({args})"


class Polygon:
vertices: List[Vertex]
Expand All @@ -27,6 +36,9 @@ def __init__(self, vertices: List[Vertex]):
def __iter__(self):
return iter(self.vertices)

def __repr__(self) -> str:
return f"{self.__class__.__name__}({self.vertices!r})"

@property
def normal(self) -> vector.vec3:
return [v.normal for v in self.vertices] / len(self.vertices)
Expand Down

0 comments on commit 2f597f2

Please sign in to comment.