Utilities (.util)#
Code Statistics (.util.codestats)#
compute#
The model is already indexed into topological order by setup.py.
choice_probs[choice_id] gives branch probabilities for one discrete choice
choice_branches[choice_id] gives the branch ids for that choice
branch_vars[branch_id] is a bitmask of variables activated by that branch
var_kind[var_id] is “choice” or “continuous”
- infinigen2.util.codestats.compute.shannon_entropy_bits(probabilities) float[source]#
- Parameters:
probabilities
- infinigen2.util.codestats.compute.cyclomatic_complexity(choice_probs) int[source]#
Cyclomatic complexity where only control flow is pf.control.hcoice Return 1 + sum(branch_count - 1) over discrete choices.
setup#
Compute-graph extraction and stat summaries
Representation after setup:
choice_probs[choice_id] gives branch probabilities for one discrete choice
choice_branches[choice_id] gives the branch ids for that choice
branch_vars[branch_id] gives the variables activated by that branch
var_kind[var_id] is “choice” or “continuous”
This code handles: - extracting this model from a compute graph - topologically reindexing variables so the solver can use bitmasks - calling either the plain recursion or the memoized DP
- infinigen2.util.codestats.setup.build_model_from_compute_graph(graph) dict[source]#
Extract the compact branch-first model from a traced compute graph.
- Parameters:
graph (ComputeGraph)
- infinigen2.util.codestats.setup.build_indexed_model(model) dict[source]#
Reindex variables into topological order and convert branches to masks.
- Parameters:
model (dict)
- infinigen2.util.codestats.setup.compute_stats(...) dict[source]#
Extract the compact model and run either the tree or DP solver.
- Parameters:
graph (ComputeGraph)
method (str) -- (default:
'dp')continuous_bits (float) -- (default:
3.0)trace_level (TraceLevel | None) -- (default:
None)
Module contents#
- infinigen2.util.codestats.build_indexed_model(model) dict[source]#
Reindex variables into topological order and convert branches to masks.
- Parameters:
model (dict)
- infinigen2.util.codestats.build_model_from_compute_graph(graph) dict[source]#
Extract the compact branch-first model from a traced compute graph.
- Parameters:
graph (ComputeGraph)
- infinigen2.util.codestats.compute_stats(...) dict[source]#
Extract the compact model and run either the tree or DP solver.
- Parameters:
graph (ComputeGraph)
method (str) -- (default:
'dp')continuous_bits (float) -- (default:
3.0)trace_level (TraceLevel | None) -- (default:
None)
- infinigen2.util.codestats.cyclomatic_complexity(choice_probs) int[source]#
Cyclomatic complexity where only control flow is pf.control.hcoice Return 1 + sum(branch_count - 1) over discrete choices.
camera_projection#
- infinigen2.util.camera_projection.adjust_camera_sensor(camera)[source]#
- Parameters:
camera (CameraObject)
- infinigen2.util.camera_projection.get_calibration_matrix_K_from_blender(camera) ndarray[source]#
Build intrinsic camera parameters from Blender camera data
Based on https://blender.stackexchange.com/questions/15102/what-is-blenders-camera-projection-matrix-model
- Parameters:
camera (CameraObject) -- Blender camera object
- Returns:
3x3 intrinsic camera matrix
- Return type:
K
- infinigen2.util.camera_projection.get_3x4_RT_matrix_from_blender(camera) ndarray[source]#
Get camera rotation and translation matrices from Blender.
We return a camera matrix in the usual computer vision convention: +x is horizontal, +y is down, +z is forward.
This is different than blender’s camera typical convention, which is +x is horizontal, +y is up, -z is forward.
- Parameters:
camera (CameraObject) -- Blender camera object
- Returns:
3x4 camera matrix
- Return type:
RT
- infinigen2.util.camera_projection.project_points(camera, points_N3) ndarray[source]#
Project points onto the camera image plane.
- Parameters:
camera (CameraObject)
points_N3 (ndarray)
- infinigen2.util.camera_projection.is_projection_within_image(projected, resolution=None) ndarray[source]#
Check if the projection is within the image.
- infinigen2.util.camera_projection.camera_depth_raycast(cam, colliders, meshgridcoords) ndarray[source]#
- Parameters:
cam (CameraObject)
colliders (CollisionSet)
meshgridcoords (ndarray)
curve#
- class infinigen2.util.curve.CurveToMeshWithUvResult(mesh, vector)[source]#
Bases:
NamedTuple- mesh: pf.ProcNode[pf.MeshObject]#
- vector: pf.ProcNode[pf.Vector]#
- class infinigen2.util.curve.FilletMaskResult(...)[source]#
Bases:
NamedTuple- curve: pf.ProcNode[CurveObject]#
- is_fillet_point: pf.ProcNode[bool]#
- is_flat_point: pf.ProcNode[bool]#
- orig_point_idx: pf.ProcNode[int]#
- infinigen2.util.curve.curve_to_mesh_with_uv(
- curve,
- profile,
- fill_caps=False,
- Parameters:
curve (pf.ProcNode[CurveObject])
profile (pf.ProcNode[CurveObject])
fill_caps (pf.ProcNode[bool] | bool) -- (default:
False)
- infinigen2.util.curve.curve_to_noncyclic(input) pf.ProcNode[CurveObject][source]#
- Parameters:
input (pf.ProcNode[CurveObject])
- infinigen2.util.curve.fillet_mask(...) FilletMaskResult[source]#
- Parameters:
geometry (pf.ProcNode[CurveObject])
selection (pf.ProcNode[bool] | bool)
fillet_vertices (pf.ProcNode[int] | int)
radius (pf.ProcNode[float] | float)
errors#
external_assets#
hardware_info#
import_utils#
Utilities for dynamic imports and finding generator functions.
instance#
- infinigen2.util.instance.instance(...) pf.ProcNode[source]#
- Parameters:
parent (pf.ProcNode[pf.MeshObject])
child (pf.ProcNode[pf.Collection])
seed (pf.ProcNode[int]) -- (default:
0)density (pf.ProcNode[float]) -- (default:
2.0)distance_min (pf.ProcNode[float]) -- (default:
0.0)offset (pf.ProcNode[pf.Vector]) -- (default:
(0, 0, 0.002))
- infinigen2.util.instance.instanced_objects(...) list[pf.MeshObject][source]#
- Parameters:
rng (Generator)
parent (pf.MeshObject)
child (pf.Collection)
density (float) -- (default:
2.0)distance_min (float) -- (default:
0.0)offset (tuple[float, float, float]) -- (default:
(0, 0, 0.002))
math#
- infinigen2.util.math.offset_spacing(...) pf.ProcNode[float][source]#
- Parameters:
seed (pf.ProcNode[int] | int)
dimension (pf.ProcNode[float] | float)
index (pf.ProcNode[int] | int)
vertices (pf.ProcNode[int] | int)
max_offset_pct (pf.ProcNode[float] | float)
mesh#
- class infinigen2.util.mesh.CubeWithVertexIndicesResult(...)[source]#
Bases:
NamedTuple- mesh: pf.ProcNode[pf.MeshObject]#
- index_x: pf.ProcNode[int]#
- index_y: pf.ProcNode[int]#
- index_z: pf.ProcNode[int]#
- class infinigen2.util.mesh.ExtrudeSeamlessResult(mesh, top, side)[source]#
Bases:
NamedTuple- mesh: pf.ProcNode[pf.MeshObject]#
- top: pf.ProcNode[bool]#
- side: pf.ProcNode[bool]#
- class infinigen2.util.mesh.WallCutoutResult(wall, sill, lightblocker)[source]#
Bases:
NamedTuple- wall: pf.ProcNode[pf.MeshObject]#
- sill: pf.ProcNode[pf.MeshObject]#
- lightblocker: pf.ProcNode[pf.MeshObject]#
- infinigen2.util.mesh.corner_box(...) CubeWithVertexIndicesResult[source]#
- Parameters:
size (pf.ProcNode[pf.Vector] | pf.Vector) -- (default:
(1, 1, 1))loops_x (pf.ProcNode[int] | int) -- (default:
0)loops_y (pf.ProcNode[int] | int) -- (default:
0)loops_z (pf.ProcNode[int] | int) -- (default:
0)support_loop_offset (pf.ProcNode[pf.Vector] | pf.Vector) -- (default:
(0.05, 0.05, 0.05))
- infinigen2.util.mesh.crease_sharp(
- mesh,
- threshold_degrees,
- Parameters:
mesh (pf.ProcNode[pf.MeshObject])
threshold_degrees (pf.ProcNode[float] | float)
- infinigen2.util.mesh.extrude_mesh_seamless_uvs(...) ExtrudeSeamlessResult[source]#
Extrude faces and continue source UVs onto the new side faces seamlessly.
Each side corner gets uv0 plus a perpendicular offset proportional to its extrusion depth. The boundary edge driving that offset is found per corner via its own next-corner edge (the one with both ends on the depth-0 ring), then broadcast across the side face with accumulate_field.
- Parameters:
mesh (pf.ProcNode[pf.MeshObject])
selection (pf.ProcNode[bool] | bool)
offset_scale (pf.ProcNode[float] | float)
uv_winding_sign (pf.ProcNode[float] | float) -- (default:
1.0)
- infinigen2.util.mesh.grid_from_corners(...) pf.ProcNode[source]#
- Parameters:
point_1 (pf.ProcNode[pf.Vector] | pf.Vector)
point_2 (pf.ProcNode[pf.Vector] | pf.Vector)
vertices_x (pf.ProcNode[int] | int)
vertices_y (pf.ProcNode[int] | int)
- infinigen2.util.mesh.uv_winding_sign(obj) float[source]#
Sign of the first face’s UV winding (+1/-1), for un-mirrored continuation.
- Parameters:
obj (pf.MeshObject)
- infinigen2.util.mesh.wall_cutout_split(...) WallCutoutResult[source]#
Split a flat cutout_sel-tagged surface into holed wall, sill tunnels, and lightblocker backing.
The mouth of each hole gets a chamfer-wide angled lip, kept on the wall (it reads as a bevel of the wall surface around the opening); the sill is just the deep reveal tunnel. The footprint must be pre-expanded by chamfer (see face_expand_margin) so the inner opening lands at the originally-intended size.
- Parameters:
geometry (pf.ProcNode[pf.MeshObject])
thickness (pf.ProcNode[float] | float)
blocker_thickness (pf.ProcNode[float] | float) -- (default:
0.1)uv_winding_sign (pf.ProcNode[float] | float) -- (default:
1.0)delete_facecap (pf.ProcNode[bool] | bool) -- (default:
True)chamfer (pf.ProcNode[float] | float) -- (default:
0.006)
render_metadata#
scene_cleanup#
- infinigen2.util.scene_cleanup.cleanup_except(keep) list[str][source]#
Delete every bpy.data.objects entry not in keep.
Placement helpers (e.g. repeat_attempts) leave failed-placement objects in the scene. They are excluded from the returned all_objects lists but still live in the blend and would otherwise be rendered. Pass the union of objects/cameras/lights you want kept and this removes the rest.