Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double Sided per Material #280

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion korman/exporter/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,7 @@ def _propagate_material_settings(self, bo, bm, tex_slot, layer):
state = layer.state

is_waveset = bo.plasma_modifiers.water_basic.enabled
if bo.data.show_double_sided:
if bm.plasma_material.double_sided:
if is_waveset:
self._report.warn("FORCING single sided--this is a waveset (are you insane?)")
else:
Expand Down
20 changes: 10 additions & 10 deletions korman/operators/op_toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,33 +174,33 @@ def execute(self, context):


class PlasmaToggleDoubleSidedOperator(ToolboxOperator, bpy.types.Operator):
bl_idname = "mesh.plasma_toggle_double_sided"
bl_idname = "material.plasma_toggle_double_sided"
bl_label = "Toggle All Double Sided"
bl_description = "Toggles all meshes to be double sided"
bl_description = "Toggles all materials to be double sided"

enable = BoolProperty(name="Enable", description="Enable Double Sided")

def execute(self, context):
enable = self.enable
for mesh in bpy.data.meshes:
mesh.show_double_sided = enable
for mat in bpy.data.materials:
mat.plasma_material.double_sided = enable
return {"FINISHED"}


class PlasmaToggleDoubleSidedSelectOperator(ToolboxOperator, bpy.types.Operator):
bl_idname = "mesh.plasma_toggle_double_sided_selected"
bl_idname = "material.plasma_toggle_double_sided_selected"
bl_label = "Toggle Selected Double Sided"
bl_description = "Toggles selected meshes double sided value"
bl_description = "Toggles selected meshes' material(s) double sided value"

@classmethod
def poll(cls, context):
return super().poll(context) and hasattr(bpy.context, "selected_objects")

def execute(self, context):
mesh_list = [i.data for i in context.selected_objects if i.type == "MESH"]
enable = not all((mesh.show_double_sided for mesh in mesh_list))
for mesh in mesh_list:
mesh.show_double_sided = enable
mat_list = [slot.material for slot in itertools.chain.from_iterable((i.material_slots for i in context.selected_objects)) if slot and slot.material]
enable = not all((mat.plasma_material.double_sided for mat in mat_list))
for mat in mat_list:
mat.plasma_material.double_sided = enable
return {"FINISHED"}


Expand Down
2 changes: 2 additions & 0 deletions korman/properties/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from .prop_camera import *
from .prop_image import *
from .prop_lamp import *
from .prop_material import *
from . import modifiers
from .prop_object import *
from .prop_scene import *
Expand All @@ -32,6 +33,7 @@ def register():
bpy.types.Camera.plasma_camera = bpy.props.PointerProperty(type=PlasmaCamera)
bpy.types.Image.plasma_image = bpy.props.PointerProperty(type=PlasmaImage)
bpy.types.Lamp.plasma_lamp = bpy.props.PointerProperty(type=PlasmaLamp)
byp.types.Material.plasma_material = bpy.Props.PointerProperty(type=PlasmaMaterial)
bpy.types.Object.plasma_net = bpy.props.PointerProperty(type=PlasmaNet)
bpy.types.Object.plasma_object = bpy.props.PointerProperty(type=PlasmaObject)
bpy.types.Scene.plasma_scene = bpy.props.PointerProperty(type=PlasmaScene)
Expand Down
27 changes: 27 additions & 0 deletions korman/properties/prop_material.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This file is part of Korman.
#
# Korman is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Korman is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Korman. If not, see <http://www.gnu.org/licenses/>.

import bpy
from bpy.props import *

from .. import idprops

class PlasmaMaterial(bpy.types.PropertyGroup):
bl_idname = "material.plasma_material"

double_sided = BoolProperty(name="Double Sided",
description="Sets this material as double sided (formerly TWOSIDE)",
default=False)

1 change: 1 addition & 0 deletions korman/ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from .ui_image import *
from .ui_lamp import *
from .ui_list import *
from .ui_material import *
from .ui_menus import *
from .ui_modifiers import *
from .ui_object import *
Expand Down
42 changes: 42 additions & 0 deletions korman/ui/ui_material.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This file is part of Korman.
#
# Korman is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Korman is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Korman. If not, see <http://www.gnu.org/licenses/>.

import bpy

from . import ui_list

class MaterialButtonsPanel:
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "material"

@classmethod
def poll(cls, context):
return context.material and context.scene.render.engine == "PLASMA_GAME"


class PlasmaMaterialPanel(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Plasma Material Options"

def draw(self, context):
mat = context.material
mat_props = mat.plasma_material
layout = self.layout

split = layout.split()
col = split.column()
sub = col.column()
col.prop(mat_props, "double_sided")