Skip to content

Commit

Permalink
Merge pull request #125 from TheDuckCow/dev
Browse files Browse the repository at this point in the history
Dev PR for 3.2.3.1
  • Loading branch information
TheDuckCow authored May 15, 2020
2 parents a48b1b4 + 05051b6 commit 33ac9c3
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 90 deletions.
5 changes: 3 additions & 2 deletions MCprep_addon/MCprep_resources/mcprep_data_update.json
Original file line number Diff line number Diff line change
Expand Up @@ -2416,6 +2416,7 @@
"cauldron_inner": "cauldron_inner",
"cauldron_side": "cauldron_side",
"cauldron_top": "cauldron_top",
"chain": "chain",
"chain_command_block_back": "chain_command_block_back",
"chain_command_block_conditional": "chain_command_block_conditional",
"chain_command_block_front": "chain_command_block_front",
Expand Down Expand Up @@ -2922,10 +2923,10 @@
"soul_campfire_fire": "soul_campfire_fire",
"soul_campfire_log_lit": "soul_campfire_log_lit",
"soul_fire_0": "soul_fire_0",
"soul_fire_lantern": "soul_fire_lantern",
"soul_fire_torch": "soul_fire_torch",
"soul_lantern": "soul_lantern",
"soul_sand": "soul_sand",
"soul_soil": "soul_soil",
"soul_torch": "soul_torch",
"spawner": "spawner",
"sponge": "sponge",
"spruce_door_bottom": "spruce_door_bottom",
Expand Down
2 changes: 1 addition & 1 deletion MCprep_addon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
bl_info = {
"name": "MCprep",
"category": "Object",
"version": (3, 2, 3),
"version": (3, 2, 3, 1),
"blender": (2, 80, 0),
"location": "3D window toolshelf > MCprep tab",
"description": "Minecraft workflow addon for rendering and animation",
Expand Down
9 changes: 3 additions & 6 deletions MCprep_addon/load_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
importlib.reload(addon_updater_ops)
importlib.reload(generate)

if conf.v:
print("Reload, verbose is enabled")
conf.log("Reload, verbose is enabled")

else:
import bpy
Expand Down Expand Up @@ -97,10 +96,8 @@ def register(bl_info):
# addon updater code and configurations
addon_updater_ops.register(bl_info)

if conf.v:
print("MCprep: Verbose is enabled")
if conf.vv:
print("MCprep: Very Verbose is enabled")
conf.log("MCprep: Verbose is enabled")
conf.log("MCprep: Very Verbose is enabled", vv_only=True)


def unregister(bl_info):
Expand Down
58 changes: 41 additions & 17 deletions MCprep_addon/materials/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,15 @@ def set_cycles_texture(image, material, extra_passes=False):
node.image = image
node.mute = False
node.hide = False
elif "MCPREP_normal" in node:
elif "MCPREP_normal" in node and node.type == 'TEX_IMAGE':
if "normal" in img_sets:
if node.type == 'TEX_IMAGE':
new_img = util.loadTexture(img_sets["normal"])
node.image = new_img
new_img = util.loadTexture(img_sets["normal"])
node.image = new_img
# For later 2.8, fix images color space user
if hasattr(node, "color_space"): # 2.7 and earlier 2.8 versions
node.color_space = 'NONE' # for better interpretation of specmaps
elif hasattr(new_img, "colorspace_settings"): # later 2.8 versions
new_img.colorspace_settings.name = 'Non-Color'
node.mute = False
node.hide = False
else:
Expand All @@ -430,18 +434,23 @@ def set_cycles_texture(image, material, extra_passes=False):
# normal_map = node.outputs[0].links[0].to_node
# principled = ...

elif "MCPREP_specular" in node:
elif "MCPREP_specular" in node and node.type == 'TEX_IMAGE':
if "specular" in img_sets:
new_img = util.loadTexture(img_sets["specular"])
node.image = new_img
node.mute = False
node.hide = False
# For later 2.8, fix images color space user
if hasattr(node, "color_space"): # 2.7 and earlier 2.8 versions
node.color_space = 'NONE' # for better interpretation of specmaps
elif hasattr(new_img, "colorspace_settings"): # later 2.8 versions
new_img.colorspace_settings.name = 'Non-Color'
else:
node.mute = True
node.hide = True

elif node.type == "TEX_IMAGE":
# assume all unlabeled texture nodes should be the diffuse
# assume all unlabeled texture nodes should be the diffuse pass
node["MCPREP_diffuse"] = True # annotate node for future reference
node.image = image
node.mute = False
Expand Down Expand Up @@ -752,10 +761,12 @@ def replace_missing_texture(image):

def is_image_grayscale(image):
"""Returns true if image data is all grayscale, false otherwise"""
if not image:
return None
conf.log("Checking image for grayscale "+image.name, vv_only=True)
if 'grayscale' in image: # cache
return image['grayscale']
if not image or not image.pixels:
if not image.pixels:
conf.log("Not an image / no pixels", vv_only=True)
return None

Expand Down Expand Up @@ -789,7 +800,10 @@ def set_saturation_material(mat):
return

conf.log("Running set_saturation on "+mat.name, vv_only=True)
diff_img = get_node_for_pass(mat, "diffuse").image
diff_pass = get_node_for_pass(mat, "diffuse")
if not diff_pass:
return
diff_img = diff_pass.image

if not diff_img:
conf.log("debug: No diffuse", vv_only=True)
Expand Down Expand Up @@ -1009,13 +1023,18 @@ def matgen_cycles_principled(mat, passes, use_reflections, only_solid):
if hasattr(nodeTexDiff, "interpolation"): # 2.72+
nodeTexDiff.interpolation = 'Closest'
nodeTexSpec.interpolation = 'Closest'

# Spec update
if hasattr(nodeTexSpec, "color_space"): # 2.7 and earlier 2.8 versions
nodeTexSpec.color_space = 'NONE' # for better interpretation of specmaps
nodeTexNorm.color_space = 'NONE' # for better interpretation of normals
elif nodeTexSpec.image and hasattr(nodeTexSpec.image, "colorspace_settings"): # later 2.8 versions
nodeTexSpec.image.colorspace_settings.name = 'Non-Color'
if nodeTexNorm.image:
nodeTexNorm.image.colorspace_settings.name = 'Non-Color'

# Normal update
if hasattr(nodeTexNorm, "color_space"): # 2.7 and earlier 2.8 versions
nodeTexNorm.color_space = 'NONE' # for better interpretation of normals
elif nodeTexNorm.image and hasattr(nodeTexNorm.image, "colorspace_settings"):
nodeTexNorm.image.colorspace_settings.name = 'Non-Color'

# apply additional settings
if hasattr(mat, "cycles"):
Expand Down Expand Up @@ -1214,16 +1233,21 @@ def matgen_cycles_original(mat, passes, use_reflections, only_solid):
nodeNormal.mute = True
# nodeTexDisp.image = image_disp

if hasattr(nodeTexDiff, "interpolation"): # only avail 2.72+
if hasattr(nodeTexDiff, "interpolation"): # 2.72+
nodeTexDiff.interpolation = 'Closest'
nodeTexSpec.interpolation = 'Closest' # should this be closest or not?
nodeTexSpec.interpolation = 'Closest'

# Spec update
if hasattr(nodeTexSpec, "color_space"): # 2.7 and earlier 2.8 versions
nodeTexSpec.color_space = 'NONE' # for better interpretation of specmaps
nodeTexNorm.color_space = 'NONE' # for better interpretation of normals
elif nodeTexSpec.image and hasattr(nodeTexSpec.image, "colorspace_settings"): # 2.7 and earlier 2.8 versions
elif nodeTexSpec.image and hasattr(nodeTexSpec.image, "colorspace_settings"): # later 2.8 versions
nodeTexSpec.image.colorspace_settings.name = 'Non-Color'
if nodeTexNorm.iamge:
nodeTexNorm.iamge.colorspace_settings.name = 'Non-Color'

# Normal update
if hasattr(nodeTexNorm, "color_space"): # 2.7 and earlier 2.8 versions
nodeTexNorm.color_space = 'NONE' # for better interpretation of normals
elif nodeTexNorm.image and hasattr(nodeTexNorm.image, "colorspace_settings"):
nodeTexNorm.image.colorspace_settings.name = 'Non-Color'

#set other default values, e.g. the mixes
nodeMix2.inputs[0].default_value = 0 # factor mix with glossy
Expand Down
58 changes: 15 additions & 43 deletions MCprep_addon/mcprep_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,6 @@ def change_verbose(self, context):
description = "Default folder for opening world objs from programs like jmc2obj or Mineways",
subtype = 'DIR_PATH',
default = "//")
# mcprep_use_lib = bpy.props.BoolProperty(
# name = "Link meshswapped groups & materials",
# description = "Use library linking when meshswapping or material matching",
# default = False)
MCprep_groupAppendLayer = bpy.props.IntProperty(
name="Group Append Layer",
description="When groups are appended instead of linked, "+\
Expand Down Expand Up @@ -246,11 +242,11 @@ def change_verbose(self, context):
subtype = 'FILE_PATH',
update=mineways_update,
default = "Mineways")
# open_mineways_path_mac = bpy.props.StringProperty(
# name = "Mineways path",
# description = "Path to the Mineways executable",
# subtype = 'FILE_PATH',
# default = "mineways.app")
save_folder = bpy.props.StringProperty(
name = "MC saves folder",
description = "Folder containing Minecraft world saves directories, for the direct import bridge",
subtype = 'FILE_PATH',
default = '')

# addon updater preferences

Expand Down Expand Up @@ -581,16 +577,16 @@ def draw(self, context):
addon_updater_ops.update_notice_box_ui(self, context)


# class MCPREP_PT_bridge(bpy.types.Panel):
# """MCprep panel for directly importing and reloading minecraft saves"""
# bl_label = "World Bridge"
# bl_space_type = "VIEW_3D"
# bl_region_type = 'TOOLS' if not util.bv28() else 'UI'
# bl_context = "objectmode"
# bl_category = "MCprep"
class MCPREP_PT_bridge(bpy.types.Panel):
"""MCprep panel for directly importing and reloading minecraft saves"""
bl_label = "World Bridge"
bl_space_type = "VIEW_3D"
bl_region_type = 'TOOLS' if not util.bv28() else 'UI'
bl_context = "objectmode"
bl_category = "MCprep"

# def draw(self, context):
# bridge.panel_draw(self, context)
def draw(self, context):
bridge.panel_draw(self, context)


class MCPREP_PT_world_tools(bpy.types.Panel):
Expand Down Expand Up @@ -1046,6 +1042,7 @@ def mcprep_image_tools(self, context):


class McprepProps(bpy.types.PropertyGroup):
"""Properties saved to an individual scene"""

# not available here
addon_prefs = util.get_user_preferences()
Expand All @@ -1063,17 +1060,6 @@ class McprepProps(bpy.types.PropertyGroup):
name = "show spawner settings",
description = "Show extra MCprep panel settings",
default = False)
combine_materials = bpy.props.BoolProperty(
name = "Combine materials",
description = "Consolidate duplciate materials & textures",
default = False
)
autoFindMissingTextures = bpy.props.BoolProperty(
name = "Auto-find missing images",
description = "If the texture for an existing material is missing, "+\
"try to load from the default texture pack instead",
default = True # decide this behavior
)

# Rig settings
spawn_rig_category = bpy.props.EnumProperty(
Expand All @@ -1099,20 +1085,6 @@ class McprepProps(bpy.types.PropertyGroup):
item_list = bpy.props.CollectionProperty(type=spawn_util.ListItemAssets)
item_list_index = bpy.props.IntProperty(default=0)

# Mineways bridge/Minecraft direct settings
save_dir_default = '/Users/patrickcrawford/Library/Application Support/minecraft/saves/'
save_folder = bpy.props.StringProperty(
name = "Saves folder",
description = "Folder containing Minecraft world saves directories, for the direct import bridge",
subtype = 'FILE_PATH',
default = save_dir_default)
# bridge_world = bpy.props.EnumProperty(
# name = "World Save",
# description = "World to use for the direct import bridge",
# items = bridge.world_saves_enum,
# update = bridge.world_save_update
# )


# -----------------------------------------------------------------------------
# Register functions
Expand Down
44 changes: 26 additions & 18 deletions MCprep_addon/spawner/meshswap.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,6 @@ def execute(self, context):
group = util.collections()[block]
# if blender 2.8, see if collection part of the MCprepLib coll.
use_cache = True
sel_count = 0
for obj in group.objects:
try:
util.select_set(obj, True)
except RuntimeError:
# likely particles like for the torch, not added to scene
conf.log("Skip {} select, not in view layer".format(obj.name))
continue
if sel_count == 0: # added with try/except above, to catch reports since non replicated
raise Exception("No objects selected for cache: "+block)
else:
util.bAppendLink(os.path.join(meshSwapPath,method), block, toLink)

Expand Down Expand Up @@ -298,7 +288,10 @@ def execute(self, context):
ob["MCprep_noSwap"] = 1

if self.make_real:
if util.bv28(): # make real doesn't select resulting output now
if util.bv28():
# make real doesn't select resulting output now (true for
# earlier versions of 2.8, not true in 2.82 at least where
# selects everything BUT the source of original instance
pre_objs = list(bpy.data.objects)
bpy.ops.object.duplicates_make_real()
post_objs = list(bpy.data.objects)
Expand All @@ -311,13 +304,27 @@ def execute(self, context):
if group is not None:
self.fix_armature_target(
context, context.selected_objects, group)

# remove the empty added by making duplicates real.
for ob in context.selected_objects:
if ob.type != "EMPTY":
continue
elif ob.parent or ob.children:
continue
if ob in bpy.data.objects[:] and ob.type == "EMPTY":
util.obj_unlink_remove(ob, True, context)
else:
for ob in context.selected_objects:
if ob.type != "EMPTY":
continue
elif ob.parent or ob.children:
continue
util.obj_unlink_remove(ob, True, context)
# TODO: Consider actually keeping the empty, and parenting the
# spawned items to this empty (not the defautl behavior)
else:
# change the draw size
if hasattr(ob, "empty_draw_size"):
ob.empty_draw_size = 0.25
else:
ob.empty_display_size = 0.25
# mark as active object
util.set_active_object(context, ob)

# Move source of group instance into excluded view layer
if util.bv28() and group:
Expand Down Expand Up @@ -812,12 +819,13 @@ def checkExternal(self, context, name):
'door_birch_upper','door_spruce_upper','tnt_side','tnt_bottom',
'pumpkin_top_lit', 'pumpkin_side_lit', 'workbench_back', 'workbench_front',
'furnace_top', 'furnace_side', 'sunflower_top', 'sunflower_front',
'campfire_log_lit', 'campfire_fire']
'campfire_log_lit', 'campfire_fire', 'sunflower_back']
elif self.track_exporter == "Mineways":
rmable = ['oak_door_top', 'iron_door_top', 'spruce_door_top',
'birch_door_top', 'jungle_door_top', 'acacia_door_top', 'dark_oak_door_top',
'cactus_top', 'tall_grass_top', 'sunflower_top', 'sunflower_back',
'campfire_log_lit', 'campfire_fire'] # Mineways removable objs
'campfire_log_lit', 'campfire_fire', 'enchanting_table_side', 'sunflower_front',
'tnt_side', 'tnt_bottom'] # Mineways removable objs
else:
# need to select one of the exporters!
return False # {'CANCELLED'}
Expand Down
Loading

0 comments on commit 33ac9c3

Please sign in to comment.