Skip to content

Commit

Permalink
Move addon calls
Browse files Browse the repository at this point in the history
  • Loading branch information
pvl-bot committed Nov 11, 2024
1 parent a4b73b5 commit 6638a81
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 34 deletions.
2 changes: 0 additions & 2 deletions infinigen/assets/objects/rocks/blender_rock.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
from infinigen.core.tagging import tag_object
from infinigen.core.util import blender as butil

bpy.ops.preferences.addon_enable(module="add_mesh_extra_objects")


class BlenderRockFactory(AssetFactory):
def __init__(self, factory_seed, detail=1):
Expand Down
4 changes: 0 additions & 4 deletions infinigen/assets/scatters/snow_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@


class Snowlayer:
def __init__(self):
bpy.ops.preferences.addon_enable(module="real_snow")
pass

def apply(self, obj, **kwargs):
bpy.context.scene.snow.height = 0.1
with butil.SelectObjects(obj):
Expand Down
12 changes: 0 additions & 12 deletions infinigen/assets/utils/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,3 @@ def separate_loose(obj):
objs.remove(obj)
butil.delete(objs)
return obj


def print3d_clean_up(obj):
bpy.ops.preferences.addon_enable(module="object_print3d_utils")
with butil.ViewportMode(obj, "EDIT"), butil.Suppress():
bpy.ops.mesh.select_all(action="SELECT")
bpy.ops.mesh.quads_convert_to_tris(quad_method="BEAUTY", ngon_method="BEAUTY")
bpy.ops.mesh.fill_holes()
bpy.ops.mesh.quads_convert_to_tris(quad_method="BEAUTY", ngon_method="BEAUTY")
bpy.ops.mesh.normals_make_consistent()
bpy.ops.mesh.print3d_clean_distorted()
bpy.ops.mesh.print3d_clean_non_manifold()
15 changes: 4 additions & 11 deletions infinigen/core/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from numpy.random import randint

import infinigen
from infinigen.core.util.logging import LogLevel, Suppress
from infinigen.core.util.logging import LogLevel
from infinigen.core.util.math import int_hash
from infinigen.core.util.organization import Task

Expand Down Expand Up @@ -198,15 +198,6 @@ def find_config(p):
)


def import_addons(names):
for name in names:
try:
with Suppress():
bpy.ops.preferences.addon_enable(module=name)
except Exception:
logger.warning(f'Could not load addon "{name}"')


@gin.configurable
def configure_render_cycles(
# supplied by gin.config
Expand Down Expand Up @@ -303,4 +294,6 @@ def configure_blender(
bpy.context.scene.cycles.motion_blur_position = "START"
bpy.context.scene.render.motion_blur_shutter = motion_blur_shutter

import_addons(["ant_landscape", "real_snow"])
bpy.ops.preferences.addon_enable(module="add_mesh_extra_objects")
bpy.ops.preferences.addon_enable(module="real_snow")
bpy.ops.preferences.addon_enable(module="ant_landscape")
2 changes: 0 additions & 2 deletions infinigen/tools/terrain/generate_terrain_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ def asset_generation(
parser.add_argument("--device", type=str, default="cpu")
args = init.parse_args_blender(parser)

bpy.ops.preferences.addon_enable(module="add_mesh_extra_objects")
bpy.ops.preferences.addon_enable(module="ant_landscape")
butil.clear_scene(targets=[bpy.data.objects])
asset_generation(
Path(args.folder),
Expand Down
5 changes: 2 additions & 3 deletions tests/test_terrain_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
# Authors: Zeyu Ma


import bpy
import gin
import pytest

from infinigen.core.init import configure_blender
from infinigen.core.surface import registry
from infinigen.core.util.organization import Task
from infinigen.core.util.test_utils import setup_gin
Expand All @@ -34,8 +34,7 @@ def test_terrain_runs():
],
)

bpy.ops.preferences.addon_enable(module="add_mesh_extra_objects")
bpy.ops.preferences.addon_enable(module="ant_landscape")
configure_blender()

terrain = Terrain(
0, registry, task=Task.Coarse, on_the_fly_asset_folder="/tmp/terrain_tests"
Expand Down

0 comments on commit 6638a81

Please sign in to comment.