pub struct Surface {
pub id: Uuid,
pub sector_id: u32,
pub plane: Plane,
pub frame: Basis3,
pub edit_uv: EditPlane,
pub extrusion: ExtrusionSpec,
pub profile: Option<Uuid>,
pub organic_layers: IndexMap<Uuid, OrganicVolumeLayer>,
pub organic_vine_strokes: Vec<OrganicVineStroke>,
pub organic_bush_clusters: Vec<OrganicBushCluster>,
pub world_vertices: Vec<Vec3<f32>>,
}Expand description
Represents a surface with the sector owner, geometry, and profile.
Fields§
§id: Uuid§sector_id: u32§plane: PlaneGeometric frame of the editable plane for this surface
frame: Basis3§edit_uv: EditPlane§extrusion: ExtrusionSpecExtrusion parameters for this surface (depth, caps, UVs).
profile: Option<Uuid>Uuid of the Profile
organic_layers: IndexMap<Uuid, OrganicVolumeLayer>Surface-local organic paint volumes authored on top of this surface.
organic_vine_strokes: Vec<OrganicVineStroke>Surface-local vine strokes authored on top of this surface.
organic_bush_clusters: Vec<OrganicBushCluster>Surface-local bush foliage clusters authored on top of this surface.
world_vertices: Vec<Vec3<f32>>Optional, the vertices of the surface in world coordinates, used in cases where we need to pass standalone surfaces.
Implementations§
Source§impl Surface
impl Surface
pub fn new(sector_id: u32) -> Surface
pub fn extrusion_offsets(&self) -> (f32, f32)
pub fn main_organic_layer_mut(&mut self) -> &mut OrganicVolumeLayer
pub fn organic_layer_for_cell_size_mut( &mut self, cell_size: f32, ) -> &mut OrganicVolumeLayer
Sourcepub fn calculate_geometry(&mut self, map: &Map)
pub fn calculate_geometry(&mut self, map: &Map)
Calculate the geometry
Sourcepub fn uv_to_world(&self, uv: Vec2<f32>) -> Vec3<f32>
pub fn uv_to_world(&self, uv: Vec2<f32>) -> Vec3<f32>
Map a UV point on the surface plane to world space (w = 0 plane).
Sourcepub fn uvw_to_world(&self, uv: Vec2<f32>, w: f32) -> Vec3<f32>
pub fn uvw_to_world(&self, uv: Vec2<f32>, w: f32) -> Vec3<f32>
Map a UVW point (UV on the surface, W along the surface normal) to world space.
pub fn world_to_uv(&self, p: Vec3<f32>) -> Vec2<f32>
Sourcepub fn sector_uv_min(&self, map: &Map) -> Option<Vec2<f32>>
pub fn sector_uv_min(&self, map: &Map) -> Option<Vec2<f32>>
Compute the minimum UV of the owning sector projected onto this surface. Used to rebase tile coordinates to a sector-local 0..N space.
Sourcepub fn tile_local_anchor_uv(&self, map: &Map) -> Vec2<f32>
pub fn tile_local_anchor_uv(&self, map: &Map) -> Vec2<f32>
Anchor UV for tile-local mapping. For wall-like surfaces, use a world-anchored UV origin to keep painting stable across inside/outside and adjacent coplanar surfaces. For floor/ceiling-like surfaces, keep sector-local behavior.
Sourcepub fn tile_local_flip_x(&self) -> bool
pub fn tile_local_flip_x(&self) -> bool
Returns true if tile-local X should be mirrored for this surface to keep wall painting orientation stable independent of wall normal direction.
Sourcepub fn uv_to_tile_local(&self, uv: Vec2<f32>, map: &Map) -> Vec2<f32>
pub fn uv_to_tile_local(&self, uv: Vec2<f32>, map: &Map) -> Vec2<f32>
Convert UV to continuous tile-local coordinates.
Sourcepub fn tile_local_to_uv(&self, local: Vec2<f32>, map: &Map) -> Vec2<f32>
pub fn tile_local_to_uv(&self, local: Vec2<f32>, map: &Map) -> Vec2<f32>
Convert continuous tile-local coordinates back to UV.
Sourcepub fn world_to_tile(&self, p: Vec3<f32>) -> (i32, i32)
pub fn world_to_tile(&self, p: Vec3<f32>) -> (i32, i32)
Map a world point to discrete tile coordinates (1x1 grid cells in UV space). Returns (tile_x, tile_y) representing which tile cell the point falls into. This is useful for tile override systems that assign different tiles to different regions.
Sourcepub fn world_to_tile_local(&self, p: Vec3<f32>, map: &Map) -> (i32, i32)
pub fn world_to_tile_local(&self, p: Vec3<f32>, map: &Map) -> (i32, i32)
Map a world point to sector-local tile coordinates. Tile (0,0) starts at the minimum projected UV of this sector.
Sourcepub fn tile_outline_world(&self, tile: (i32, i32)) -> [Vec3<f32>; 4]
pub fn tile_outline_world(&self, tile: (i32, i32)) -> [Vec3<f32>; 4]
Get the four world-space corners of a 1x1 tile cell at the given tile coordinates. Corners are ordered around the cell starting at (tile_x, tile_y) and proceeding CCW.
Sourcepub fn tile_outline_world_local(
&self,
tile: (i32, i32),
map: &Map,
) -> [Vec3<f32>; 4]
pub fn tile_outline_world_local( &self, tile: (i32, i32), map: &Map, ) -> [Vec3<f32>; 4]
Get the world-space corners of a sector-local tile cell. Tile (0,0) starts at the minimum projected UV of this sector.
Sourcepub fn sector_loop_uv(&self, map: &Map) -> Option<Vec<Vec2<f32>>>
pub fn sector_loop_uv(&self, map: &Map) -> Option<Vec<Vec2<f32>>>
Project the owning sector polygon into this surface’s UV space (CCW ensured).
Sourcepub fn triangulate_cap_with_holes(
&self,
outer_uv: &[Vec2<f32>],
holes_uv: &[Vec<Vec2<f32>>],
) -> Option<(Vec<[f32; 4]>, Vec<(usize, usize, usize)>, Vec<[f32; 2]>)>
pub fn triangulate_cap_with_holes( &self, outer_uv: &[Vec2<f32>], holes_uv: &[Vec<Vec2<f32>>], ) -> Option<(Vec<[f32; 4]>, Vec<(usize, usize, usize)>, Vec<[f32; 2]>)>
Triangulate a cap defined by an outer loop and optional hole loops in UV space. Returns (world_positions, triangle_indices, uv_positions).
Sourcepub fn triangulate(
&self,
sector: &Sector,
map: &Map,
) -> Option<(Vec<[f32; 4]>, Vec<(usize, usize, usize)>, Vec<[f32; 2]>)>
pub fn triangulate( &self, sector: &Sector, map: &Map, ) -> Option<(Vec<[f32; 4]>, Vec<(usize, usize, usize)>, Vec<[f32; 2]>)>
Triangulate the owning sector in this surface’s local UV space and return world vertices, indices, and UVs. This treats the sector’s 3D polygon as the base face of the surface; any vertical/tilted walls are handled correctly.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Surface
impl<'de> Deserialize<'de> for Surface
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Surface, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Surface, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for Surface
impl Serialize for Surface
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for Surface
impl RefUnwindSafe for Surface
impl Send for Surface
impl Sync for Surface
impl Unpin for Surface
impl UnsafeUnpin for Surface
impl UnwindSafe for Surface
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.