|
|
@ -108,27 +108,26 @@ class LightmapAutobakeOperator(_LightingOperator, bpy.types.Operator): |
|
|
|
# We want to ensure that we use the UV Layer "LIGHTMAPGEN" and fetch the size from |
|
|
|
# We want to ensure that we use the UV Layer "LIGHTMAPGEN" and fetch the size from |
|
|
|
# the lightmap modifier. What fun... |
|
|
|
# the lightmap modifier. What fun... |
|
|
|
mesh = context.active_object.data |
|
|
|
mesh = context.active_object.data |
|
|
|
mesh.update() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Search for LIGHTMAPGEN |
|
|
|
# Search for LIGHTMAPGEN |
|
|
|
for uvtex in mesh.uv_textures: |
|
|
|
for i in mesh.uv_textures: |
|
|
|
if uvtex.name == "LIGHTMAPGEN": |
|
|
|
if i.name == "LIGHTMAPGEN": |
|
|
|
toggle.track(mesh.uv_textures, "active", uvtex) |
|
|
|
uvtex = i |
|
|
|
toggle.track(uvtex, "active_render", True) |
|
|
|
|
|
|
|
break |
|
|
|
break |
|
|
|
else: |
|
|
|
else: |
|
|
|
toggle.track(uvtex, "active_render", False) |
|
|
|
toggle.track(i, "active_render", False) |
|
|
|
else: |
|
|
|
else: |
|
|
|
# Gotta make it |
|
|
|
|
|
|
|
uvtex = mesh.uv_textures.new("LIGHTMAPGEN") |
|
|
|
uvtex = mesh.uv_textures.new("LIGHTMAPGEN") |
|
|
|
toggle.track(mesh.uv_textures, "active", uvtex) |
|
|
|
uvtex.active_render = False |
|
|
|
toggle.track(uvtex, "active_render", True) |
|
|
|
toggle.track(mesh.uv_textures, "active", uvtex) |
|
|
|
|
|
|
|
toggle.track(uvtex, "active_render", True) |
|
|
|
|
|
|
|
|
|
|
|
# Now, enter edit mode on this mesh and unwrap. |
|
|
|
# Now, enter edit mode on this mesh and unwrap. |
|
|
|
bpy.ops.object.mode_set(mode="EDIT") |
|
|
|
bpy.ops.object.mode_set(mode="EDIT") |
|
|
|
bpy.ops.mesh.select_all(action="SELECT") |
|
|
|
bpy.ops.mesh.select_all(action="SELECT") |
|
|
|
bpy.ops.uv.lightmap_pack(PREF_CONTEXT="ALL_FACES", PREF_IMG_PX_SIZE=size) |
|
|
|
bpy.ops.uv.lightmap_pack(PREF_CONTEXT="ALL_FACES", PREF_IMG_PX_SIZE=size) |
|
|
|
bpy.ops.object.mode_set(mode="OBJECT") |
|
|
|
bpy.ops.object.mode_set(mode="OBJECT") |
|
|
|
|
|
|
|
mesh.update() |
|
|
|
|
|
|
|
|
|
|
|
# Associate the image with all the new UVs |
|
|
|
# Associate the image with all the new UVs |
|
|
|
# NOTE: no toggle here because it's the artist's problem if they are looking at our |
|
|
|
# NOTE: no toggle here because it's the artist's problem if they are looking at our |
|
|
@ -185,7 +184,6 @@ class VertexColorLightingOperator(_LightingOperator, bpy.types.Operator): |
|
|
|
def execute(self, context): |
|
|
|
def execute(self, context): |
|
|
|
with GoodNeighbor() as toggle: |
|
|
|
with GoodNeighbor() as toggle: |
|
|
|
mesh = context.active_object.data |
|
|
|
mesh = context.active_object.data |
|
|
|
mesh.update() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Find the "autocolor" vertex color layer |
|
|
|
# Find the "autocolor" vertex color layer |
|
|
|
autocolor = mesh.vertex_colors.get("autocolor") |
|
|
|
autocolor = mesh.vertex_colors.get("autocolor") |
|
|
@ -197,6 +195,7 @@ class VertexColorLightingOperator(_LightingOperator, bpy.types.Operator): |
|
|
|
for vcol_layer in mesh.vertex_colors: |
|
|
|
for vcol_layer in mesh.vertex_colors: |
|
|
|
autocol = vcol_layer.name == "autocolor" |
|
|
|
autocol = vcol_layer.name == "autocolor" |
|
|
|
toggle.track(vcol_layer, "active_render", autocol) |
|
|
|
toggle.track(vcol_layer, "active_render", autocol) |
|
|
|
|
|
|
|
mesh.update() |
|
|
|
|
|
|
|
|
|
|
|
# Bake settings |
|
|
|
# Bake settings |
|
|
|
render = context.scene.render |
|
|
|
render = context.scene.render |
|
|
|