Skip to content

Commit

Permalink
Changed wall naming scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
markusmoenig committed Sep 24, 2024
1 parent b5685f0 commit 3555bac
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 35 deletions.
Binary file added creator/embedded/geo_wall_back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added creator/embedded/geo_wall_left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions creator/src/modeleditor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,9 @@ impl ModelEditor {
geo_obj.nodes[selected_index].set(name, value.clone());
match &geo_obj.nodes[selected_index].role {
GeoFXNodeRole::LeftWall
| GeoFXNodeRole::TopWall
| GeoFXNodeRole::BackWall
| GeoFXNodeRole::RightWall
| GeoFXNodeRole::BottomWall
| GeoFXNodeRole::FrontWall
| GeoFXNodeRole::MiddleWallH
| GeoFXNodeRole::MiddleWallV => {
if name == "Length" || name == "Height" {
Expand Down
34 changes: 22 additions & 12 deletions creator/src/modelfxeditor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,9 +631,9 @@ impl ModelFXEditor {
geo_obj.nodes[index].set(name, value.clone());
match &geo_obj.nodes[index].role {
GeoFXNodeRole::LeftWall
| GeoFXNodeRole::TopWall
| GeoFXNodeRole::BackWall
| GeoFXNodeRole::RightWall
| GeoFXNodeRole::BottomWall
| GeoFXNodeRole::FrontWall
| GeoFXNodeRole::MiddleWallH
| GeoFXNodeRole::MiddleWallV => {
if name == "Length" || name == "Height" {
Expand Down Expand Up @@ -1260,8 +1260,8 @@ impl ModelFXEditor {
}

/// Set the tiles for the picker.
pub fn set_geo_tiles(&mut self, palette: &ThePalette, ui: &mut TheUI, ctx: &mut TheContext) {
let tile_size = 48;
pub fn set_geo_tiles(&mut self, _palette: &ThePalette, ui: &mut TheUI, ctx: &mut TheContext) {
let tile_size = 65;

//let mut set_default_selection = false;

Expand Down Expand Up @@ -1310,14 +1310,24 @@ impl ModelFXEditor {

i += 1;

tile.preview(
&mut tile_buffer,
None,
palette,
&FxHashMap::default(),
Vec2f::zero(),
ctx,
);
if let Some(icon_name) = tile.icon_name() {
if let Some(b) = ctx.ui.icon(&icon_name) {
tile_buffer.copy_into(0, 0, b);
} else {
tile_buffer.fill(BLACK);
}
} else {
tile_buffer.fill(BLACK);
}

// tile.preview(
// &mut tile_buffer,
// None,
// palette,
// &FxHashMap::default(),
// Vec2f::zero(),
// ctx,
// );
buffer.copy_into(x * grid, y * grid, &tile_buffer);
self.geos.insert((x, y), tile.clone());
}
Expand Down
46 changes: 27 additions & 19 deletions shared/src/geofxnode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ pub enum GeoFXNodeRole {
Column,

LeftWall,
TopWall,
BackWall,
RightWall,
BottomWall,
FrontWall,
MiddleWallH,
MiddleWallV,

Expand Down Expand Up @@ -100,7 +100,7 @@ impl GeoFXNode {
coll.set("Annular", TheValue::Text(str!("0.0")));
coll.set("Extrusion", TheValue::Text(str!("thickness")));
}
LeftWall | TopWall | RightWall | BottomWall | MiddleWallH | MiddleWallV => {
LeftWall | FrontWall | RightWall | BackWall | MiddleWallH | MiddleWallV => {
coll.set("Pos X", TheValue::Float(0.1));
coll.set("Pos Y", TheValue::Float(0.5));
coll.set("Length", TheValue::FloatRange(1.0, 0.001..=1.0));
Expand Down Expand Up @@ -253,9 +253,9 @@ impl GeoFXNode {
Self::new(GeoFXNodeRole::RemoveHeight),
Self::new(GeoFXNodeRole::SetHeight),
Self::new(GeoFXNodeRole::LeftWall),
Self::new(GeoFXNodeRole::TopWall),
Self::new(GeoFXNodeRole::BackWall),
Self::new(GeoFXNodeRole::RightWall),
Self::new(GeoFXNodeRole::BottomWall),
Self::new(GeoFXNodeRole::FrontWall),
Self::new(GeoFXNodeRole::MiddleWallH),
Self::new(GeoFXNodeRole::MiddleWallV),
// Self::new(GeoFXNodeRole::BendWallNW),
Expand All @@ -282,9 +282,9 @@ impl GeoFXNode {
RemoveHeight => str!("Remove height from the ground tile (height map)."),
SetHeight => str!("Set the height of the ground tile (height map)."),
LeftWall => str!("Left Wall"),
TopWall => str!("Top Wall"),
BackWall => str!("Back Wall"),
RightWall => str!("Right Wall"),
BottomWall => str!("Bottom Wall"),
FrontWall => str!("Front Wall"),
MiddleWallH => str!("Middle Wall X"),
MiddleWallV => str!("Niddle Wall Y"),
Column => str!("A column (disc) with an optional profile."),
Expand Down Expand Up @@ -312,15 +312,23 @@ impl GeoFXNode {
GeoFXNode::new(MiddleWallH)
}

pub fn icon_name(&self) -> Option<String> {
match self.role {
LeftWall => Some(str!("geo_wall_left")),
BackWall => Some(str!("geo_wall_back")),
_ => None,
}
}

pub fn description(&self) -> String {
match &self.role {
AddHeight => str!("Add height to the ground tile (height map)."),
RemoveHeight => str!("Remove height from the ground tile (height map)."),
SetHeight => str!("Set the height of the ground tile (height map)."),
LeftWall => str!("A wall on the left side of the tile."),
TopWall => str!("A wall on the top side of the tile."),
BackWall => str!("A wall on the back side of the tile."),
RightWall => str!("A wall on the right side of the tile."),
BottomWall => str!("A wall on the bottom side of the tile."),
FrontWall => str!("A wall on the front side of the tile."),
MiddleWallH => str!("A horizontal wall in the middle of the tile."),
MiddleWallV => str!("A vertical wall in the middle of the tile."),
// BendWallNW => str!("A rounded wall from the left to the top side of the tile."),
Expand Down Expand Up @@ -629,14 +637,14 @@ impl GeoFXNode {
ctx.material_id = Some(format!("material_{}", ctx.id_counter));
ctx.id_counter += 1;
}
LeftWall | MiddleWallV | RightWall | TopWall | MiddleWallH | BottomWall => {
LeftWall | MiddleWallV | RightWall | BackWall | MiddleWallH | FrontWall => {
let face_type = match &self.role {
LeftWall => "Left",
MiddleWallV => "MiddleY",
RightWall => "Right",
TopWall => "Top",
BackWall => "Back",
MiddleWallH => "MiddleX",
BottomWall => "Bottom",
FrontWall => "Front",
_ => "",
};

Expand Down Expand Up @@ -719,7 +727,7 @@ impl GeoFXNode {

return sdf_box2d(p, pos, thick, len);
}
TopWall => {
BackWall => {
let t = if coll.get_i32_default("2D Mode", 0) == 1 {
1.0
} else {
Expand Down Expand Up @@ -751,7 +759,7 @@ impl GeoFXNode {

return sdf_box2d(p, pos, thick, len);
}
BottomWall => {
FrontWall => {
let t = if coll.get_i32_default("2D Mode", 0) == 1 {
1.0
} else {
Expand Down Expand Up @@ -971,7 +979,7 @@ impl GeoFXNode {

d
}
TopWall => {
BackWall => {
let thick = params[2] / 2.0;
let len = params[3];
let mut height = params[4];
Expand Down Expand Up @@ -1030,7 +1038,7 @@ impl GeoFXNode {

d
}
BottomWall => {
FrontWall => {
let thick = params[2] / 2.0;
let len = params[3];
let mut height = params[4];
Expand Down Expand Up @@ -1363,7 +1371,7 @@ impl GeoFXNode {
area.push(Vec2i::new(pos.x, pos.y + i));
}
}
TopWall | BottomWall | MiddleWallH => {
BackWall | FrontWall | MiddleWallH => {
let pos = Vec2i::from(self.position(&coll));
let length = self.length().ceil() as i32;
for i in 0..length {
Expand Down Expand Up @@ -1513,7 +1521,7 @@ impl GeoFXNode {

pub fn inputs(&self) -> Vec<TheNodeTerminal> {
match self.role {
LeftWall | TopWall | RightWall | BottomWall | MiddleWallH | MiddleWallV => {
LeftWall | BackWall | RightWall | FrontWall | MiddleWallH | MiddleWallV => {
vec![]
}
Bricks | Box | Disc | Material | Repeat | Stack | Group => {
Expand Down Expand Up @@ -1545,7 +1553,7 @@ impl GeoFXNode {
highest_output_terminal += 1;

match self.role {
LeftWall | TopWall | RightWall | BottomWall | MiddleWallH | MiddleWallV => {
LeftWall | BackWall | RightWall | FrontWall | MiddleWallH | MiddleWallV => {
let mut terminals = vec![];
for i in 1..=highest_output_terminal {
terminals.push(TheNodeTerminal {
Expand Down
4 changes: 2 additions & 2 deletions shared/src/geofxobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl GeoFXObject {
}
ctx.geometry = geometry;
}
LeftWall | MiddleWallV | RightWall | TopWall | MiddleWallH | BottomWall => {
LeftWall | MiddleWallV | RightWall | BackWall | MiddleWallH | FrontWall => {
let mut geometry = vec![];
for terminal in 0..6 {
if let Some((n, _)) = self.find_connected_input_node(node, terminal) {
Expand Down Expand Up @@ -276,7 +276,7 @@ impl GeoFXObject {
role = geo.role.clone();
}
match &role {
LeftWall | TopWall | RightWall | BottomWall | MiddleWallH | MiddleWallV => {
LeftWall | BackWall | RightWall | FrontWall | MiddleWallH | MiddleWallV => {
let mut bricks = GeoFXNode::new(Box);
bricks.position = vec2i(200, 40);
self.nodes.push(bricks);
Expand Down

0 comments on commit 3555bac

Please sign in to comment.