03806d0b67
This commit implements described in the #104573. The goal is to fix the confusion of the submodule hashes change, which are not ideal for any of the supported git-module configuration (they are either always visible causing confusion, or silently staged and committed, also causing confusion). This commit replaces submodules with a checkout of addons and addons_contrib, covered by the .gitignore, and locale and developer tools are moved to the main repository. This also changes the paths: - /release/scripts are moved to the /scripts - /source/tools are moved to the /tools - /release/datafiles/locale is moved to /locale This is done to avoid conflicts when using bisect, and also allow buildbot to automatically "recover" wgen building older or newer branches/patches. Running `make update` will initialize the local checkout to the changed repository configuration. Another aspect of the change is that the make update will support Github style of remote organization (origin remote pointing to thy fork, upstream remote pointing to the upstream blender/blender.git). Pull Request #104755
117 lines
2.5 KiB
Python
117 lines
2.5 KiB
Python
import bpy
|
|
import bmesh
|
|
from bpy_extras.object_utils import AddObjectHelper
|
|
|
|
from bpy.props import (
|
|
FloatProperty,
|
|
)
|
|
|
|
|
|
def add_box(width, height, depth):
|
|
"""
|
|
This function takes inputs and returns vertex and face arrays.
|
|
no actual mesh data creation is done here.
|
|
"""
|
|
|
|
verts = [
|
|
(+1.0, +1.0, -1.0),
|
|
(+1.0, -1.0, -1.0),
|
|
(-1.0, -1.0, -1.0),
|
|
(-1.0, +1.0, -1.0),
|
|
(+1.0, +1.0, +1.0),
|
|
(+1.0, -1.0, +1.0),
|
|
(-1.0, -1.0, +1.0),
|
|
(-1.0, +1.0, +1.0),
|
|
]
|
|
|
|
faces = [
|
|
(0, 1, 2, 3),
|
|
(4, 7, 6, 5),
|
|
(0, 4, 5, 1),
|
|
(1, 5, 6, 2),
|
|
(2, 6, 7, 3),
|
|
(4, 0, 3, 7),
|
|
]
|
|
|
|
# apply size
|
|
for i, v in enumerate(verts):
|
|
verts[i] = v[0] * width, v[1] * depth, v[2] * height
|
|
|
|
return verts, faces
|
|
|
|
|
|
class AddBox(bpy.types.Operator, AddObjectHelper):
|
|
"""Add a simple box mesh"""
|
|
bl_idname = "mesh.primitive_box_add"
|
|
bl_label = "Add Box"
|
|
bl_options = {'REGISTER', 'UNDO'}
|
|
|
|
width: FloatProperty(
|
|
name="Width",
|
|
description="Box Width",
|
|
min=0.01, max=100.0,
|
|
default=1.0,
|
|
)
|
|
height: FloatProperty(
|
|
name="Height",
|
|
description="Box Height",
|
|
min=0.01, max=100.0,
|
|
default=1.0,
|
|
)
|
|
depth: FloatProperty(
|
|
name="Depth",
|
|
description="Box Depth",
|
|
min=0.01, max=100.0,
|
|
default=1.0,
|
|
)
|
|
|
|
def execute(self, context):
|
|
|
|
verts_loc, faces = add_box(
|
|
self.width,
|
|
self.height,
|
|
self.depth,
|
|
)
|
|
|
|
mesh = bpy.data.meshes.new("Box")
|
|
|
|
bm = bmesh.new()
|
|
|
|
for v_co in verts_loc:
|
|
bm.verts.new(v_co)
|
|
|
|
bm.verts.ensure_lookup_table()
|
|
for f_idx in faces:
|
|
bm.faces.new([bm.verts[i] for i in f_idx])
|
|
|
|
bm.to_mesh(mesh)
|
|
mesh.update()
|
|
|
|
# add the mesh as an object into the scene with this utility module
|
|
from bpy_extras import object_utils
|
|
object_utils.object_data_add(context, mesh, operator=self)
|
|
|
|
return {'FINISHED'}
|
|
|
|
|
|
def menu_func(self, context):
|
|
self.layout.operator(AddBox.bl_idname, icon='MESH_CUBE')
|
|
|
|
|
|
# Register and add to the "add mesh" menu (required to use F3 search "Add Box" for quick access).
|
|
def register():
|
|
bpy.utils.register_class(AddBox)
|
|
bpy.types.VIEW3D_MT_mesh_add.append(menu_func)
|
|
|
|
|
|
def unregister():
|
|
bpy.utils.unregister_class(AddBox)
|
|
bpy.types.VIEW3D_MT_mesh_add.remove(menu_func)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
register()
|
|
|
|
# test call
|
|
bpy.ops.mesh.primitive_box_add()
|