[Bf-blender-cvs] [2ff490f9e3d] master: Fix: Crash Requesting GPU_SHADER_GPENCIL_FILL builtin shader.
Commit: 2ff490f9e3d61cfc5e18f1eb660aff80da7d021a Author: Jeroen Bakker Date: Mon Jun 28 08:51:37 2021 +0200 Branches: master https://developer.blender.org/rB2ff490f9e3d61cfc5e18f1eb660aff80da7d021a Fix: Crash Requesting GPU_SHADER_GPENCIL_FILL builtin shader. Shader doesn't have any shader code. Requesting the shader would crash blender. Solved by removing the enum_value. === M source/blender/gpu/GPU_shader.h === diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h index 3923c920c9e..f834ee5b234 100644 --- a/source/blender/gpu/GPU_shader.h +++ b/source/blender/gpu/GPU_shader.h @@ -366,7 +366,6 @@ typedef enum eGPUBuiltinShader { GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE, /* Uniformly scaled */ /* grease pencil drawing */ GPU_SHADER_GPENCIL_STROKE, - GPU_SHADER_GPENCIL_FILL, /* specialized for widget drawing */ GPU_SHADER_2D_AREA_EDGES, GPU_SHADER_2D_WIDGET_BASE, ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f53bd31690a] master: Cleanup GPU/Draw test cases.
Commit: f53bd31690ad9e1ba91f0a23d8a3cdd6519c9cf7 Author: Jeroen Bakker Date: Mon Jun 28 08:28:56 2021 +0200 Branches: master https://developer.blender.org/rBf53bd31690ad9e1ba91f0a23d8a3cdd6519c9cf7 Cleanup GPU/Draw test cases. In preparation of supporting vulkan. Draw/GPU tests should use GPU_TEST or DRAW_TEST macros. These macros will run the test on available drawing context backends like OpenGL or Vulkan. As in master there is only an OpenGL backend nothing changed. === M source/blender/draw/tests/draw_testing.cc M source/blender/draw/tests/draw_testing.hh M source/blender/draw/tests/shaders_test.cc M source/blender/gpu/tests/gpu_index_buffer_test.cc M source/blender/gpu/tests/gpu_shader_test.cc M source/blender/gpu/tests/gpu_testing.hh === diff --git a/source/blender/draw/tests/draw_testing.cc b/source/blender/draw/tests/draw_testing.cc index 0104437e921..45a857e7577 100644 --- a/source/blender/draw/tests/draw_testing.cc +++ b/source/blender/draw/tests/draw_testing.cc @@ -9,9 +9,9 @@ namespace blender::draw { /* Base class for draw test cases. It will setup and tear down the GPU part around each test. */ -void DrawTest::SetUp() +void DrawOpenGLTest::SetUp() { - GPUTest::SetUp(); + GPUOpenGLTest::SetUp(); DRW_draw_state_init_gtests(GPU_SHADER_CFG_DEFAULT); } diff --git a/source/blender/draw/tests/draw_testing.hh b/source/blender/draw/tests/draw_testing.hh index ec0b15b611e..00f0ac5bab7 100644 --- a/source/blender/draw/tests/draw_testing.hh +++ b/source/blender/draw/tests/draw_testing.hh @@ -5,9 +5,15 @@ namespace blender::draw { /* Base class for draw test cases. It will setup and tear down the GPU part around each test. */ -class DrawTest : public blender::gpu::GPUTest { +class DrawOpenGLTest : public blender::gpu::GPUOpenGLTest { public: void SetUp() override; }; +#define DRAW_TEST(test_name) \ + TEST_F(DrawOpenGLTest, test_name) \ + { \ +test_##test_name(); \ + } + } // namespace blender::draw diff --git a/source/blender/draw/tests/shaders_test.cc b/source/blender/draw/tests/shaders_test.cc index cce69714f5e..0c7cbd4dac8 100644 --- a/source/blender/draw/tests/shaders_test.cc +++ b/source/blender/draw/tests/shaders_test.cc @@ -22,7 +22,7 @@ namespace blender::draw { -TEST_F(DrawTest, workbench_glsl_shaders) +static void test_workbench_glsl_shaders() { workbench_shader_library_ensure(); @@ -155,8 +155,9 @@ TEST_F(DrawTest, workbench_glsl_shaders) workbench_shader_free(); } +DRAW_TEST(workbench_glsl_shaders) -TEST_F(DrawTest, gpencil_glsl_shaders) +static void test_gpencil_glsl_shaders() { EXPECT_NE(GPENCIL_shader_antialiasing(0), nullptr); EXPECT_NE(GPENCIL_shader_antialiasing(1), nullptr); @@ -177,8 +178,9 @@ TEST_F(DrawTest, gpencil_glsl_shaders) GPENCIL_shader_free(); } +DRAW_TEST(gpencil_glsl_shaders) -TEST_F(DrawTest, image_glsl_shaders) +static void test_image_glsl_shaders() { IMAGE_shader_library_ensure(); @@ -187,8 +189,9 @@ TEST_F(DrawTest, image_glsl_shaders) IMAGE_shader_free(); } +DRAW_TEST(image_glsl_shaders) -TEST_F(DrawTest, overlay_glsl_shaders) +static void test_overlay_glsl_shaders() { OVERLAY_shader_library_ensure(); @@ -280,8 +283,9 @@ TEST_F(DrawTest, overlay_glsl_shaders) OVERLAY_shader_free(); } +DRAW_TEST(overlay_glsl_shaders) -TEST_F(DrawTest, eevee_glsl_shaders_static) +static void test_eevee_glsl_shaders_static() { EEVEE_shaders_material_shaders_init(); @@ -370,6 +374,7 @@ TEST_F(DrawTest, eevee_glsl_shaders_static) EXPECT_NE(EEVEE_shaders_effect_reflection_resolve_sh_get(), nullptr); EEVEE_shaders_free(); } +DRAW_TEST(eevee_glsl_shaders_static) static void test_draw_shaders(eParticleRefineShaderType sh_type) { @@ -378,7 +383,7 @@ static void test_draw_shaders(eParticleRefineShaderType sh_type) DRW_shaders_free(); } -TEST_F(DrawTest, draw_glsl_shaders) +static void test_draw_glsl_shaders() { #ifndef __APPLE__ test_draw_shaders(PART_REFINE_SHADER_TRANSFORM_FEEDBACK); @@ -386,5 +391,6 @@ TEST_F(DrawTest, draw_glsl_shaders) #endif test_draw_shaders(PART_REFINE_SHADER_TRANSFORM_FEEDBACK_WORKAROUND); } +DRAW_TEST(draw_glsl_shaders) } // namespace blender::draw diff --git a/source/blender/gpu/tests/gpu_index_buffer_test.cc b/source/blender/gpu/tests/gpu_index_buffer_test.cc index 78e351af7f1..9d767b58a7b 100644 --- a/source/blender/gpu/tests/gpu_index_buffer_test.cc +++ b/source/blender/gpu/tests/gpu_index_buffer_test.cc @@ -10,7 +10,7 @@ namespace blender::gpu::tests { -TEST_F(GPUTest, gpu_index_buffer_subbuilders) +static void test_gpu_index_buffer_subbuilders() { const uint num_subbuilders = 10; const uint verts_per_subbuilders = 100; @@ -44,4 +44,6 @@ TEST_F(GPUTest, gpu_index_buffer_subbuilders) GPU_INDEXBUF_DISCARD_SAFE(index_buffer); } +GPU_TEST(gpu_
[Bf-blender-cvs] [b2cd225623d] master: GPU: Testcases for builtin shaders.
Commit: b2cd225623dfdf4be7bf74ac90e79b48ee639366 Author: Jeroen Bakker Date: Mon Jun 28 08:50:09 2021 +0200 Branches: master https://developer.blender.org/rBb2cd225623dfdf4be7bf74ac90e79b48ee639366 GPU: Testcases for builtin shaders. Adding compiler test (does it compile?) test for all builtin shaders. === M source/blender/gpu/CMakeLists.txt A source/blender/gpu/tests/gpu_shader_builtin_test.cc === diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 8468985309f..3754341fe33 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -396,6 +396,7 @@ if(WITH_GTESTS) tests/gpu_testing.cc tests/gpu_index_buffer_test.cc + tests/gpu_shader_builtin_test.cc tests/gpu_shader_test.cc tests/gpu_testing.hh diff --git a/source/blender/gpu/tests/gpu_shader_builtin_test.cc b/source/blender/gpu/tests/gpu_shader_builtin_test.cc new file mode 100644 index 000..f0061a6bf5c --- /dev/null +++ b/source/blender/gpu/tests/gpu_shader_builtin_test.cc @@ -0,0 +1,94 @@ +/* Apache License, Version 2.0 */ + +#include "gpu_testing.hh" + +#include "GPU_shader.h" + +namespace blender::gpu::tests { + +static void test_compile_builtin_shader(eGPUBuiltinShader shader_type, eGPUShaderConfig sh_cfg) +{ + GPUShader *sh = GPU_shader_get_builtin_shader_with_config(shader_type, sh_cfg); + EXPECT_NE(sh, nullptr); +} + +static void test_compile_builtin_shader(eGPUBuiltinShader shader_type) +{ + test_compile_builtin_shader(shader_type, GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(shader_type, GPU_SHADER_CFG_CLIPPED); +} + +static void test_shader_builtin() +{ + GPU_shader_free_builtin_shaders(); + + test_compile_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR); + test_compile_builtin_shader(GPU_SHADER_3D_SMOOTH_COLOR); + test_compile_builtin_shader(GPU_SHADER_3D_DEPTH_ONLY); + test_compile_builtin_shader(GPU_SHADER_3D_FLAT_COLOR); + test_compile_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE); + test_compile_builtin_shader(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR); + test_compile_builtin_shader(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA); + test_compile_builtin_shader(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA); + + test_compile_builtin_shader(GPU_SHADER_TEXT, GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(GPU_SHADER_KEYFRAME_DIAMOND, GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(GPU_SHADER_SIMPLE_LIGHTING, GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(GPU_SHADER_2D_UNIFORM_COLOR, GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(GPU_SHADER_2D_FLAT_COLOR, GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(GPU_SHADER_2D_SMOOTH_COLOR, GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(GPU_SHADER_2D_IMAGE, GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(GPU_SHADER_2D_IMAGE_COLOR, GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(GPU_SHADER_2D_IMAGE_DESATURATE_COLOR, GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(GPU_SHADER_2D_IMAGE_RECT_COLOR, GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(GPU_SHADER_2D_IMAGE_MULTI_RECT_COLOR, GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(GPU_SHADER_2D_CHECKER, GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(GPU_SHADER_2D_DIAG_STRIPES, GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR, GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR, GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(GPU_SHADER_3D_POLYLINE_CLIPPED_UNIFORM_COLOR, + GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(GPU_SHADER_3D_POLYLINE_FLAT_COLOR, GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(GPU_SHADER_3D_POLYLINE_SMOOTH_COLOR, GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(GPU_SHADER_2D_IMAGE_OVERLAYS_MERGE, GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(GPU_SHADER_2D_IMAGE_OVERLAYS_STEREO_MERGE, GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR, GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(GPU_SHADER_2D_POINT_FIXED_SIZE_UNIFORM_COLOR, + GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(GPU_SHADER_2D_POINT_UNIFORM_SIZE_VARYING_COLOR_OUTLINE_AA, + GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(GPU_SHADER_2D_POINT_VARYING_SIZE_VARYING_COLOR, + GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(GPU_SHADER_3D_POINT_FIXED_SIZE_UNIFORM_COLOR, + GPU_SHADER_CFG_DEFAULT); + test_compile_builtin_shader(GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA, + GPU_SHADER_
[Bf-blender-cvs] [02d8f6a6463] soc-2021-adaptive-cloth: adaptive_cloth: Mesh: write()
Commit: 02d8f6a6463d25647b099c94e6e204bce04b3e3c Author: ishbosamiya Date: Thu Jun 24 20:19:55 2021 +0530 Branches: soc-2021-adaptive-cloth https://developer.blender.org/rB02d8f6a6463d25647b099c94e6e204bce04b3e3c adaptive_cloth: Mesh: write() Creates a MeshIO object. There are limitations for this as of right now, check inline comments for details (is a todo), the basic problem is if the arena has `EntryNoExist` in between elements. This will cause major problems. === M source/blender/blenkernel/BKE_cloth_remesh.hh M source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc === diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh index 044ec8725f5..9f99e0bc6c3 100644 --- a/source/blender/blenkernel/BKE_cloth_remesh.hh +++ b/source/blender/blenkernel/BKE_cloth_remesh.hh @@ -421,6 +421,31 @@ class MeshIO { } } + void set_positions(blender::Vector &&positions) + { +this->positions = std::move(positions); + } + + void set_uvs(blender::Vector &&uvs) + { +this->uvs = std::move(uvs); + } + + void set_normals(blender::Vector &&normals) + { +this->normals = std::move(normals); + } + + void set_face_indices(blender::Vector> &&face_indices) + { +this->face_indices = std::move(face_indices); + } + + void set_line_indices(blender::Vector> &&line_indices) + { +this->line_indices = std::move(line_indices); + } + const auto &get_positions() const { return this->positions; @@ -796,6 +821,80 @@ template class Mesh { } /* TODO(ish): add support for lines */ + +/* TODO(ish): ensure normal information properly, right now need + * to just assume it is not dirty for faster development */ +this->node_normals_dirty = false; + } + + MeshIO write() const + { +using FaceData = std::tuple; +blender::Vector positions; +blender::Vector uvs; +blender::Vector normals; +blender::Vector> face_indices; +blender::Vector> line_indices; + +/* TODO(ish): drain all nodes, verts, edges, and faces into a new + * arena, and update the self indices. Some operations (such as + * collapse edges) can cause gaps in the arena which isn't + * acceptable here. It is more than just updating the self + * indices because the references would break then. There must be + * a simple way to do this but can't think of one right now. + * Maybe just go through the whole arena, assigning incrementing + * position data. Need to decide if drain and store in a wrapped + * datatype or always store or store that info in a map. + * + * As of now, using the index directly, assuming no gaps */ + +/* TODO(ish): this assert should change to some sort of error + * handled thing */ +BLI_assert(this->node_normals_dirty == false); + +for (const auto &node : this->nodes) { + auto pos = node.pos; + positions.append(pos); + + auto normal = node.normal; + normals.append(normal); +} + +for (const auto &vert : this->verts) { + auto uv = vert.uv; + uvs.append(uv); +} + +for (const auto &face : this->faces) { + blender::Vector io_face; + + for (const auto &vert_index : face.verts) { +auto op_vert = this->verts.get(vert_index); +BLI_assert(op_vert); +const auto &vert = op_vert.value().get(); + +BLI_assert(vert.node); /* a vert cannot exist without a node */ + +auto pos_index = std::get<0>(vert.node.value().get_raw()); +auto uv_index = std::get<0>(vert.self_index.get_raw()); +auto normal_index = pos_index; + +io_face.append(std::make_tuple(pos_index, uv_index, normal_index)); + } + + face_indices.append(io_face); +} + +/* TODO(ish): add support for lines */ + +MeshIO result; +result.set_positions(std::move(positions)); +result.set_uvs(std::move(uvs)); +result.set_normals(std::move(normals)); +result.set_face_indices(std::move(face_indices)); +result.set_line_indices(std::move(line_indices)); + +return result; } void read_obj(const fs::path &filepath) diff --git a/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc b/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc index 43b6ef5d4d4..a5c10067c6c 100644 --- a/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc +++ b/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc @@ -160,4 +160,31 @@ TEST(cloth_remesh, Mesh_Read) } } +TEST(cloth_remesh, Mesh_Write) +{ + MeshIO reader; + std::istringstream stream(cube_pos_uv_normal); + reader.read(std::move(stream), MeshIO::FILETYPE_OBJ); + + Mesh mesh; + mesh.read(reader); + + auto result = mesh.write(); + + const auto positions = result.get_positions(); + const auto uvs = result.get_uvs(); + const auto normals = result.get_normals()
[Bf-blender-cvs] [0126abfd6e9] soc-2021-adaptive-cloth: adaptive_cloth: MeshIO: write obj
Commit: 0126abfd6e9f0c33c9451f7543b3dfc37aff0be6 Author: ishbosamiya Date: Thu Jun 24 18:14:41 2021 +0530 Branches: soc-2021-adaptive-cloth https://developer.blender.org/rB0126abfd6e9f0c33c9451f7543b3dfc37aff0be6 adaptive_cloth: MeshIO: write obj === M source/blender/blenkernel/BKE_cloth_remesh.hh M source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc === diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh index bc3dba35997..044ec8725f5 100644 --- a/source/blender/blenkernel/BKE_cloth_remesh.hh +++ b/source/blender/blenkernel/BKE_cloth_remesh.hh @@ -389,6 +389,38 @@ class MeshIO { return true; } + bool write(const fs::path &filepath, FileType type) + { +if (type != FILETYPE_OBJ) { + return false; +} + +if (!fs::exists(filepath)) { + return false; +} + +std::fstream fout; +fout.open(filepath, std::ios::out); + +if (!fout.is_open()) { + return false; +} + +write(fout, type); + +return true; + } + + void write(std::ostream &out, FileType type) + { +if (type == FILETYPE_OBJ) { + this->write_obj(out); +} +else { + BLI_assert_unreachable(); +} + } + const auto &get_positions() const { return this->positions; @@ -414,6 +446,11 @@ class MeshIO { return this->line_indices; } + static constexpr inline auto invalid_index() + { +return std::numeric_limits::max(); + } + private: blender::Vector tokenize(std::string const &str, const char delim) { @@ -487,9 +524,8 @@ class MeshIO { std::istringstream isi(indices_str[0]); usize pos_index; isi >> pos_index; -face.append(std::make_tuple(pos_index - 1, -std::numeric_limits::max(), -std::numeric_limits::max())); +face.append( +std::make_tuple(pos_index - 1, MeshIO::invalid_index(), MeshIO::invalid_index())); } else if (indices_str.size() == 2) { std::istringstream isi_pos(indices_str[0]); @@ -498,8 +534,7 @@ class MeshIO { usize uv_index; isi_pos >> pos_index; isi_uv >> uv_index; -face.append( -std::make_tuple(pos_index - 1, uv_index - 1, std::numeric_limits::max())); +face.append(std::make_tuple(pos_index - 1, uv_index - 1, MeshIO::invalid_index())); } else if (indices_str.size() == 3) { std::istringstream isi_pos(indices_str[0]); @@ -544,6 +579,41 @@ class MeshIO { return true; } + + void write_obj(std::ostream &out) + { +for (const auto &pos : this->positions) { + out << "v " << pos.x << " " << pos.y << " " << pos.z << std::endl; +} + +for (const auto &uv : this->uvs) { + out << "vt " << uv.x << " " << uv.y << std::endl; +} + +for (const auto &normal : this->normals) { + out << "v " << normal.x << " " << normal.y << " " << normal.z << std::endl; +} + +for (const auto &face : this->face_indices) { + out << "f "; + for (const auto &[pos_index, uv_index, normal_index] : face) { +if (normal_index == MeshIO::invalid_index()) { + if (uv_index == MeshIO::invalid_index()) { +out << pos_index + 1 << " "; + } + else { +out << pos_index + 1 << "/" << uv_index + 1 << " "; + } +} +else { + out << pos_index + 1 << "/" << uv_index + 1 << "/" << normal_index + 1 << " "; +} + } + out << std::endl; +} + +/* TODO(ish): add line support */ + } }; template class Mesh { diff --git a/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc b/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc index a2e3b4a0760..43b6ef5d4d4 100644 --- a/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc +++ b/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc @@ -71,6 +71,55 @@ TEST(cloth_remesh, MeshIO_ReadObj) EXPECT_EQ(line_indices.size(), 0); } +TEST(cloth_remesh, MeshIO_WriteObj) +{ + MeshIO reader; + std::istringstream stream_in(cube_pos_uv_normal); + auto res = reader.read(std::move(stream_in), MeshIO::FILETYPE_OBJ); + EXPECT_TRUE(res); + + std::ostringstream stream_out; + reader.write(stream_out, MeshIO::FILETYPE_OBJ); + + std::string expected = + "v 1 1 -1\n" + "v 1 -1 -1\n" + "v 1 1 1\n" + "v 1 -1 1\n" + "v -1 1 -1\n" + "v -1 -1 -1\n" + "v -1 1 1\n" + "v -1 -1 1\n" + "vt 0.625 0.5\n" + "vt 0.875 0.5\n" + "vt 0.875 0.75\n" + "vt 0.625 0.75\n" + "vt 0.375 0.75\n" + "vt 0.625 1\n" + "vt 0.375 1\n" + "vt 0.375 0\n" + "vt 0.625 0\n" + "vt 0.625 0.25\n" + "v
[Bf-blender-cvs] [e28bb2266ba] soc-2021-adaptive-cloth: adaptive_cloth: mesh: fix failing test Mesh_Read
Commit: e28bb2266baf485233490e53a8ba7980455b32f3 Author: ishbosamiya Date: Thu Jun 24 13:35:57 2021 +0530 Branches: soc-2021-adaptive-cloth https://developer.blender.org/rBe28bb2266baf485233490e53a8ba7980455b32f3 adaptive_cloth: mesh: fix failing test Mesh_Read Turns out auto doesn't automatically use references even if the function is returning a reference, need to do `auto &`. === M source/blender/blenkernel/BKE_cloth_remesh.hh M source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc === diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh index dc1495ffb84..e1f100a3161 100644 --- a/source/blender/blenkernel/BKE_cloth_remesh.hh +++ b/source/blender/blenkernel/BKE_cloth_remesh.hh @@ -167,6 +167,11 @@ template class Node { this->extra_data = extra_data; } + const auto &get_verts() const + { +return this->verts; + } + friend std::ostream &operator<<(std::ostream &stream, const Node &node) { stream << "(self_index: " << node.self_index << ", verts: " << node.verts @@ -207,6 +212,16 @@ template class Vert { this->extra_data = extra_data; } + const auto &get_edges() const + { +return this->edges; + } + + auto get_node() const + { +return this->node; + } + friend std::ostream &operator<<(std::ostream &stream, const Vert &vert) { stream << "(self_index: " << vert.self_index << ", edges: " << vert.edges @@ -640,8 +655,8 @@ template class Mesh { auto op_node = this->nodes.get_no_gen(pos_index); BLI_assert(op_vert && op_node); -auto vert = op_vert.value().get(); -auto node = op_node.value().get(); +auto &vert = op_vert.value().get(); +auto &node = op_node.value().get(); vert.node = node.self_index; node.verts.append(vert.self_index); @@ -677,31 +692,33 @@ template class Mesh { face_edges.append(op_edge_index.value()); } else { - auto edge = this->add_empty_edge(); + auto &edge = this->add_empty_edge(); edge.verts = std::make_tuple(vert_1_index, vert_2_index); - auto vert_1 = this->verts.get(vert_1_index).value().get(); + auto &vert_1 = this->verts.get(vert_1_index).value().get(); vert_1.edges.append(edge.self_index); - auto vert_2 = this->verts.get(vert_2_index).value().get(); + auto &vert_2 = this->verts.get(vert_2_index).value().get(); vert_2.edges.append(edge.self_index); face_edges.append(edge.self_index); } + +face_verts.append(vert_1_index); } /* update faces */ { -auto face = this->add_empty_face(float3_unknown()); +auto &face = this->add_empty_face(float3_unknown()); -face.verts = face_verts; +face.verts = std::move(face_verts); for (const auto &edge_index : face_edges) { auto op_edge = this->edges.get(edge_index); BLI_assert(op_edge); - auto edge = op_edge.value().get(); + auto &edge = op_edge.value().get(); edge.faces.append(face.self_index); } diff --git a/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc b/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc index 3a2e4175964..f38ae45f425 100644 --- a/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc +++ b/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc @@ -80,15 +80,35 @@ TEST(cloth_remesh, Mesh_Read) Mesh mesh; mesh.read(reader); - const auto nodes = mesh.get_nodes(); - const auto verts = mesh.get_verts(); - const auto edges = mesh.get_edges(); - const auto faces = mesh.get_faces(); + const auto &nodes = mesh.get_nodes(); + const auto &verts = mesh.get_verts(); + const auto &edges = mesh.get_edges(); + const auto &faces = mesh.get_faces(); EXPECT_EQ(nodes.size(), 8); EXPECT_EQ(verts.size(), 14); - EXPECT_EQ(edges.size(), 12); + EXPECT_EQ(edges.size(), 19); EXPECT_EQ(faces.size(), 6); + + for (const auto &face : faces) { +EXPECT_EQ(face.get_verts().size(), 4); + } + + for (const auto &edge : edges) { +auto num_faces = edge.get_faces().size(); +EXPECT_TRUE(num_faces == 1 || num_faces == 2); + } + + for (const auto &vert : verts) { +auto num_edges = vert.get_edges().size(); +EXPECT_TRUE(num_edges >= 2 && num_edges <= 4); +EXPECT_NE(vert.get_node(), std::nullopt); + } + + for (const auto &node : nodes) { +auto num_verts = node.get_verts().size(); +EXPECT_TRUE(num_verts >= 1 && num_verts <= 3); + } } } /* namespace blender::bke::tests */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-c
[Bf-blender-cvs] [72ea9b9e06e] soc-2021-adaptive-cloth: adaptive_cloth: MeshReader to MeshIO
Commit: 72ea9b9e06ea1699232c4ab0731812945d87ae89 Author: ishbosamiya Date: Thu Jun 24 16:50:29 2021 +0530 Branches: soc-2021-adaptive-cloth https://developer.blender.org/rB72ea9b9e06ea1699232c4ab0731812945d87ae89 adaptive_cloth: MeshReader to MeshIO === M source/blender/blenkernel/BKE_cloth_remesh.hh M source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc === diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh index e1f100a3161..bc3dba35997 100644 --- a/source/blender/blenkernel/BKE_cloth_remesh.hh +++ b/source/blender/blenkernel/BKE_cloth_remesh.hh @@ -68,7 +68,7 @@ template class Vert; template class Edge; template class Face; template class Mesh; -class MeshReader; +class MeshIO; namespace ga = blender::generational_arena; namespace fs = std::filesystem; @@ -334,7 +334,7 @@ template class Face { template friend class Mesh; }; -class MeshReader { +class MeshIO { using FaceData = std::tuple; /* position, * uv, * normal */ @@ -350,7 +350,7 @@ class MeshReader { FILETYPE_OBJ, }; - MeshReader() = default; + MeshIO() = default; bool read(const fs::path &filepath, FileType type) { @@ -621,7 +621,7 @@ template class Mesh { return std::nullopt; } - void read(const MeshReader &reader) + void read(const MeshIO &reader) { const auto positions = reader.get_positions(); const auto uvs = reader.get_uvs(); @@ -730,8 +730,8 @@ template class Mesh { void read_obj(const fs::path &filepath) { -MeshReader reader; -const auto reader_success = reader.read(filepath, MeshReader::FILETYPE_OBJ); +MeshIO reader; +const auto reader_success = reader.read(filepath, MeshIO::FILETYPE_OBJ); BLI_assert(reader_success); /* must successfully load obj */ this->read(reader); diff --git a/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc b/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc index f38ae45f425..a2e3b4a0760 100644 --- a/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc +++ b/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc @@ -50,11 +50,11 @@ static const char *cube_pos_uv_normal = "f 2/13/5 1/1/5 3/4/5 4/5/5\n" "f 6/11/6 5/10/6 1/1/6 2/13/6\n"; -TEST(cloth_remesh, MeshReader_ReadObj) +TEST(cloth_remesh, MeshIO_ReadObj) { - MeshReader reader; + MeshIO reader; std::istringstream stream(cube_pos_uv_normal); - auto res = reader.read(std::move(stream), MeshReader::FILETYPE_OBJ); + auto res = reader.read(std::move(stream), MeshIO::FILETYPE_OBJ); EXPECT_TRUE(res); @@ -73,9 +73,9 @@ TEST(cloth_remesh, MeshReader_ReadObj) TEST(cloth_remesh, Mesh_Read) { - MeshReader reader; + MeshIO reader; std::istringstream stream(cube_pos_uv_normal); - reader.read(std::move(stream), MeshReader::FILETYPE_OBJ); + reader.read(std::move(stream), MeshIO::FILETYPE_OBJ); Mesh mesh; mesh.read(reader); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f60100b8ca4] soc-2021-adaptive-cloth: adaptive_cloth: operator << overload for debug printing
Commit: f60100b8ca4d8287e9b620b1a79d1fd3aae244c7 Author: ishbosamiya Date: Thu Jun 24 12:05:19 2021 +0530 Branches: soc-2021-adaptive-cloth https://developer.blender.org/rBf60100b8ca4d8287e9b620b1a79d1fd3aae244c7 adaptive_cloth: operator << overload for debug printing === M source/blender/blenkernel/BKE_cloth_remesh.hh M source/blender/blenlib/BLI_generational_arena.hh === diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh index 1d97503a147..a5856a7e4dc 100644 --- a/source/blender/blenkernel/BKE_cloth_remesh.hh +++ b/source/blender/blenkernel/BKE_cloth_remesh.hh @@ -49,6 +49,7 @@ void BKE_cloth_remesh(const struct Object *ob, # include # include # include +# include # include # include # include @@ -84,6 +85,27 @@ using EdgeVerts = std::tuple; using usize = uint64_t; +template std::ostream &operator<<(std::ostream &stream, const blender::Vector &vec) +{ + stream << "("; + for (const auto &i : vec) { +stream << i << ", "; + } + stream << "\b\b)"; + return stream; +} + +template std::ostream &operator<<(std::ostream &stream, const std::optional &option) +{ + if (option) { +stream << "Some(" << option << ")"; + } + else { +stream << "None"; + } + return stream; +} + /** * `Node`: Stores the worldspace/localspace coordinates of the * `Mesh`. Commonly called the vertex of the mesh (note: in this mesh @@ -110,6 +132,13 @@ template class Node { this->extra_data = extra_data; } + friend std::ostream &operator<<(std::ostream &stream, const Node &node) + { +stream << "(" << node.self_index << ", " << node.verts << ", " << node.pos << "," + << node.normal << ")"; +return stream; + } + template friend class Mesh; }; @@ -143,6 +172,13 @@ template class Vert { this->extra_data = extra_data; } + friend std::ostream &operator<<(std::ostream &stream, const Vert &vert) + { +stream << "(" << vert.self_index << ", " << vert.edges << ", " << vert.node << "," << vert.uv + << ")"; +return stream; + } + template friend class Mesh; }; @@ -189,6 +225,17 @@ template class Edge { return false; } + const auto &get_faces() const + { +return this->faces; + } + + friend std::ostream &operator<<(std::ostream &stream, const Edge &edge) + { +stream << "(" << edge.self_index << ", " << edge.faces << ", " << edge.verts << ")"; +return stream; + } + template friend class Mesh; }; @@ -221,6 +268,17 @@ template class Face { this->extra_data = extra_data; } + const auto &get_verts() const + { +return this->verts; + } + + friend std::ostream &operator<<(std::ostream &stream, const Face &face) + { +stream << "(" << face.self_index << ", " << face.verts << ", " << face.normal << ")"; +return stream; + } + template friend class Mesh; }; diff --git a/source/blender/blenlib/BLI_generational_arena.hh b/source/blender/blenlib/BLI_generational_arena.hh index 94738881404..ed065256c53 100644 --- a/source/blender/blenlib/BLI_generational_arena.hh +++ b/source/blender/blenlib/BLI_generational_arena.hh @@ -105,6 +105,12 @@ class Index { return std::make_tuple(this->index, this->generation); } + friend std::ostream &operator<<(std::ostream &stream, const Index &index) + { +stream << "(" << index.index << ", " << index.generation << ")"; +return stream; + } + template friend class Arena; }; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8bcd17be056] soc-2021-adaptive-cloth: adaptive_cloth: better debug print
Commit: 8bcd17be056947688e44851d066d0be886852afe Author: ishbosamiya Date: Thu Jun 24 13:27:59 2021 +0530 Branches: soc-2021-adaptive-cloth https://developer.blender.org/rB8bcd17be056947688e44851d066d0be886852afe adaptive_cloth: better debug print === M source/blender/blenkernel/BKE_cloth_remesh.hh === diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh index a5856a7e4dc..dc1495ffb84 100644 --- a/source/blender/blenkernel/BKE_cloth_remesh.hh +++ b/source/blender/blenkernel/BKE_cloth_remesh.hh @@ -87,6 +87,10 @@ using usize = uint64_t; template std::ostream &operator<<(std::ostream &stream, const blender::Vector &vec) { + if (vec.size() == 0) { +stream << "()"; +return stream; + } stream << "("; for (const auto &i : vec) { stream << i << ", "; @@ -95,10 +99,24 @@ template std::ostream &operator<<(std::ostream &stream, const blende return stream; } +template std::ostream &operator<<(std::ostream &stream, const ga::Arena &arena) +{ + if (arena.size() == 0) { +stream << "()"; +return stream; + } + stream << "("; + for (const auto &i : arena) { +stream << i << ", "; + } + stream << "\b\b)"; + return stream; +} + template std::ostream &operator<<(std::ostream &stream, const std::optional &option) { if (option) { -stream << "Some(" << option << ")"; +stream << "Some(" << option.value() << ")"; } else { stream << "None"; @@ -106,6 +124,23 @@ template std::ostream &operator<<(std::ostream &stream, const std::o return stream; } +template +constexpr std::ostream &operator<<(std::ostream &stream, const std::tuple &tuple) +{ + auto tuple_size = std::tuple_size>(); + + if (tuple_size == 0) { +stream << "()"; +return stream; + } + + stream << "("; + std::apply([&](const auto &... i) { ((stream << i << ", "), ...); }, tuple); + stream << "\b\b)"; + + return stream; +} + /** * `Node`: Stores the worldspace/localspace coordinates of the * `Mesh`. Commonly called the vertex of the mesh (note: in this mesh @@ -134,8 +169,8 @@ template class Node { friend std::ostream &operator<<(std::ostream &stream, const Node &node) { -stream << "(" << node.self_index << ", " << node.verts << ", " << node.pos << "," - << node.normal << ")"; +stream << "(self_index: " << node.self_index << ", verts: " << node.verts + << ", pos: " << node.pos << ", normal: " << node.normal << ")"; return stream; } @@ -174,8 +209,8 @@ template class Vert { friend std::ostream &operator<<(std::ostream &stream, const Vert &vert) { -stream << "(" << vert.self_index << ", " << vert.edges << ", " << vert.node << "," << vert.uv - << ")"; +stream << "(self_index: " << vert.self_index << ", edges: " << vert.edges + << ", node: " << vert.node << ", uv: " << vert.uv << ")"; return stream; } @@ -232,7 +267,8 @@ template class Edge { friend std::ostream &operator<<(std::ostream &stream, const Edge &edge) { -stream << "(" << edge.self_index << ", " << edge.faces << ", " << edge.verts << ")"; +stream << "(self_index: " << edge.self_index << ", faces: " << edge.faces + << ", verts: " << edge.verts << ")"; return stream; } @@ -275,7 +311,8 @@ template class Face { friend std::ostream &operator<<(std::ostream &stream, const Face &face) { -stream << "(" << face.self_index << ", " << face.verts << ", " << face.normal << ")"; +stream << "(self_index: " << face.self_index << ", verts: " << face.verts + << ", normal: " << face.normal << ")"; return stream; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b9fa792e081] soc-2021-adaptive-cloth: bli: generational_arena: ConstIterator
Commit: b9fa792e081d5d717a93a323364a99c29b9c11eb Author: ishbosamiya Date: Thu Jun 24 11:01:54 2021 +0530 Branches: soc-2021-adaptive-cloth https://developer.blender.org/rBb9fa792e081d5d717a93a323364a99c29b9c11eb bli: generational_arena: ConstIterator ConstIterator is an iterator where the Iterator cannot change the value stored by the iterator. === M source/blender/blenlib/BLI_generational_arena.hh M source/blender/blenlib/tests/BLI_generational_arena_test.cc === diff --git a/source/blender/blenlib/BLI_generational_arena.hh b/source/blender/blenlib/BLI_generational_arena.hh index 84c2b391445..94738881404 100644 --- a/source/blender/blenlib/BLI_generational_arena.hh +++ b/source/blender/blenlib/BLI_generational_arena.hh @@ -130,6 +130,7 @@ template< class Arena { public: class Iterator; + class ConstIterator; private: struct EntryNoExist; @@ -418,11 +419,21 @@ class Arena { return Iterator(this->data.begin(), this->data.begin(), this->data.end()); } + ConstIterator begin() const + { +return ConstIterator(this->data.begin(), this->data.begin(), this->data.end()); + } + Iterator end() { return Iterator(this->data.end(), this->data.begin(), this->data.end()); } + ConstIterator end() const + { +return ConstIterator(this->data.end(), this->data.begin(), this->data.end()); + } + class Iterator { public: using iterator_category = std::bidirectional_iterator_tag; @@ -519,6 +530,107 @@ class Arena { } }; + class ConstIterator { + public: +using iterator_category = std::bidirectional_iterator_tag; +using difference_type = std::ptrdiff_t; +using value_type = T; +using pointer = value_type *; +using const_pointer = const value_type *; +using reference = value_type &; +using const_reference = const value_type &; + + private: +const Entry *ptr; /* points to current position */ +const Entry *start; /* points to first element in the + * Arena::data, aka Arena::data.begin() */ +const Entry *end; /* points to last+1 element in the Arena::data, aka Arena::data.end()*/ + + public: +ConstIterator(const Entry *ptr, const Entry *start, const Entry *end) +{ + this->ptr = ptr; + this->start = start; + this->end = end; +} + +const_reference operator*() const +{ + if (auto val = std::get_if(this->ptr)) { +return val->value; + } + + BLI_assert_unreachable(); + + return std::get(*this->ptr).value; +} + +const_pointer operator->() +{ + return this->ptr; +} + +/* pre fix */ +ConstIterator &operator++() +{ + BLI_assert(this->ptr != this->end); + while (true) { +this->ptr++; + +if (this->ptr == this->end) { + break; +} + +if (auto val = std::get_if(this->ptr)) { + break; +} + } + return *this; +} + +ConstIterator &operator--() +{ + BLI_assert(this->ptr != this->start); + while (true) { +this->ptr--; + +if (this->ptr == this->start) { + break; +} + +if (auto val = std::get_if(this->ptr)) { + break; +} + } + return *this; +} + +/* post fix */ +ConstIterator operator++(int) +{ + ConstIterator temp = *this; + ++(*this); + return temp; +} + +ConstIterator operator--(int) +{ + ConstIterator temp = *this; + --(*this); + return temp; +} + +friend bool operator==(const ConstIterator &a, const ConstIterator &b) +{ + return a.start == b.start && a.end == b.end && a.ptr == b.ptr; +} + +friend bool operator!=(const ConstIterator &a, const ConstIterator &b) +{ + return a.start != b.start || a.end != b.end || a.ptr != b.ptr; +} + }; + protected: /* all protected static methods */ /* all protected non-static methods */ diff --git a/source/blender/blenlib/tests/BLI_generational_arena_test.cc b/source/blender/blenlib/tests/BLI_generational_arena_test.cc index 279480dbb44..a13ccc83cda 100644 --- a/source/blender/blenlib/tests/BLI_generational_arena_test.cc +++ b/source/blender/blenlib/tests/BLI_generational_arena_test.cc @@ -181,6 +181,29 @@ TEST(generational_arena, Iter2) EXPECT_NE(std::find(it, arena.end(), 4), arena.end()); } +TEST(generational_arena, Iter3) +{ + struct Foo { +int a; +int b; +Foo(int a, int b) : a(a), b(b) +{ +} + }; + Arena arena; + arena.insert(Foo(0, 0)); + arena.insert(Foo(1, 0)); + arena.insert(Foo(2, 0)); + arena.insert(Foo(3, 0)); + arena.insert(Foo(4, 0)); + + const Arena &arena_ref = arena; + + for (const auto &i : arena_ref) { +EXPECT_EQ(i.b, 0); + } +} + TEST(generational_arena, IterIncrement) { Arena arena; ___
[Bf-blender-cvs] [acdfde35986] soc-2021-adaptive-cloth: adaptive_cloth: test: mesh: read(), fails, need to find fix
Commit: acdfde359868ea715d6ea011b5bc8194e9fc93b7 Author: ishbosamiya Date: Thu Jun 24 10:30:00 2021 +0530 Branches: soc-2021-adaptive-cloth https://developer.blender.org/rBacdfde359868ea715d6ea011b5bc8194e9fc93b7 adaptive_cloth: test: mesh: read(), fails, need to find fix === M source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc === diff --git a/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc b/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc index 5e188b36ebb..3a2e4175964 100644 --- a/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc +++ b/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc @@ -8,51 +8,52 @@ namespace blender::bke::tests { using namespace internal; -TEST(cloth_remesh, MeshReader) +static const char *cube_pos_uv_normal = +"# Blender v3.0.0 Alpha OBJ File: ''\n" +"# www.blender.org\n" +"mtllib untitled.mtl\n" +"o Cube\n" +"v 1.00 1.00 -1.00\n" +"v 1.00 -1.00 -1.00\n" +"v 1.00 1.00 1.00\n" +"v 1.00 -1.00 1.00\n" +"v -1.00 1.00 -1.00\n" +"v -1.00 -1.00 -1.00\n" +"v -1.00 1.00 1.00\n" +"v -1.00 -1.00 1.00\n" +"vt 0.625000 0.50\n" +"vt 0.875000 0.50\n" +"vt 0.875000 0.75\n" +"vt 0.625000 0.75\n" +"vt 0.375000 0.75\n" +"vt 0.625000 1.00\n" +"vt 0.375000 1.00\n" +"vt 0.375000 0.00\n" +"vt 0.625000 0.00\n" +"vt 0.625000 0.25\n" +"vt 0.375000 0.25\n" +"vt 0.125000 0.50\n" +"vt 0.375000 0.50\n" +"vt 0.125000 0.75\n" +"vn 0. 1. 0.\n" +"vn 0. 0. 1.\n" +"vn -1. 0. 0.\n" +"vn 0. -1. 0.\n" +"vn 1. 0. 0.\n" +"vn 0. 0. -1.\n" +"usemtl Material\n" +"s off\n" +"f 1/1/1 5/2/1 7/3/1 3/4/1\n" +"f 4/5/2 3/4/2 7/6/2 8/7/2\n" +"f 8/8/3 7/9/3 5/10/3 6/11/3\n" +"f 6/12/4 2/13/4 4/5/4 8/14/4\n" +"f 2/13/5 1/1/5 3/4/5 4/5/5\n" +"f 6/11/6 5/10/6 1/1/6 2/13/6\n"; + +TEST(cloth_remesh, MeshReader_ReadObj) { MeshReader reader; - std::string file = - "# Blender v3.0.0 Alpha OBJ File: ''\n" - "# www.blender.org\n" - "mtllib untitled.mtl\n" - "o Cube\n" - "v 1.00 1.00 -1.00\n" - "v 1.00 -1.00 -1.00\n" - "v 1.00 1.00 1.00\n" - "v 1.00 -1.00 1.00\n" - "v -1.00 1.00 -1.00\n" - "v -1.00 -1.00 -1.00\n" - "v -1.00 1.00 1.00\n" - "v -1.00 -1.00 1.00\n" - "vt 0.625000 0.50\n" - "vt 0.875000 0.50\n" - "vt 0.875000 0.75\n" - "vt 0.625000 0.75\n" - "vt 0.375000 0.75\n" - "vt 0.625000 1.00\n" - "vt 0.375000 1.00\n" - "vt 0.375000 0.00\n" - "vt 0.625000 0.00\n" - "vt 0.625000 0.25\n" - "vt 0.375000 0.25\n" - "vt 0.125000 0.50\n" - "vt 0.375000 0.50\n" - "vt 0.125000 0.75\n" - "vn 0. 1. 0.\n" - "vn 0. 0. 1.\n" - "vn -1. 0. 0.\n" - "vn 0. -1. 0.\n" - "vn 1. 0. 0.\n" - "vn 0. 0. -1.\n" - "usemtl Material\n" - "s off\n" - "f 1/1/1 5/2/1 7/3/1 3/4/1\n" - "f 4/5/2 3/4/2 7/6/2 8/7/2\n" - "f 8/8/3 7/9/3 5/10/3 6/11/3\n" - "f 6/12/4 2/13/4 4/5/4 8/14/4\n" - "f 2/13/5 1/1/5 3/4/5 4/5/5\n" - "f 6/11/6 5/10/6 1/1/6 2/13/6\n"; - std::istringstream stream(file); + std::istringstream stream(cube_pos_uv_normal); auto res = reader.read(std::move(stream), MeshReader::FILETYPE_OBJ); EXPECT_TRUE(res); @@ -70,4 +71,24 @@ TEST(cloth_remesh, MeshReader) EXPECT_EQ(line_indices.size(), 0); } +TEST(cloth_remesh, Mesh_Read) +{ + MeshReader reader; + std::istringstream stream(cube_pos_uv_normal); + reader.read(std::move(stream), MeshReader::FILETYPE_OBJ); + + Mesh mesh; + mesh.read(reader); + + const auto nodes = mesh.get_nodes(); + const auto verts = mesh.get_verts(); + const auto edges = mesh.get_edges(); + const auto faces = mesh.get_faces(); + + EXPECT_EQ(nodes.size(), 8); + EXPECT_EQ(verts.size(), 14); + EXPECT_EQ(edges.size(), 12); + EXPECT_EQ(faces.size(), 6); +} + } /* namespace blender::bke::tests */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [4796acef66e] soc-2021-adaptive-cloth: adaptive_cloth: mesh: read obj to Mesh
Commit: 4796acef66e0c029927907d6b5650cfb6b60bd10 Author: ishbosamiya Date: Wed Jun 23 12:17:34 2021 +0530 Branches: soc-2021-adaptive-cloth https://developer.blender.org/rB4796acef66e0c029927907d6b5650cfb6b60bd10 adaptive_cloth: mesh: read obj to Mesh === M source/blender/blenkernel/BKE_cloth_remesh.hh === diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh index 05fe29404ec..8a4d739f465 100644 --- a/source/blender/blenkernel/BKE_cloth_remesh.hh +++ b/source/blender/blenkernel/BKE_cloth_remesh.hh @@ -82,6 +82,8 @@ using IncidentFaces = blender::Vector; using AdjacentVerts = IncidentVerts; using EdgeVerts = std::tuple; +using usize = uint64_t; + /** * `Node`: Stores the worldspace/localspace coordinates of the * `Mesh`. Commonly called the vertex of the mesh (note: in this mesh @@ -107,6 +109,8 @@ template class Node { { this->extra_data = extra_data; } + + template friend class Mesh; }; /** @@ -138,6 +142,8 @@ template class Vert { { this->extra_data = extra_data; } + + template friend class Mesh; }; /** @@ -170,6 +176,20 @@ template class Edge { { this->extra_data = extra_data; } + + bool has_vert(VertIndex vert_index) + { +if (this->verts) { + if (std::get<0>(this->verts.value()) == vert_index || + std::get<1>(this->verts.value()) == vert_index) { +return true; + } +} + +return false; + } + + template friend class Mesh; }; /** @@ -200,75 +220,11 @@ template class Face { { this->extra_data = extra_data; } -}; - -template class Mesh { - /* using declarations */ - /* static data members */ - /* non-static data members */ - ga::Arena> nodes; - ga::Arena> verts; - ga::Arena> edges; - ga::Arena> faces; - - public: - /* default constructor */ - Mesh() = default; - /* other constructors */ - /* copy constructor */ - /* move constructor */ - - /* destructor */ - - /* copy assignment operator */ - /* move assignment operator */ - /* other operator overloads */ - - /* all public static methods */ - /* all public non-static methods */ - - protected: - /* all protected static methods */ - /* all protected non-static methods */ - - private: - /* all private static methods */ - /* all private non-static methods */ - - Node &add_empty_node(float3 pos, float3 normal) - { -auto node_index = this->nodes.insert_with( -[=](NodeIndex index) { return Node(index, pos, normal); }); -return this->nodes.get(node_index); - } - - Vert &add_empty_vert(float2 uv) - { -auto vert_index = this->verts.insert_with( -[=](VertIndex index) { return Vert(index, uv); }); - -return this->verts.get(vert_index); - } - - Edge &add_empty_edge() - { -auto edge_index = this->edges.insert_with([=](EdgeIndex index) { return Edge(index); }); - -return this->edges.get(edge_index); - } - - Face &add_empty_face(float3 normal) - { -auto face_index = this->faces.insert_with( -[=](FaceIndex index) { return Face(index, normal); }); - -return this->faces.get(face_index); - } + template friend class Mesh; }; class MeshReader { - using usize = uint64_t; using FaceData = std::tuple; /* position, * uv, * normal */ @@ -318,6 +274,8 @@ class MeshReader { BLI_assert_unreachable(); } +/* TODO(ish): do some checks to ensure the data makes sense */ + return true; } @@ -478,6 +436,207 @@ class MeshReader { } }; +template class Mesh { + /* using declarations */ + /* static data members */ + /* non-static data members */ + ga::Arena> nodes; + ga::Arena> verts; + ga::Arena> edges; + ga::Arena> faces; + + bool node_normals_dirty; + bool face_normals_dirty; + + public: + /* default constructor */ + Mesh() = default; + + /* other constructors */ + /* copy constructor */ + /* move constructor */ + + /* destructor */ + + /* copy assignment operator */ + /* move assignment operator */ + /* other operator overloads */ + + /* all public static methods */ + /* all public non-static methods */ + std::optional get_connecting_edge_index(VertIndex vert_1_index, + VertIndex vert_2_index) + { +auto vert_1 = this->verts.get(vert_1_index); +if (vert_1 == std::nullopt) { + return std::nullopt; +} + +for (const auto &edge_index : vert_1.edges) { + auto edge = this->edges.get(edge_index); + + if (edge == std::nullopt) { +return std::nullopt; + } + + if (edge.has_vert(vert_2_index)) { +return edge_index; + } +} + +return std::nullopt; + } + + void read_obj(const fs::path &filepath) + { +MeshReader reader; +
[Bf-blender-cvs] [32441a7ae58] soc-2021-adaptive-cloth: adaptive_cloth: mesh_reader: initial setup
Commit: 32441a7ae58c7427cd887cd53f58cdd753694ed7 Author: ishbosamiya Date: Tue Jun 22 17:43:38 2021 +0530 Branches: soc-2021-adaptive-cloth https://developer.blender.org/rB32441a7ae58c7427cd887cd53f58cdd753694ed7 adaptive_cloth: mesh_reader: initial setup === M source/blender/blenkernel/BKE_cloth_remesh.hh === diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh index 53f56a4252d..dd0a72325ca 100644 --- a/source/blender/blenkernel/BKE_cloth_remesh.hh +++ b/source/blender/blenkernel/BKE_cloth_remesh.hh @@ -27,6 +27,7 @@ * reference http://graphics.berkeley.edu/papers/Narain-AAR-2012-11/index.html **/ +#include "BLI_assert.h" #ifdef __cplusplus extern "C" { #endif @@ -45,6 +46,10 @@ void BKE_cloth_remesh(const struct Object *ob, #ifdef __cplusplus +# include +# include +# include +# include # include # include "BLI_float2.hh" @@ -54,7 +59,15 @@ void BKE_cloth_remesh(const struct Object *ob, namespace blender::bke::internal { +template class Node; +template class Vert; +template class Edge; +template class Face; +template class Mesh; +class MeshReader; + namespace ga = blender::generational_arena; +namespace fs = std::filesystem; using NodeIndex = ga::Index; using VertIndex = ga::Index; @@ -250,6 +263,84 @@ template class Mesh { return this->faces.get(face_index); } }; + +class MeshReader { + using usize = uint64_t; + + blender::Vector positions; + blender::Vector uvs; + blender::Vector normals; + blender::Vector> face_indices; /* position, + * uv, + * normal */ + blender::Vector> line_indices; + + public: + enum FileType { +FILETYPE_OBJ, + }; + + MeshReader() = default; + + bool read(const fs::path &filepath, FileType type) + { +if (type != FILETYPE_OBJ) { + return false; +} + +if (!fs::exists(filepath)) { + return false; +} + +std::fstream fin; +fin.open(filepath, std::ios::in); + +if (!fin.is_open()) { + return false; +} + +if (type == FILETYPE_OBJ) { + this->read_obj(std::move(fin)); +} +else { + BLI_assert_unreachable(); +} + +return true; + } + + private: + void read_obj(std::fstream &&fin) + { +std::string line; +while (std::getline(fin, line)) { + if (line.rfind('#', 0) == 0) { +continue; + } + + if (line.rfind('v', 0) == 0) { +/* TODO(ish): process positions */ + } + else if (line.rfind("vt", 0) == 0) { +/* TODO(ish): process uvs */ + } + else if (line.rfind("vn", 0) == 0) { +/* TODO(ish): process normals */ + } + else if (line.rfind("f", 0) == 0) { +/* TODO(ish): process face indices */ + } + else if (line.rfind("l", 0) == 0) { +/* TODO(ish): process uvs */ + } + else { +/* unknown type, continuing */ +continue; + } +} + } +}; + } /* namespace blender::bke::internal */ #endif /* __cplusplus */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [3b28d1486ec] soc-2021-adaptive-cloth: adaptive_cloth: mesh: abstract out read over MeshReader and fix compiler errors
Commit: 3b28d1486ecc7601fe76129dd12ac90c4c9625b3 Author: ishbosamiya Date: Wed Jun 23 13:32:41 2021 +0530 Branches: soc-2021-adaptive-cloth https://developer.blender.org/rB3b28d1486ecc7601fe76129dd12ac90c4c9625b3 adaptive_cloth: mesh: abstract out read over MeshReader and fix compiler errors === M source/blender/blenkernel/BKE_cloth_remesh.hh === diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh index 8a4d739f465..1d97503a147 100644 --- a/source/blender/blenkernel/BKE_cloth_remesh.hh +++ b/source/blender/blenkernel/BKE_cloth_remesh.hh @@ -464,21 +464,45 @@ template class Mesh { /* all public static methods */ /* all public non-static methods */ + const auto &get_nodes() const + { +return this->nodes; + } + + const auto &get_verts() const + { +return this->verts; + } + + const auto &get_edges() const + { +return this->edges; + } + + const auto &get_faces() const + { +return this->faces; + } + std::optional get_connecting_edge_index(VertIndex vert_1_index, VertIndex vert_2_index) { -auto vert_1 = this->verts.get(vert_1_index); -if (vert_1 == std::nullopt) { +auto op_vert_1 = this->verts.get(vert_1_index); +if (op_vert_1 == std::nullopt) { return std::nullopt; } +auto vert_1 = op_vert_1.value().get(); + for (const auto &edge_index : vert_1.edges) { - auto edge = this->edges.get(edge_index); + auto op_edge = this->edges.get(edge_index); - if (edge == std::nullopt) { + if (op_edge == std::nullopt) { return std::nullopt; } + auto edge = op_edge.value().get(); + if (edge.has_vert(vert_2_index)) { return edge_index; } @@ -487,12 +511,8 @@ template class Mesh { return std::nullopt; } - void read_obj(const fs::path &filepath) + void read(const MeshReader &reader) { -MeshReader reader; -const auto reader_success = reader.read(filepath, MeshReader::FILETYPE_OBJ); -BLI_assert(reader_success); /* must successfully load obj */ - const auto positions = reader.get_positions(); const auto uvs = reader.get_uvs(); const auto normals = reader.get_normals(); @@ -521,9 +541,12 @@ template class Mesh { /* update verts and nodes */ for (const auto &[pos_index, uv_index, normal_index] : face_index_data) { -auto vert = this->verts.get_no_gen(uv_index); -auto node = this->node.get_no_gen(pos_index); -BLI_assert(vert && node); +auto op_vert = this->verts.get_no_gen(uv_index); +auto op_node = this->nodes.get_no_gen(pos_index); +BLI_assert(op_vert && op_node); + +auto vert = op_vert.value().get(); +auto node = op_node.value().get(); vert.node = node.self_index; node.verts.append(vert.self_index); @@ -535,35 +558,38 @@ template class Mesh { } /* update edges */ - auto vert_1_i = face_index_data[0]; - auto vert_2_i = face_index_data[0]; + auto vert_1_i = std::get<1>(face_index_data[0]); + auto vert_2_i = std::get<1>(face_index_data[0]); blender::Vector face_verts; blender::Vector face_edges; for (auto i = 1; i <= face_index_data.size(); i++) { vert_1_i = vert_2_i; if (i == face_index_data.size()) { - vert_2_i = face_index_data[0]; + vert_2_i = std::get<1>(face_index_data[0]); } else { - vert_2_i = face_index_data[i]; + vert_2_i = std::get<1>(face_index_data[i]); } -auto vert_1_index = this->verts.get_no_gen_index(vert_1_i); -auto vert_2_index = this->verts.get_no_gen_index(vert_2_i); -BLI_assert(vert_1_index && vert_2_index); +auto op_vert_1_index = this->verts.get_no_gen_index(vert_1_i); +auto op_vert_2_index = this->verts.get_no_gen_index(vert_2_i); +BLI_assert(op_vert_1_index && op_vert_2_index); + +auto vert_1_index = op_vert_1_index.value(); +auto vert_2_index = op_vert_2_index.value(); -if (auto edge_index = this->get_connecting_edge_index(vert_1_index, vert_2_index)) { - face_edges.append(edge_index); +if (auto op_edge_index = this->get_connecting_edge_index(vert_1_index, vert_2_index)) { + face_edges.append(op_edge_index.value()); } else { auto edge = this->add_empty_edge(); edge.verts = std::make_tuple(vert_1_index, vert_2_index); - auto vert_1 = this->verts.get(vert_1_index); + auto vert_1 = this->verts.get(vert_1_index).value().get(); vert_1.edges.append(edge.self_index); - auto vert_2 = this->verts.get(vert_2_index); + auto vert_2 = this->verts.get(vert_2_index).v
[Bf-blender-cvs] [255edfa5e15] soc-2021-adaptive-cloth: adaptive_cloth: fix: mesh_reader: obj: 'vt' considered under 'v'
Commit: 255edfa5e1554abdf5f55d454488f2e1d69271b7 Author: ishbosamiya Date: Tue Jun 22 23:32:25 2021 +0530 Branches: soc-2021-adaptive-cloth https://developer.blender.org/rB255edfa5e1554abdf5f55d454488f2e1d69271b7 adaptive_cloth: fix: mesh_reader: obj: 'vt' considered under 'v' Consider v 1.0 1.0 1.0 vt 1.0 1.0 Here, both lines start with "v" hence, if the check is, line starts with "v", it satisfies both, which is not correct. The correct check should be, line starts with "v ". === M source/blender/blenkernel/BKE_cloth_remesh.hh === diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh index f17cc7ff863..05fe29404ec 100644 --- a/source/blender/blenkernel/BKE_cloth_remesh.hh +++ b/source/blender/blenkernel/BKE_cloth_remesh.hh @@ -369,7 +369,7 @@ class MeshReader { continue; } - if (line.rfind('v', 0) == 0) { + if (line.rfind("v ", 0) == 0) { std::istringstream li(line); float x, y, z; std::string temp; @@ -380,7 +380,7 @@ class MeshReader { BLI_assert(temp == "v"); this->positions.append(float3(x, y, z)); } - else if (line.rfind("vt", 0) == 0) { + else if (line.rfind("vt ", 0) == 0) { std::istringstream li(line); float u, v; std::string temp; @@ -402,9 +402,11 @@ class MeshReader { BLI_assert(temp == "vn"); this->normals.append(float3(x, y, z)); } - else if (line.rfind("f", 0) == 0) { + else if (line.rfind("f ", 0) == 0) { const auto line_toks = this->tokenize(line, ' '); +BLI_assert(line_toks.size() != 0); + blender::Vector face; for (const auto *indices_group_iter = line_toks.begin() + 1; @@ -448,9 +450,10 @@ class MeshReader { } } +BLI_assert(line_toks[0] == "f"); this->face_indices.append(face); } - else if (line.rfind("l", 0) == 0) { + else if (line.rfind("l ", 0) == 0) { std::istringstream li(line); std::string temp; li >> temp; @@ -461,6 +464,8 @@ class MeshReader { indices.append(index - 1); /* obj starts from 1, we want to * start from 0 */ } + +BLI_assert(temp == "l"); this->line_indices.append(indices); } else { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [fed0cdf3cbf] soc-2021-adaptive-cloth: adaptive_cloth: test: MeshReader simple cube read
Commit: fed0cdf3cbf790c5d6ea3c4af6c942b51274f03e Author: ishbosamiya Date: Tue Jun 22 23:31:06 2021 +0530 Branches: soc-2021-adaptive-cloth https://developer.blender.org/rBfed0cdf3cbf790c5d6ea3c4af6c942b51274f03e adaptive_cloth: test: MeshReader simple cube read === M source/blender/blenkernel/BKE_cloth_remesh.hh M source/blender/blenkernel/CMakeLists.txt A source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc === diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh index c1aa319fdf7..f17cc7ff863 100644 --- a/source/blender/blenkernel/BKE_cloth_remesh.hh +++ b/source/blender/blenkernel/BKE_cloth_remesh.hh @@ -49,6 +49,7 @@ void BKE_cloth_remesh(const struct Object *ob, # include # include # include +# include # include # include # include @@ -302,8 +303,13 @@ class MeshReader { return false; } +return read(std::move(fin), type); + } + + bool read(std::istream &&in, FileType type) + { if (type == FILETYPE_OBJ) { - auto res = this->read_obj(std::move(fin)); + auto res = this->read_obj(std::move(in)); if (!res) { return false; } @@ -315,6 +321,31 @@ class MeshReader { return true; } + const auto &get_positions() const + { +return this->positions; + } + + const auto &get_uvs() const + { +return this->uvs; + } + + const auto &get_normals() const + { +return this->normals; + } + + const auto &get_face_indices() const + { +return this->face_indices; + } + + const auto &get_line_indices() const + { +return this->line_indices; + } + private: blender::Vector tokenize(std::string const &str, const char delim) { @@ -330,10 +361,10 @@ class MeshReader { return res; } - bool read_obj(std::fstream &&fin) + bool read_obj(std::istream &&in) { std::string line; -while (std::getline(fin, line)) { +while (std::getline(in, line)) { if (line.rfind('#', 0) == 0) { continue; } diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 112c1ccd164..a425f832600 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -773,6 +773,8 @@ if(WITH_GTESTS) intern/layer_test.cc intern/lib_id_test.cc intern/tracking_test.cc + +tests/BKE_cloth_remesh_test.cc ) set(TEST_INC ../editors/include diff --git a/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc b/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc new file mode 100644 index 000..5e188b36ebb --- /dev/null +++ b/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc @@ -0,0 +1,73 @@ +#include "BKE_cloth_remesh.hh" + +#include "testing/testing.h" +#include +#include + +namespace blender::bke::tests { + +using namespace internal; + +TEST(cloth_remesh, MeshReader) +{ + MeshReader reader; + std::string file = + "# Blender v3.0.0 Alpha OBJ File: ''\n" + "# www.blender.org\n" + "mtllib untitled.mtl\n" + "o Cube\n" + "v 1.00 1.00 -1.00\n" + "v 1.00 -1.00 -1.00\n" + "v 1.00 1.00 1.00\n" + "v 1.00 -1.00 1.00\n" + "v -1.00 1.00 -1.00\n" + "v -1.00 -1.00 -1.00\n" + "v -1.00 1.00 1.00\n" + "v -1.00 -1.00 1.00\n" + "vt 0.625000 0.50\n" + "vt 0.875000 0.50\n" + "vt 0.875000 0.75\n" + "vt 0.625000 0.75\n" + "vt 0.375000 0.75\n" + "vt 0.625000 1.00\n" + "vt 0.375000 1.00\n" + "vt 0.375000 0.00\n" + "vt 0.625000 0.00\n" + "vt 0.625000 0.25\n" + "vt 0.375000 0.25\n" + "vt 0.125000 0.50\n" + "vt 0.375000 0.50\n" + "vt 0.125000 0.75\n" + "vn 0. 1. 0.\n" + "vn 0. 0. 1.\n" + "vn -1. 0. 0.\n" + "vn 0. -1. 0.\n" + "vn 1. 0. 0.\n" + "vn 0. 0. -1.\n" + "usemtl Material\n" + "s off\n" + "f 1/1/1 5/2/1 7/3/1 3/4/1\n" + "f 4/5/2 3/4/2 7/6/2 8/7/2\n" + "f 8/8/3 7/9/3 5/10/3 6/11/3\n" + "f 6/12/4 2/13/4 4/5/4 8/14/4\n" + "f 2/13/5 1/1/5 3/4/5 4/5/5\n" + "f 6/11/6 5/10/6 1/1/6 2/13/6\n"; + std::istringstream stream(file); + auto res = reader.read(std::move(stream), MeshReader::FILETYPE_OBJ); + + EXPECT_TRUE(res); + + const auto positions = reader.get_positions(); + const auto uvs = reader.get_uvs(); + const auto normals = reader.get_normals(); + const auto face_indices = reader.get_face_indices(); + const auto line_indices = reader.get_line_indices(); + + EXPECT_EQ(positions.size(), 8); + EXPECT_EQ(uvs.size(), 14); + EXPECT_EQ(normals.size(), 6); + EXPECT
[Bf-blender-cvs] [2446e978df3] soc-2021-adaptive-cloth: adaptive_cloth: mesh_reader: obj parse
Commit: 2446e978df32322461e7f009d4e6beace086fa71 Author: ishbosamiya Date: Tue Jun 22 21:49:49 2021 +0530 Branches: soc-2021-adaptive-cloth https://developer.blender.org/rB2446e978df32322461e7f009d4e6beace086fa71 adaptive_cloth: mesh_reader: obj parse === M source/blender/blenkernel/BKE_cloth_remesh.hh === diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh index dd0a72325ca..c1aa319fdf7 100644 --- a/source/blender/blenkernel/BKE_cloth_remesh.hh +++ b/source/blender/blenkernel/BKE_cloth_remesh.hh @@ -49,6 +49,8 @@ void BKE_cloth_remesh(const struct Object *ob, # include # include # include +# include +# include # include # include @@ -266,13 +268,14 @@ template class Mesh { class MeshReader { using usize = uint64_t; + using FaceData = std::tuple; /* position, + * uv, + * normal */ blender::Vector positions; blender::Vector uvs; blender::Vector normals; - blender::Vector> face_indices; /* position, - * uv, - * normal */ + blender::Vector> face_indices; blender::Vector> line_indices; public: @@ -300,7 +303,10 @@ class MeshReader { } if (type == FILETYPE_OBJ) { - this->read_obj(std::move(fin)); + auto res = this->read_obj(std::move(fin)); + if (!res) { +return false; + } } else { BLI_assert_unreachable(); @@ -310,7 +316,21 @@ class MeshReader { } private: - void read_obj(std::fstream &&fin) + blender::Vector tokenize(std::string const &str, const char delim) + { +blender::Vector res; +// construct a stream from the string +std::stringstream ss(str); + +std::string s; +while (std::getline(ss, s, delim)) { + res.append(s); +} + +return res; + } + + bool read_obj(std::fstream &&fin) { std::string line; while (std::getline(fin, line)) { @@ -319,25 +339,106 @@ class MeshReader { } if (line.rfind('v', 0) == 0) { -/* TODO(ish): process positions */ +std::istringstream li(line); +float x, y, z; +std::string temp; +li >> temp >> x >> y >> z; +if (li.fail()) { + return false; +} +BLI_assert(temp == "v"); +this->positions.append(float3(x, y, z)); } else if (line.rfind("vt", 0) == 0) { -/* TODO(ish): process uvs */ +std::istringstream li(line); +float u, v; +std::string temp; +li >> temp >> u >> v; +if (li.fail()) { + return false; +} +BLI_assert(temp == "vt"); +this->uvs.append(float2(u, v)); } else if (line.rfind("vn", 0) == 0) { -/* TODO(ish): process normals */ +std::istringstream li(line); +float x, y, z; +std::string temp; +li >> temp >> x >> y >> z; +if (li.fail()) { + return false; +} +BLI_assert(temp == "vn"); +this->normals.append(float3(x, y, z)); } else if (line.rfind("f", 0) == 0) { -/* TODO(ish): process face indices */ +const auto line_toks = this->tokenize(line, ' '); + +blender::Vector face; + +for (const auto *indices_group_iter = line_toks.begin() + 1; + indices_group_iter != line_toks.end(); + indices_group_iter++) { + const auto indices_group = *indices_group_iter; + + auto indices_str = this->tokenize(indices_group, '/'); + if (indices_str.size() == 1) { +std::istringstream isi(indices_str[0]); +usize pos_index; +isi >> pos_index; +face.append(std::make_tuple(pos_index - 1, +std::numeric_limits::max(), +std::numeric_limits::max())); + } + else if (indices_str.size() == 2) { +std::istringstream isi_pos(indices_str[0]); +std::istringstream isi_uv(indices_str[1]); +usize pos_index; +usize uv_index; +isi_pos >> pos_index; +isi_uv >> uv_index; +face.append( +std::make_tuple(pos_index - 1, uv_index - 1, std::numeric_limits::max())); + } + else if (indices_str.size() == 3) { +std::istringstream isi_pos(indices_str[0]); +std::istringstream isi_uv(indices_str[1]); +std::istringstream isi_normal(indices_str[2]); +usize pos_index; +usize uv_index; +usize normal_index; +isi_pos >> pos_index; +isi_
[Bf-blender-cvs] [9457c541a55] soc-2021-adaptive-cloth: adaptive_cloth: mesh: add empty elements
Commit: 9457c541a55bfe8ab2cf6c3e34f7740c0c08e55a Author: ishbosamiya Date: Tue Jun 22 12:25:40 2021 +0530 Branches: soc-2021-adaptive-cloth https://developer.blender.org/rB9457c541a55bfe8ab2cf6c3e34f7740c0c08e55a adaptive_cloth: mesh: add empty elements === M source/blender/blenkernel/BKE_cloth_remesh.hh === diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh index 87631e68031..53f56a4252d 100644 --- a/source/blender/blenkernel/BKE_cloth_remesh.hh +++ b/source/blender/blenkernel/BKE_cloth_remesh.hh @@ -218,6 +218,37 @@ template class Mesh { private: /* all private static methods */ /* all private non-static methods */ + + Node &add_empty_node(float3 pos, float3 normal) + { +auto node_index = this->nodes.insert_with( +[=](NodeIndex index) { return Node(index, pos, normal); }); + +return this->nodes.get(node_index); + } + + Vert &add_empty_vert(float2 uv) + { +auto vert_index = this->verts.insert_with( +[=](VertIndex index) { return Vert(index, uv); }); + +return this->verts.get(vert_index); + } + + Edge &add_empty_edge() + { +auto edge_index = this->edges.insert_with([=](EdgeIndex index) { return Edge(index); }); + +return this->edges.get(edge_index); + } + + Face &add_empty_face(float3 normal) + { +auto face_index = this->faces.insert_with( +[=](FaceIndex index) { return Face(index, normal); }); + +return this->faces.get(face_index); + } }; } /* namespace blender::bke::internal */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ff2db09f552] soc-2021-adaptive-cloth: bli: generational_arena: add iterator support
Commit: ff2db09f55245077647ff953f7d63ccb40544b2c Author: ishbosamiya Date: Mon Jun 21 23:39:56 2021 +0530 Branches: soc-2021-adaptive-cloth https://developer.blender.org/rBff2db09f55245077647ff953f7d63ccb40544b2c bli: generational_arena: add iterator support Made as a bidirectional iterator since movement can be in both directions. Random access iterator is not possible since there can be gaps in between the elements. Had a very annoying bug- using the iterator with the standard library would throw an error "`iterator_category` not defined" even though it was defined. Spent a lot of time to realize that `difference_type` should also be defined but other types within the iterator class are optional. For some reason the compiler does not create the `iterator_trait` correctly if `difference_type` is missing but throws error about `iterator_category` which is extremely strange and time consuming to debug :( === M source/blender/blenlib/BLI_generational_arena.hh M source/blender/blenlib/tests/BLI_generational_arena_test.cc === diff --git a/source/blender/blenlib/BLI_generational_arena.hh b/source/blender/blenlib/BLI_generational_arena.hh index 2d588907a06..84c2b391445 100644 --- a/source/blender/blenlib/BLI_generational_arena.hh +++ b/source/blender/blenlib/BLI_generational_arena.hh @@ -52,12 +52,15 @@ */ /* TODO(ish): need to complete documentation */ +#include #include +#include #include #include #include #include +#include "BLI_assert.h" #include "BLI_vector.hh" #include "testing/testing.h" @@ -125,6 +128,10 @@ template< */ typename Allocator = GuardedAllocator> class Arena { + public: + class Iterator; + + private: struct EntryNoExist; struct EntryExist; /* using declarations */ @@ -406,6 +413,112 @@ class Arena { return static_cast(this->length); } + Iterator begin() + { +return Iterator(this->data.begin(), this->data.begin(), this->data.end()); + } + + Iterator end() + { +return Iterator(this->data.end(), this->data.begin(), this->data.end()); + } + + class Iterator { + public: +using iterator_category = std::bidirectional_iterator_tag; +using difference_type = std::ptrdiff_t; +using value_type = T; +using pointer = value_type *; +using reference = value_type &; + + private: +Entry *ptr; /* points to current position */ +Entry *start; /* points to first element in the + * Arena::data, aka Arena::data.begin() */ +Entry *end; /* points to last+1 element in the Arena::data, aka Arena::data.end()*/ + + public: +Iterator(Entry *ptr, Entry *start, Entry *end) : ptr(ptr), start(start), end(end) +{ +} + +reference operator*() const +{ + if (auto val = std::get_if(this->ptr)) { +return val->value; + } + + BLI_assert_unreachable(); + + return std::get(*this->ptr).value; +} + +pointer operator->() +{ + return this->ptr; +} + +/* pre fix */ +Iterator &operator++() +{ + BLI_assert(this->ptr != this->end); + while (true) { +this->ptr++; + +if (this->ptr == this->end) { + break; +} + +if (auto val = std::get_if(this->ptr)) { + break; +} + } + return *this; +} + +Iterator &operator--() +{ + BLI_assert(this->ptr != this->start); + while (true) { +this->ptr--; + +if (this->ptr == this->start) { + break; +} + +if (auto val = std::get_if(this->ptr)) { + break; +} + } + return *this; +} + +/* post fix */ +Iterator operator++(int) +{ + Iterator temp = *this; + ++(*this); + return temp; +} + +Iterator operator--(int) +{ + Iterator temp = *this; + --(*this); + return temp; +} + +friend bool operator==(const Iterator &a, const Iterator &b) +{ + return a.start == b.start && a.end == b.end && a.ptr == b.ptr; +} + +friend bool operator!=(const Iterator &a, const Iterator &b) +{ + return a.start != b.start || a.end != b.end || a.ptr != b.ptr; +} + }; + protected: /* all protected static methods */ /* all protected non-static methods */ diff --git a/source/blender/blenlib/tests/BLI_generational_arena_test.cc b/source/blender/blenlib/tests/BLI_generational_arena_test.cc index ead72f80f35..279480dbb44 100644 --- a/source/blender/blenlib/tests/BLI_generational_arena_test.cc +++ b/source/blender/blenlib/tests/BLI_generational_arena_test.cc @@ -2,7 +2,9 @@ #include "testing/testing.h" +#include #include +#include #include namespace blender::tests { @@ -145,6 +147,88 @@ TEST(generational_arena, GetNoGenIndex) EXPECT_EQ(arena.get_no_gen(2), std::nullopt); } +TEST(generational_arena, Iter) +{ + A
[Bf-blender-cvs] [11ad8fa732a] soc-2021-adaptive-cloth: adaptive_cloth: mesh elements, better constructors
Commit: 11ad8fa732ad78d2613aa2b7009af74ce0559dfa Author: ishbosamiya Date: Tue Jun 22 12:25:04 2021 +0530 Branches: soc-2021-adaptive-cloth https://developer.blender.org/rB11ad8fa732ad78d2613aa2b7009af74ce0559dfa adaptive_cloth: mesh elements, better constructors === M source/blender/blenkernel/BKE_cloth_remesh.hh === diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh index 236f2b87404..87631e68031 100644 --- a/source/blender/blenkernel/BKE_cloth_remesh.hh +++ b/source/blender/blenkernel/BKE_cloth_remesh.hh @@ -83,10 +83,8 @@ template class Node { public: Node(NodeIndex self_index, float3 pos, float3 normal) + : self_index(self_index), pos(pos), normal(normal) { -this->self_index = self_index; -this->pos = pos; -this->normal = normal; } void set_extra_data(T extra_data) @@ -116,10 +114,8 @@ template class Vert { std::optional extra_data; public: - Vert(VertIndex self_index, float2 uv) + Vert(VertIndex self_index, float2 uv) : self_index(self_index), uv(uv) { -this->self_index = self_index; -this->uv = uv; } void set_extra_data(T extra_data) @@ -150,9 +146,8 @@ template class Edge { std::optional extra_data; public: - Edge(EdgeIndex self_index) + Edge(EdgeIndex self_index) : self_index(self_index) { -this->self_index = self_index; } void set_extra_data(T extra_data) @@ -181,10 +176,8 @@ template class Face { std::optional extra_data; public: - Face(FaceIndex self_index, float3 normal) + Face(FaceIndex self_index, float3 normal) : self_index(self_index), normal(normal) { -this->self_index = self_index; -this->normal = normal; } void set_extra_data(T extra_data) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [1d8648b13a0] master: Cleanup: repeated terms in code comments & error messages
Commit: 1d8648b13a0667d338a4e60df004be7e41525968 Author: Campbell Barton Date: Mon Jun 28 15:44:12 2021 +1000 Branches: master https://developer.blender.org/rB1d8648b13a0667d338a4e60df004be7e41525968 Cleanup: repeated terms in code comments & error messages === M intern/cycles/bvh/bvh_node.h M intern/cycles/util/util_math_fast.h M intern/cycles/util/util_task.h M intern/ghost/intern/GHOST_SystemWin32.cpp M intern/itasc/kdl/frames.inl M intern/mantaflow/intern/manta_fluid_API.cpp M source/blender/blenkernel/BKE_customdata.h M source/blender/blenkernel/BKE_idtype.h M source/blender/blenkernel/intern/action.c M source/blender/blenkernel/intern/action_mirror.c M source/blender/blenkernel/intern/curve.c M source/blender/blenkernel/intern/geometry_set_instances.cc M source/blender/blenkernel/intern/gpencil_curve.c M source/blender/blenkernel/intern/image.c M source/blender/blenkernel/intern/mesh_boolean_convert.cc M source/blender/blenkernel/intern/mesh_mapping.c M source/blender/blenkernel/intern/mesh_mirror.c M source/blender/blenkernel/intern/object.c M source/blender/blenkernel/intern/unit.c M source/blender/blenkernel/intern/volume.cc M source/blender/blenkernel/nla_private.h M source/blender/blenlib/BLI_vector.hh M source/blender/blenlib/intern/BLI_kdopbvh.c M source/blender/blenlib/intern/kdtree_impl.h M source/blender/blenlib/intern/math_color.c M source/blender/blenlib/intern/mesh_intersect.cc M source/blender/blenlib/intern/stack.c M source/blender/blenlib/intern/string.c M source/blender/blenlib/tests/BLI_listbase_test.cc M source/blender/blenloader/intern/readfile.c M source/blender/bmesh/bmesh_class.h M source/blender/bmesh/intern/bmesh_mesh_normals.c M source/blender/bmesh/intern/bmesh_mods.c M source/blender/bmesh/intern/bmesh_query.c M source/blender/bmesh/operators/bmo_dupe.c M source/blender/bmesh/operators/bmo_hull.c M source/blender/bmesh/tools/bmesh_bevel.c M source/blender/compositor/intern/COM_CompositorContext.h M source/blender/draw/intern/draw_manager.c M source/blender/editors/animation/keyframes_edit.c M source/blender/editors/armature/armature_edit.c M source/blender/editors/armature/armature_relations.c M source/blender/editors/gpencil/gpencil_data.c M source/blender/editors/include/ED_view3d.h M source/blender/editors/interface/interface_handlers.c M source/blender/editors/interface/interface_templates.c M source/blender/editors/interface/interface_widgets.c M source/blender/editors/object/object_add.c M source/blender/editors/sculpt_paint/paint_image_proj.c M source/blender/editors/space_graph/graph_select.c M source/blender/editors/space_info/info_stats.c M source/blender/editors/space_view3d/space_view3d.c M source/blender/editors/space_view3d/view3d_fly.c M source/blender/editors/space_view3d/view3d_iterators.c M source/blender/editors/space_view3d/view3d_placement.c M source/blender/editors/space_view3d/view3d_walk.c M source/blender/editors/transform/transform_snap_object.c M source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp M source/blender/freestyle/intern/winged_edge/WEdge.h M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/blender/imbuf/intern/anim_movie.c M source/blender/makesdna/DNA_genfile.h M source/blender/makesrna/intern/rna_access_compare_override.c M source/blender/makesrna/intern/rna_action.c M source/blender/makesrna/intern/rna_fluid.c M source/blender/makesrna/intern/rna_internal_types.h M source/blender/makesrna/intern/rna_modifier.c M source/blender/nodes/NOD_derived_node_tree.hh M source/blender/nodes/NOD_geometry_exec.hh M source/blender/python/bmesh/bmesh_py_ops_call.c M source/blender/python/bmesh/bmesh_py_types.c M source/blender/python/generic/bgl.c M source/blender/python/generic/idprop_py_api.c M source/blender/python/generic/imbuf_py_api.c M source/blender/render/intern/engine.c M source/blender/sequencer/intern/render.c M source/blender/windowmanager/intern/wm_event_system.c M source/blender/windowmanager/intern/wm_stereo.c === diff --git a/intern/cycles/bvh/bvh_node.h b/intern/cycles/bvh/bvh_node.h index 797dd5b694e..b3b5c43a394 100644 --- a/intern/cycles/bvh/bvh_node.h +++ b/intern/cycles/bvh/bvh_node.h @@ -179,7 +179,7 @@ class InnerNode : public BVHNode { } /* NOTE: This function is only used during binary BVH builder, and it - * supposed to be configured to have 2 children which will be filled in in a + *
[Bf-blender-cvs] [7beb57f3bdf] master: Cleanup: update comments
Commit: 7beb57f3bdf5d40aa4a3581367625ac7312b42a8 Author: Campbell Barton Date: Mon Jun 28 16:02:52 2021 +1000 Branches: master https://developer.blender.org/rB7beb57f3bdf5d40aa4a3581367625ac7312b42a8 Cleanup: update comments === M source/blender/bmesh/intern/bmesh_operator_api_inline.h M source/blender/editors/interface/interface_align.c M source/blender/editors/space_view3d/view3d_fly.c M source/blender/editors/space_view3d/view3d_walk.c === diff --git a/source/blender/bmesh/intern/bmesh_operator_api_inline.h b/source/blender/bmesh/intern/bmesh_operator_api_inline.h index 43628f01bc8..85701a76433 100644 --- a/source/blender/bmesh/intern/bmesh_operator_api_inline.h +++ b/source/blender/bmesh/intern/bmesh_operator_api_inline.h @@ -22,15 +22,10 @@ #pragma once -/* tool flag API. never, ever ever should tool code put junk in - * header flags (element->head.flag), nor should they use - * element->head.eflag1/eflag2. instead, use this api to set - * flags. - * - * if you need to store a value per element, use a - * ghash or a mapping slot to do it. */ +/* Tool Flag API: Tool code must never put junk in header flags (#BMHeader.hflag) + * instead, use this API to set flags. + * If you need to store a value per element, use a #GHash or a mapping slot to do it. */ -/* flags 15 and 16 (1 << 14 and 1 << 15) are reserved for bmesh api use */ ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 2) BLI_INLINE short _bmo_elem_flag_test(BMesh *bm, const BMFlagLayer *oflags, const short oflag) { diff --git a/source/blender/editors/interface/interface_align.c b/source/blender/editors/interface/interface_align.c index 1f9c736a5f3..dbfdfbf7950 100644 --- a/source/blender/editors/interface/interface_align.c +++ b/source/blender/editors/interface/interface_align.c @@ -590,7 +590,8 @@ static void ui_block_align_calc_but(uiBut *first, short nr) /* rows == 0: 1 row, cols == 0: 1 column */ - /* note; how it uses 'flag' in loop below (either set it, or OR it) is confusing */ + /* NOTE: manipulation of 'flag' in the loop below is confusing. + * In some cases it's assigned, other times OR is used. */ for (but = first, prev = NULL; but && but->alignnr == nr; prev = but, but = but->next) { next = but->next; if (next && next->alignnr != nr) { diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index c0a95f24f08..3347de73d01 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -757,9 +757,6 @@ static int flyApply(bContext *C, FlyInfo *fly, bool is_confirm) #define FLY_ZUP_CORRECT_ACCEL 0.05f /* increase upright momentum each step */ #define FLY_SMOOTH_FAC 20.0f/* higher value less lag */ - /* fly mode - Shift+F - * a fly loop where the user can move the view as if they are flying - */ RegionView3D *rv3d = fly->rv3d; /* 3x3 copy of the view matrix so we can move along the view axis */ diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c index 84515d4a39b..370ed7d12cf 100644 --- a/source/blender/editors/space_view3d/view3d_walk.c +++ b/source/blender/editors/space_view3d/view3d_walk.c @@ -989,9 +989,6 @@ static int walkApply(bContext *C, WalkInfo *walk, bool is_confirm) #define WALK_MOVE_SPEED base_speed #define WALK_BOOST_FACTOR ((void)0, walk->speed_factor) - /* walk mode - Ctrl+Shift+F - * a walk loop where the user can move move the view as if they are in a walk game - */ RegionView3D *rv3d = walk->rv3d; ARegion *region = walk->region; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e94ec793417] master: Cleanup: use view3d_navigate prefix for walk/fly operators
Commit: e94ec7934173548f22bf1af24c16c301a777526b Author: Campbell Barton Date: Mon Jun 28 16:06:38 2021 +1000 Branches: master https://developer.blender.org/rBe94ec7934173548f22bf1af24c16c301a777526b Cleanup: use view3d_navigate prefix for walk/fly operators Use matching file-name prefix as these operators are closely related. === M source/blender/editors/space_view3d/CMakeLists.txt M source/blender/editors/space_view3d/view3d_intern.h R099source/blender/editors/space_view3d/view3d_fly.c source/blender/editors/space_view3d/view3d_navigate_fly.c R099source/blender/editors/space_view3d/view3d_walk.c source/blender/editors/space_view3d/view3d_navigate_walk.c === diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt index 9242fc15021..fe84a3b8ae9 100644 --- a/source/blender/editors/space_view3d/CMakeLists.txt +++ b/source/blender/editors/space_view3d/CMakeLists.txt @@ -46,7 +46,6 @@ set(SRC view3d_camera_control.c view3d_draw.c view3d_edit.c - view3d_fly.c view3d_gizmo_armature.c view3d_gizmo_camera.c view3d_gizmo_empty.c @@ -60,6 +59,8 @@ set(SRC view3d_gizmo_tool_generic.c view3d_header.c view3d_iterators.c + view3d_navigate_fly.c + view3d_navigate_walk.c view3d_ops.c view3d_placement.c view3d_project.c @@ -67,7 +68,6 @@ set(SRC view3d_snap.c view3d_utils.c view3d_view.c - view3d_walk.c view3d_intern.h ) diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 0964c2dcbcc..ab80928e0c1 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -111,11 +111,11 @@ void view3d_ndof_fly(const struct wmNDOFMotionData *ndof, bool *r_has_rotate); #endif /* WITH_INPUT_NDOF */ -/* view3d_fly.c */ +/* view3d_navigate_fly.c */ void view3d_keymap(struct wmKeyConfig *keyconf); void VIEW3D_OT_fly(struct wmOperatorType *ot); -/* view3d_walk.c */ +/* view3d_navigate_walk.c */ void VIEW3D_OT_walk(struct wmOperatorType *ot); /* view3d_draw.c */ diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_navigate_fly.c similarity index 99% rename from source/blender/editors/space_view3d/view3d_fly.c rename to source/blender/editors/space_view3d/view3d_navigate_fly.c index 3347de73d01..fd4fd5051b1 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_navigate_fly.c @@ -19,7 +19,7 @@ * * Interactive fly navigation modal operator (flying around in space). * - * \note Similar logic to `view3d_walk.c` changes here may apply there too. + * \note Similar logic to `view3d_navigate_walk.c` changes here may apply there too. */ /* defines VIEW3D_OT_fly modal operator */ diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_navigate_walk.c similarity index 99% rename from source/blender/editors/space_view3d/view3d_walk.c rename to source/blender/editors/space_view3d/view3d_navigate_walk.c index 370ed7d12cf..33cb6aad400 100644 --- a/source/blender/editors/space_view3d/view3d_walk.c +++ b/source/blender/editors/space_view3d/view3d_navigate_walk.c @@ -20,7 +20,7 @@ * Interactive walk navigation modal operator * (similar to walking around in a first person game). * - * \note Similar logic to `view3d_fly.c` changes here may apply there too. + * \note Similar logic to `view3d_navigate_fly.c` changes here may apply there too. */ /* defines VIEW3D_OT_navigate - walk modal operator */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6f42e69b58c] master: Cleanup: de-duplicate 3D-view depth calculation function
Commit: 6f42e69b58ce4b9a2f0370d22b41f1c76bf21f89 Author: Campbell Barton Date: Mon Jun 28 15:44:16 2021 +1000 Branches: master https://developer.blender.org/rB6f42e69b58ce4b9a2f0370d22b41f1c76bf21f89 Cleanup: de-duplicate 3D-view depth calculation function === M source/blender/editors/gpencil/annotate_paint.c M source/blender/editors/gpencil/gpencil_paint.c M source/blender/editors/include/ED_view3d.h M source/blender/editors/space_view3d/view3d_project.c === diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index 69b21731284..7b995c545ba 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -1079,17 +1079,6 @@ static void annotation_free_stroke(bGPDframe *gpf, bGPDstroke *gps) BLI_freelinkN(&gpf->strokes, gps); } -/** - * Which which point is in front (result should only be used for comparison). - */ -static float view3d_point_depth(const RegionView3D *rv3d, const float co[3]) -{ - if (rv3d->is_persp) { -return ED_view3d_calc_zfac(rv3d, co, NULL); - } - return -dot_v3v3(rv3d->viewinv[2], co); -} - /* only erase stroke points that are visible (3d view) */ static bool annotation_stroke_eraser_is_occluded(tGPsdata *p, const bGPDspoint *pt, @@ -1102,8 +1091,8 @@ static bool annotation_stroke_eraser_is_occluded(tGPsdata *p, float mval_3d[3]; if (ED_view3d_autodist_simple(p->region, mval_i, mval_3d, 0, NULL)) { - const float depth_mval = view3d_point_depth(rv3d, mval_3d); - const float depth_pt = view3d_point_depth(rv3d, &pt->x); + const float depth_mval = ED_view3d_calc_depth_for_comparison(rv3d, mval_3d); + const float depth_pt = ED_view3d_calc_depth_for_comparison(rv3d, &pt->x); if (depth_pt > depth_mval) { return true; diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index d0c0933c5be..409d10996d0 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1319,17 +1319,6 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p) /* --- 'Eraser' for 'Paint' Tool -- */ -/** - * Which which point is in front (result should only be used for comparison). - */ -static float view3d_point_depth(const RegionView3D *rv3d, const float co[3]) -{ - if (rv3d->is_persp) { -return ED_view3d_calc_zfac(rv3d, co, NULL); - } - return -dot_v3v3(rv3d->viewinv[2], co); -} - /* only erase stroke points that are visible */ static bool gpencil_stroke_eraser_is_occluded( tGPsdata *p, bGPDlayer *gpl, bGPDspoint *pt, const int x, const int y) @@ -1359,10 +1348,10 @@ static bool gpencil_stroke_eraser_is_occluded( BKE_gpencil_layer_transform_matrix_get(p->depsgraph, obact, gpl, diff_mat); if (ED_view3d_autodist_simple(p->region, mval_i, mval_3d, 0, NULL)) { - const float depth_mval = view3d_point_depth(rv3d, mval_3d); + const float depth_mval = ED_view3d_calc_depth_for_comparison(rv3d, mval_3d); mul_v3_m4v3(fpt, diff_mat, &pt->x); - const float depth_pt = view3d_point_depth(rv3d, fpt); + const float depth_pt = ED_view3d_calc_depth_for_comparison(rv3d, fpt); /* Checked occlusion flag. */ pt->flag |= GP_SPOINT_TEMP_TAG; diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 98994feaf38..2c958d282f9 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -366,6 +366,8 @@ float ED_view3d_pixel_size(const struct RegionView3D *rv3d, const float co[3]); float ED_view3d_pixel_size_no_ui_scale(const struct RegionView3D *rv3d, const float co[3]); float ED_view3d_calc_zfac(const struct RegionView3D *rv3d, const float co[3], bool *r_flip); +float ED_view3d_calc_depth_for_comparison(const struct RegionView3D *rv3d, const float co[3]); + bool ED_view3d_clip_segment(const struct RegionView3D *rv3d, float ray_start[3], float ray_end[3]); bool ED_view3d_win_to_ray_clipped(struct Depsgraph *depsgraph, const struct ARegion *region, diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c index 49da1764660..8a900a4e898 100644 --- a/source/blender/editors/space_view3d/view3d_project.c +++ b/source/blender/editors/space_view3d/view3d_project.c @@ -330,6 +330,17 @@ float ED_view3d_calc_zfac(const RegionView3D *rv3d, const float co[3], bool *r_f return zfac; } +/** + * Calculate a depth value from `co` (result should only be used for comparison). + */ +float ED_view3d_calc_depth_for_comparison(const RegionView3D *rv3d, const float co[3]) +{ + if (rv3
[Bf-blender-cvs] [7efc87dcd21] master: Cleanup: typos in RNA enums
Commit: 7efc87dcd2162b9294cb84512b7445fe1565f058 Author: Campbell Barton Date: Mon Jun 28 15:44:14 2021 +1000 Branches: master https://developer.blender.org/rB7efc87dcd2162b9294cb84512b7445fe1565f058 Cleanup: typos in RNA enums === M source/blender/makesrna/intern/rna_context.c M source/blender/makesrna/intern/rna_nodetree.c === diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c index e6dceb5af72..4079406e64b 100644 --- a/source/blender/makesrna/intern/rna_context.c +++ b/source/blender/makesrna/intern/rna_context.c @@ -36,7 +36,7 @@ const EnumPropertyItem rna_enum_context_mode_items[] = { {CTX_MODE_EDIT_MESH, "EDIT_MESH", 0, "Mesh Edit", ""}, {CTX_MODE_EDIT_CURVE, "EDIT_CURVE", 0, "Curve Edit", ""}, {CTX_MODE_EDIT_SURFACE, "EDIT_SURFACE", 0, "Surface Edit", ""}, -{CTX_MODE_EDIT_TEXT, "EDIT_TEXT", 0, "Edit Edit", ""}, +{CTX_MODE_EDIT_TEXT, "EDIT_TEXT", 0, "Text Edit", ""}, /* PARSKEL reuse will give issues */ {CTX_MODE_EDIT_ARMATURE, "EDIT_ARMATURE", 0, "Armature Edit", ""}, {CTX_MODE_EDIT_METABALL, "EDIT_METABALL", 0, "Metaball Edit", ""}, diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index c26e9e883d6..13abadf809b 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -374,7 +374,7 @@ const EnumPropertyItem rna_enum_node_clamp_items[] = { static const EnumPropertyItem rna_enum_node_tex_dimensions_items[] = { {1, "1D", 0, "1D", "Use the scalar value W as input"}, {2, "2D", 0, "2D", "Use the 2D vector (x, y) as input. The z component is ignored"}, -{3, "3D", 0, "3D", "Use the 3D vector Vector as input"}, +{3, "3D", 0, "3D", "Use the 3D vector (x, y, z) as input"}, {4, "4D", 0, "4D", "Use the 4D vector (x, y, z, w) as input"}, {0, NULL, 0, NULL, NULL}, }; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [75c9ea0cab0] temp-lineart-contained: Merge remote-tracking branch 'origin/master' into temp-lineart-contained
Commit: 75c9ea0cab0eac1b39e257b070067f05a36d06d7 Author: YimingWu Date: Mon Jun 28 13:26:55 2021 +0800 Branches: temp-lineart-contained https://developer.blender.org/rB75c9ea0cab0eac1b39e257b070067f05a36d06d7 Merge remote-tracking branch 'origin/master' into temp-lineart-contained === === diff --cc source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c index 403da5e22ff,b87ed9e431a..2af3f66eb75 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c @@@ -403,22 -363,13 +403,22 @@@ static void options_panel_draw(const bC return; } - uiLayout *col = uiLayoutColumn(layout, true); + uiLayout *row = uiLayoutRowWithHeading(layout, false, IFACE_("Custom Camera")); + uiItemR(row, ptr, "use_custom_camera", 0, "", 0); + uiLayout *subrow = uiLayoutRow(row, true); + uiLayoutSetActive(subrow, RNA_boolean_get(ptr, "use_custom_camera")); + uiLayoutSetPropSep(subrow, true); + uiItemR(subrow, ptr, "source_camera", 0, "", ICON_OBJECT_DATA); - uiItemR(col, ptr, "use_remove_doubles", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "use_edge_overlap", 0, IFACE_("Overlapping Edges As Contour"), ICON_NONE); - uiItemR(col, ptr, "use_object_instances", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "use_clip_plane_boundaries", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "allow_overlap_edge_types", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "overscan", 0, NULL, ICON_NONE); + + uiItemR(layout, ptr, "use_remove_doubles", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_edge_overlap", 0, IFACE_("Overlapping Edges As Contour"), ICON_NONE); + uiItemR(layout, ptr, "use_object_instances", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_clip_plane_boundaries", 0, NULL, ICON_NONE); - uiItemR(layout, ptr, "use_multiple_edge_types", 0, NULL, ICON_NONE); ++ uiItemR(layout, ptr, "allow_overlap_edge_types", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_crease_on_smooth", 0, IFACE_("Crease On Smooth"), ICON_NONE); + uiItemR(layout, ptr, "use_crease_on_sharp", 0, IFACE_("Crease On Sharp"), ICON_NONE); } static void style_panel_draw(const bContext *UNUSED(C), Panel *panel) @@@ -741,16 -611,8 +741,14 @@@ static void panelRegister(ARegionType * transparency_panel_draw_header, transparency_panel_draw, occlusion_panel); + gpencil_modifier_subpanel_register(region_type, + "intersection", + "", + intersection_panel_draw_header, + intersection_panel_draw, + panel_type); gpencil_modifier_subpanel_register( region_type, "face_mark", "", face_mark_panel_draw_header, face_mark_panel_draw, panel_type); - gpencil_modifier_subpanel_register( - region_type, "face_mark", "", face_mark_panel_draw_header, face_mark_panel_draw, panel_type); gpencil_modifier_subpanel_register( region_type, "chaining", "Chaining", NULL, chaining_panel_draw, panel_type); gpencil_modifier_subpanel_register( diff --cc source/blender/makesrna/intern/rna_gpencil_modifier.c index 96bdd5546f2,6fd897a3d66..212237c2985 --- a/source/blender/makesrna/intern/rna_gpencil_modifier.c +++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c @@@ -2882,42 -2869,10 +2882,42 @@@ static void rna_def_modifier_gpencillin RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_ALLOW_OVERLAP_EDGE_TYPES); RNA_def_property_ui_text(prop, "Overlapping Edge Types", -"Allow an edge to have multiple overlapping types. This will create an " -"individual stroke for each overlapping type"); +"Allow an edge to have multiple overlapping types. This will create a " +"separate stroke for each overlapping type"); RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + prop = RNA_def_property(srna, "offset_towards_custom_camera", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_GPENCIL_OFFSET_TOWARDS_CUSTOM_CAMERA); + RNA_def_property_ui_text(prop, + "Offset Towards Custom Camera", + "Offset strokes towards selected camera instead of the active camera"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "stroke_offset", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_ui_text(prop, + "Stroke Offset", + "Move strokes slightly towards t
[Bf-blender-cvs] [23c4854f45d] master: UI: Cleanup: Phrasing of tooltips in line art modifier
Commit: 23c4854f45d7cafa1cfadf13556b9277d4666bd1 Author: Hans Goudey Date: Sun Jun 27 23:48:46 2021 -0500 Branches: master https://developer.blender.org/rB23c4854f45d7cafa1cfadf13556b9277d4666bd1 UI: Cleanup: Phrasing of tooltips in line art modifier Start the tooltip with a verb instead of a gerund, other small changes for consistency and readability. === M source/blender/makesrna/intern/rna_gpencil_modifier.c === diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c index 34ec4fbec92..6fd897a3d66 100644 --- a/source/blender/makesrna/intern/rna_gpencil_modifier.c +++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c @@ -2841,7 +2841,7 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna) prop = RNA_def_property(srna, "use_face_mark_boundaries", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_FILTER_FACE_MARK_BOUNDARIES); RNA_def_property_ui_text( - prop, "Boundaries", "Filtering feature lines on face mark boundaries as well"); + prop, "Boundaries", "Filter feature lines based on face mark boundaries"); RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); prop = RNA_def_property(srna, "chaining_image_threshold", PROP_FLOAT, PROP_DISTANCE); @@ -2869,8 +2869,8 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_ALLOW_OVERLAP_EDGE_TYPES); RNA_def_property_ui_text(prop, "Overlapping Edge Types", - "Allow an edge to have multiple overlapping types. This will create an " - "individual stroke for each overlapping type"); + "Allow an edge to have multiple overlapping types. This will create a " + "separate stroke for each overlapping type"); RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); prop = RNA_def_property(srna, "source_type", PROP_ENUM, PROP_NONE); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [3bf9843f484] temp-cpp-type-cleanup: update tests
Commit: 3bf9843f4848d0557a585ad24bbee9754ace24f3 Author: Jacques Lucke Date: Sun Jun 27 17:06:51 2021 +0200 Branches: temp-cpp-type-cleanup https://developer.blender.org/rB3bf9843f4848d0557a585ad24bbee9754ace24f3 update tests === M source/blender/functions/tests/FN_cpp_type_test.cc === diff --git a/source/blender/functions/tests/FN_cpp_type_test.cc b/source/blender/functions/tests/FN_cpp_type_test.cc index 3f92d2e1ac6..ffa3050f5a4 100644 --- a/source/blender/functions/tests/FN_cpp_type_test.cc +++ b/source/blender/functions/tests/FN_cpp_type_test.cc @@ -76,7 +76,7 @@ struct TestType { } // namespace blender::fn::tests -MAKE_CPP_TYPE(TestType, blender::fn::tests::TestType) +MAKE_CPP_TYPE(TestType, blender::fn::tests::TestType, CPPTypeFlags::BasicType) namespace blender::fn::tests { @@ -101,15 +101,15 @@ TEST(cpp_type, Is) TEST(cpp_type, DefaultConstruction) { int buffer[10] = {0}; - CPPType_TestType.construct_default((void *)buffer); + CPPType_TestType.default_construct((void *)buffer); EXPECT_EQ(buffer[0], default_constructed_value); EXPECT_EQ(buffer[1], 0); - CPPType_TestType.construct_default_n((void *)buffer, 3); + CPPType_TestType.default_construct_n((void *)buffer, 3); EXPECT_EQ(buffer[0], default_constructed_value); EXPECT_EQ(buffer[1], default_constructed_value); EXPECT_EQ(buffer[2], default_constructed_value); EXPECT_EQ(buffer[3], 0); - CPPType_TestType.construct_default_indices((void *)buffer, {2, 5, 7}); + CPPType_TestType.default_construct_indices((void *)buffer, {2, 5, 7}); EXPECT_EQ(buffer[2], default_constructed_value); EXPECT_EQ(buffer[4], 0); EXPECT_EQ(buffer[5], default_constructed_value); @@ -142,10 +142,10 @@ TEST(cpp_type, CopyToUninitialized) { int buffer1[10] = {0}; int buffer2[10] = {0}; - CPPType_TestType.copy_to_uninitialized((void *)buffer1, (void *)buffer2); + CPPType_TestType.copy_construct((void *)buffer1, (void *)buffer2); EXPECT_EQ(buffer1[0], copy_constructed_from_value); EXPECT_EQ(buffer2[0], copy_constructed_value); - CPPType_TestType.copy_to_uninitialized_n((void *)buffer1, (void *)buffer2, 3); + CPPType_TestType.copy_construct_n((void *)buffer1, (void *)buffer2, 3); EXPECT_EQ(buffer1[0], copy_constructed_from_value); EXPECT_EQ(buffer2[0], copy_constructed_value); EXPECT_EQ(buffer1[1], copy_constructed_from_value); @@ -154,7 +154,7 @@ TEST(cpp_type, CopyToUninitialized) EXPECT_EQ(buffer2[2], copy_constructed_value); EXPECT_EQ(buffer1[3], 0); EXPECT_EQ(buffer2[3], 0); - CPPType_TestType.copy_to_uninitialized_indices((void *)buffer1, (void *)buffer2, {2, 5, 7}); + CPPType_TestType.copy_construct_indices((void *)buffer1, (void *)buffer2, {2, 5, 7}); EXPECT_EQ(buffer1[2], copy_constructed_from_value); EXPECT_EQ(buffer2[2], copy_constructed_value); EXPECT_EQ(buffer1[4], 0); @@ -173,10 +173,10 @@ TEST(cpp_type, CopyToInitialized) { int buffer1[10] = {0}; int buffer2[10] = {0}; - CPPType_TestType.copy_to_initialized((void *)buffer1, (void *)buffer2); + CPPType_TestType.copy_assign((void *)buffer1, (void *)buffer2); EXPECT_EQ(buffer1[0], copy_assigned_from_value); EXPECT_EQ(buffer2[0], copy_assigned_value); - CPPType_TestType.copy_to_initialized_n((void *)buffer1, (void *)buffer2, 3); + CPPType_TestType.copy_assign_n((void *)buffer1, (void *)buffer2, 3); EXPECT_EQ(buffer1[0], copy_assigned_from_value); EXPECT_EQ(buffer2[0], copy_assigned_value); EXPECT_EQ(buffer1[1], copy_assigned_from_value); @@ -185,7 +185,7 @@ TEST(cpp_type, CopyToInitialized) EXPECT_EQ(buffer2[2], copy_assigned_value); EXPECT_EQ(buffer1[3], 0); EXPECT_EQ(buffer2[3], 0); - CPPType_TestType.copy_to_initialized_indices((void *)buffer1, (void *)buffer2, {2, 5, 7}); + CPPType_TestType.copy_assign_indices((void *)buffer1, (void *)buffer2, {2, 5, 7}); EXPECT_EQ(buffer1[2], copy_assigned_from_value); EXPECT_EQ(buffer2[2], copy_assigned_value); EXPECT_EQ(buffer1[4], 0); @@ -204,10 +204,10 @@ TEST(cpp_type, RelocateToUninitialized) { int buffer1[10] = {0}; int buffer2[10] = {0}; - CPPType_TestType.relocate_to_uninitialized((void *)buffer1, (void *)buffer2); + CPPType_TestType.relocate_construct((void *)buffer1, (void *)buffer2); EXPECT_EQ(buffer1[0], destructed_value); EXPECT_EQ(buffer2[0], move_constructed_value); - CPPType_TestType.relocate_to_uninitialized_n((void *)buffer1, (void *)buffer2, 3); + CPPType_TestType.relocate_construct_n((void *)buffer1, (void *)buffer2, 3); EXPECT_EQ(buffer1[0], destructed_value); EXPECT_EQ(buffer2[0], move_constructed_value); EXPECT_EQ(buffer1[1], destructed_value); @@ -216,7 +216,7 @@ TEST(cpp_type, RelocateToUninitialized) EXPECT_EQ(buffer2[2], move_constructed_value); EXPECT_EQ(buffer1[3], 0); EXPECT_EQ(buffer2[3], 0); - CPPType_TestType.relocate_to_uninitialize
[Bf-blender-cvs] [2bf84b94108] temp-cpp-type-cleanup: improve naming
Commit: 2bf84b941081b4ac6a93ef2b617e85fcf3a11fac Author: Jacques Lucke Date: Sun Jun 27 15:25:35 2021 +0200 Branches: temp-cpp-type-cleanup https://developer.blender.org/rB2bf84b941081b4ac6a93ef2b617e85fcf3a11fac improve naming === M source/blender/blenkernel/intern/attribute_access.cc M source/blender/blenkernel/intern/geometry_set_instances.cc M source/blender/functions/FN_cpp_type.hh M source/blender/functions/FN_cpp_type_make.hh M source/blender/functions/FN_generic_pointer.hh M source/blender/functions/FN_generic_value_map.hh M source/blender/functions/FN_generic_vector_array.hh M source/blender/functions/FN_generic_virtual_array.hh M source/blender/functions/intern/generic_vector_array.cc M source/blender/functions/intern/generic_virtual_array.cc M source/blender/functions/intern/generic_virtual_vector_array.cc M source/blender/functions/intern/multi_function_builder.cc M source/blender/modifiers/intern/MOD_nodes.cc M source/blender/modifiers/intern/MOD_nodes_evaluator.cc M source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc M source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc M source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc M source/blender/nodes/intern/type_conversions.cc === diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc index 8bbb3014dac..aa0af294bc3 100644 --- a/source/blender/blenkernel/intern/attribute_access.cc +++ b/source/blender/blenkernel/intern/attribute_access.cc @@ -1197,7 +1197,7 @@ static blender::bke::OutputAttribute create_output_attribute( cpp_type->size() * domain_size, cpp_type->alignment(), __func__); if (ignore_old_values) { /* This does nothing for trivially constructible types, but is necessary for correctness. */ -cpp_type->construct_default_n(data, domain); +cpp_type->default_construct_n(data, domain); } else { /* Fill the temporary array with values from the existing attribute. */ diff --git a/source/blender/blenkernel/intern/geometry_set_instances.cc b/source/blender/blenkernel/intern/geometry_set_instances.cc index 8cf08d05d9d..88fcb18d3d2 100644 --- a/source/blender/blenkernel/intern/geometry_set_instances.cc +++ b/source/blender/blenkernel/intern/geometry_set_instances.cc @@ -535,7 +535,7 @@ static void join_attributes(Span set_groups, const void *src_buffer = src_span.data(); for (const int UNUSED(i) : set_group.transforms.index_range()) { void *dst_buffer = dst_span[offset]; - cpp_type->copy_to_initialized_n(src_buffer, dst_buffer, domain_size); + cpp_type->copy_assign_n(src_buffer, dst_buffer, domain_size); offset += domain_size; } } diff --git a/source/blender/functions/FN_cpp_type.hh b/source/blender/functions/FN_cpp_type.hh index 1782000785d..60b51266138 100644 --- a/source/blender/functions/FN_cpp_type.hh +++ b/source/blender/functions/FN_cpp_type.hh @@ -35,11 +35,11 @@ * * A CPPType instance comes with many methods that allow dealing with types in a generic way. Most * methods come in three variants. Using the construct-default methods as example: - * - construct_default(void *ptr): + * - default_construct(void *ptr): * Constructs a single instance of that type at the given pointer. - * - construct_default_n(void *ptr, int64_t n): + * - default_construct_n(void *ptr, int64_t n): * Constructs n instances of that type in an array that starts at the given pointer. - * - construct_default_indices(void *ptr, IndexMask mask): + * - default_construct_indices(void *ptr, IndexMask mask): * Constructs multiple instances of that type in an array that starts at the given pointer. * Only the indices referenced by `mask` will by constructed. * @@ -58,7 +58,7 @@ * used now with explicit function pointers to work better. Here are some reasons: * - If CPPType would be inherited once for every used C++ type, we would get a lot of classes *that would only be instanced once each. - * - Methods like `construct_default` that operate on a single instance have to be fast. Even this + * - Methods like `default_construct` that operate on a single instance have to be fast. Even this *one necessary indirection using function pointers adds a lot of overhead. If all methods were *virtual, there would be a second level of indirection that increases the overhead even more. * - If it becomes necessary, we could pass the function pointers to C functions more easily than @@ -80,35 +80,35 @@ struct CPPTypeMembers { bool is_trivially_destructible = false; bool has_special_member_functions = false; - void (*const
[Bf-blender-cvs] [a7f3b1a3efc] temp-cpp-type-cleanup: make more CPPType features optional
Commit: a7f3b1a3efca88faca3d475d4e0a8bd797c796c2 Author: Jacques Lucke Date: Sun Jun 27 16:26:16 2021 +0200 Branches: temp-cpp-type-cleanup https://developer.blender.org/rBa7f3b1a3efca88faca3d475d4e0a8bd797c796c2 make more CPPType features optional === M source/blender/blenkernel/BKE_geometry_set.hh M source/blender/blenkernel/intern/geometry_set.cc M source/blender/blenlib/BLI_utildefines.h M source/blender/functions/FN_cpp_type_make.hh M source/blender/functions/intern/cpp_types.cc M source/blender/nodes/geometry/node_geometry_exec.cc M source/blender/nodes/intern/node_socket.cc === diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh index b2342a5fd96..82c9a31dfce 100644 --- a/source/blender/blenkernel/BKE_geometry_set.hh +++ b/source/blender/blenkernel/BKE_geometry_set.hh @@ -280,8 +280,6 @@ struct GeometrySet { void compute_boundbox_without_instances(blender::float3 *r_min, blender::float3 *r_max) const; friend std::ostream &operator<<(std::ostream &stream, const GeometrySet &geometry_set); - friend bool operator==(const GeometrySet &a, const GeometrySet &b); - uint64_t hash() const; void clear(); diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc index 3d85118deee..07b4e715ea9 100644 --- a/source/blender/blenkernel/intern/geometry_set.cc +++ b/source/blender/blenkernel/intern/geometry_set.cc @@ -199,20 +199,6 @@ std::ostream &operator<<(std::ostream &stream, const GeometrySet &geometry_set) return stream; } -/* This generally should not be used. It is necessary currently, so that GeometrySet can by used by - * the CPPType system. */ -bool operator==(const GeometrySet &UNUSED(a), const GeometrySet &UNUSED(b)) -{ - return false; -} - -/* This generally should not be used. It is necessary currently, so that GeometrySet can by used by - * the CPPType system. */ -uint64_t GeometrySet::hash() const -{ - return reinterpret_cast(this); -} - /* Remove all geometry components from the geometry set. */ void GeometrySet::clear() { diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index 0ddabcaa2fb..5b84e050f82 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -788,23 +788,24 @@ extern bool BLI_memory_is_zero(const void *arr, const size_t arr_size); extern "C++" { \ inline constexpr _enum_type operator|(_enum_type a, _enum_type b) \ { \ - return static_cast<_enum_type>(static_cast(a) | b); \ + return static_cast<_enum_type>(static_cast(a) | static_cast(b)); \ } \ inline constexpr _enum_type operator&(_enum_type a, _enum_type b) \ { \ - return static_cast<_enum_type>(static_cast(a) & b); \ + return static_cast<_enum_type>(static_cast(a) & static_cast(b)); \ } \ inline constexpr _enum_type operator~(_enum_type a) \ { \ - return static_cast<_enum_type>(~static_cast(a) & (2 * _max_enum_value - 1)); \ + return static_cast<_enum_type>(~static_cast(a) & \ + (2 * static_cast(_max_enum_value) - 1)); \ } \ inline _enum_type &operator|=(_enum_type &a, _enum_type b) \ { \ - return a = static_cast<_enum_type>(static_cast(a) | b); \ + return a = static_cast<_enum_type>(static_cast(a) | static_cast(b)); \ } \ inline _enum_type &operator&=(_enum_type &a, _enum_type b) \ { \ - return a = static_cast<_enum_type>(static_cast(a) & b); \ + return a = static_cast<_enum_type>(static_cast(a) & static_cast(b)); \ } \ } /* extern "C++" */ diff --git a/source/blender/functions/FN_cpp_type_make.hh b/source/blender/functions/FN_cpp_type_make.hh index 7af68f3e23a..b7c83bf8c86 100644 --- a/source/blender/functions/FN_cpp_type_make.hh +++ b/source/blender/functions/FN_cpp_type_make.hh @@ -20,6 +20,7 @@ * \ingroup fn */ +#include "BLI_utildefines.h" #include "FN_cpp_type.hh" namespace blender::fn::cpp_type_util { @@ -184,9 +185,25 @@ template uint64_t hash_cb(const void *value) } // namespace blender::fn::cpp_type_util +/** + * Different types support different features. Features like copy constructibility can be detected + * automatically easily. For some features this is harder as of C++17. Those have flags in this + * enum and need to be determined by the programmer. + */ +enum class CPPTypeFlags { + None = 0, + Hashable = 1 << 0, + Printable = 1 << 1, + EqualityComparable = 1 << 2, + + BasicType = Hashable | Printable | EqualityComparable, +}; +ENUM_OPERATORS(CPPTypeFlags, CPPTypeFlags::EqualityComparable) + namespace blender::fn { -template inline std::unique_ptr create_cpp_type(StringRef name) +template +inline st
[Bf-blender-cvs] [3dfee3c0b19] temp-cpp-type-cleanup: improve printing
Commit: 3dfee3c0b19222e650d4c60edbf1882a0c2e959f Author: Jacques Lucke Date: Sun Jun 27 16:35:24 2021 +0200 Branches: temp-cpp-type-cleanup https://developer.blender.org/rB3dfee3c0b19222e650d4c60edbf1882a0c2e959f improve printing === M source/blender/functions/FN_cpp_type.hh M source/blender/functions/FN_cpp_type_make.hh M source/blender/functions/intern/multi_function_builder.cc === diff --git a/source/blender/functions/FN_cpp_type.hh b/source/blender/functions/FN_cpp_type.hh index 70fd9131da5..e4c21885b40 100644 --- a/source/blender/functions/FN_cpp_type.hh +++ b/source/blender/functions/FN_cpp_type.hh @@ -107,7 +107,7 @@ struct CPPTypeMembers { void (*fill_construct_indices)(const void *value, void *dst, IndexMask mask) = nullptr; - void (*debug_print)(const void *value, std::stringstream &ss) = nullptr; + void (*print)(const void *value, std::stringstream &ss) = nullptr; bool (*is_equal)(const void *a, const void *b) = nullptr; uint64_t (*hash)(const void *value) = nullptr; @@ -223,6 +223,21 @@ class CPPType : NonCopyable, NonMovable { return m_.copy_construct != nullptr; } + bool is_printable() const + { +return m_.print != nullptr; + } + + bool is_equality_comparable() const + { +return m_.is_equal != nullptr; + } + + bool is_hashable() const + { +return m_.hash != nullptr; + } + /** * Returns true, when the type has the following functions: * - Default constructor. @@ -524,10 +539,20 @@ class CPPType : NonCopyable, NonMovable { m_.fill_construct_indices(value, dst, mask); } - void debug_print(const void *value, std::stringstream &ss) const + void print(const void *value, std::stringstream &ss) const { BLI_assert(this->pointer_can_point_to_instance(value)); -m_.debug_print(value, ss); +m_.print(value, ss); + } + + void print_or_default(const void *value, std::stringstream &ss, StringRef default_value) const + { +if (this->is_printable()) { + m_.print(value, ss); +} +else { + ss << default_value; +} } bool is_equal(const void *a, const void *b) const diff --git a/source/blender/functions/FN_cpp_type_make.hh b/source/blender/functions/FN_cpp_type_make.hh index b7c83bf8c86..529ec261946 100644 --- a/source/blender/functions/FN_cpp_type_make.hh +++ b/source/blender/functions/FN_cpp_type_make.hh @@ -164,7 +164,7 @@ template void fill_construct_indices_cb(const void *value, void *dst mask.foreach_index([&](int64_t i) { new (dst_ + i) T(value_); }); } -template void debug_print_cb(const void *value, std::stringstream &ss) +template void print_cb(const void *value, std::stringstream &ss) { const T &value_ = *static_cast(value); ss << value_; @@ -258,7 +258,7 @@ inline std::unique_ptr create_cpp_type(StringRef name) m.hash = hash_cb; } if constexpr ((bool)(flags & CPPTypeFlags::Printable)) { -m.debug_print = debug_print_cb; +m.print = print_cb; } if constexpr ((bool)(flags & CPPTypeFlags::EqualityComparable)) { m.is_equal = is_equal_cb; diff --git a/source/blender/functions/intern/multi_function_builder.cc b/source/blender/functions/intern/multi_function_builder.cc index 6961935dc0c..69b2b6e0b93 100644 --- a/source/blender/functions/intern/multi_function_builder.cc +++ b/source/blender/functions/intern/multi_function_builder.cc @@ -25,7 +25,7 @@ CustomMF_GenericConstant::CustomMF_GenericConstant(const CPPType &type, const vo { MFSignatureBuilder signature{"Constant " + type.name()}; std::stringstream ss; - type.debug_print(value, ss); + type.print_or_default(value, ss, type.name()); signature.single_output(ss.str(), type); signature_ = signature.build(); this->set_signature(&signature_); @@ -58,11 +58,12 @@ bool CustomMF_GenericConstant::equals(const MultiFunction &other) const static std::string gspan_to_string(GSpan array) { + const CPPType &type = array.type(); std::stringstream ss; ss << "["; const int64_t max_amount = 5; for (int64_t i : IndexRange(std::min(max_amount, array.size( { -array.type().debug_print(array[i], ss); +type.print_or_default(array[i], ss, type.name()); ss << ", "; } if (max_amount < array.size()) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b4956ad6e0e] temp-cpp-type-cleanup: better support types that don't have all special member functions
Commit: b4956ad6e0e97a96a102e746665dd191a177dd7d Author: Jacques Lucke Date: Sun Jun 27 15:08:06 2021 +0200 Branches: temp-cpp-type-cleanup https://developer.blender.org/rBb4956ad6e0e97a96a102e746665dd191a177dd7d better support types that don't have all special member functions === M source/blender/functions/FN_cpp_type.hh M source/blender/functions/FN_cpp_type_make.hh M source/blender/modifiers/intern/MOD_nodes_evaluator.cc === diff --git a/source/blender/functions/FN_cpp_type.hh b/source/blender/functions/FN_cpp_type.hh index a8cc8494585..1782000785d 100644 --- a/source/blender/functions/FN_cpp_type.hh +++ b/source/blender/functions/FN_cpp_type.hh @@ -77,7 +77,8 @@ struct CPPTypeMembers { int64_t size = 0; int64_t alignment = 0; uintptr_t alignment_mask = 0; - bool is_trivially_destructible = 0; + bool is_trivially_destructible = false; + bool has_special_member_functions = false; void (*construct_default)(void *ptr) = nullptr; void (*construct_default_indices)(void *ptr, IndexMask mask) = nullptr; @@ -126,6 +127,9 @@ class CPPType : NonCopyable, NonMovable { { BLI_assert(is_power_of_2_i(m_.alignment)); m_.alignment_mask = (uintptr_t)members.alignment - (uintptr_t)1; +m_.has_special_member_functions = (m_.construct_default && m_.copy_to_uninitialized && + m_.copy_to_initialized && m_.move_to_uninitialized && + m_.move_to_initialized && m_.destruct); } /** @@ -192,6 +196,50 @@ class CPPType : NonCopyable, NonMovable { return m_.is_trivially_destructible; } + bool is_default_constructible() const + { +return m_.construct_default != nullptr; + } + + bool is_copy_constructible() const + { +return m_.copy_to_initialized != nullptr; + } + + bool is_move_constructible() const + { +return m_.move_to_initialized != nullptr; + } + + bool is_destructible() const + { +return m_.destruct != nullptr; + } + + bool is_copy_assignable() const + { +return m_.copy_to_initialized != nullptr; + } + + bool is_move_assignable() const + { +return m_.copy_to_uninitialized != nullptr; + } + + /** + * Returns true, when the type has the following functions: + * - Default constructor. + * - Copy constructor. + * - Move constructor. + * - Copy assignment operator. + * - Move assignment operator. + * - Destructor. + */ + bool has_special_member_functions() const + { +return m_.has_special_member_functions; + } + /** * Returns true, when the given pointer fulfills the alignment requirement of this type. */ diff --git a/source/blender/functions/FN_cpp_type_make.hh b/source/blender/functions/FN_cpp_type_make.hh index 8022e5b8145..81fb09d0731 100644 --- a/source/blender/functions/FN_cpp_type_make.hh +++ b/source/blender/functions/FN_cpp_type_make.hh @@ -190,39 +190,63 @@ template uint64_t hash_cb(const void *value) namespace blender::fn { -template -inline std::unique_ptr create_cpp_type(StringRef name, const T &default_value) +template inline std::unique_ptr create_cpp_type(StringRef name) { using namespace cpp_type_util; + + static T default_value; + CPPTypeMembers m; m.name = name; m.size = (int64_t)sizeof(T); m.alignment = (int64_t)alignof(T); + m.default_value = (void *)&default_value; m.is_trivially_destructible = std::is_trivially_destructible_v; - m.construct_default = construct_default_cb; - m.construct_default_indices = construct_default_indices_cb; - m.destruct = destruct_cb; - m.destruct_indices = destruct_indices_cb; - m.copy_to_initialized = copy_to_initialized_cb; - m.copy_to_initialized_indices = copy_to_initialized_indices_cb; - m.copy_to_uninitialized = copy_to_uninitialized_cb; - m.copy_to_uninitialized_indices = copy_to_uninitialized_indices_cb; - m.move_to_initialized = move_to_initialized_cb; - m.move_to_initialized_indices = move_to_initialized_indices_cb; - m.move_to_uninitialized = move_to_uninitialized_cb; - m.move_to_uninitialized_indices = move_to_uninitialized_indices_cb; - m.relocate_to_initialized = relocate_to_initialized_cb; - m.relocate_to_initialized_indices = relocate_to_initialized_indices_cb; - m.relocate_to_uninitialized = relocate_to_uninitialized_cb; - m.relocate_to_uninitialized_indices = relocate_to_uninitialized_indices_cb; - m.fill_initialized = fill_initialized_cb; - m.fill_initialized_indices = fill_initialized_indices_cb; - m.fill_uninitialized = fill_uninitialized_cb; - m.fill_uninitialized_indices = fill_uninitialized_indices_cb; + if constexpr (std::is_default_constructible_v) { +m.construct_default = construct_default_cb; +m.construct_default_indices = construct_default_indices_cb; + } + if constexpr (std::is_destructible_v) { +m.destruct = destruct_cb; +m.dest
[Bf-blender-cvs] [89ebdfdb83b] temp-cpp-type-cleanup: cleanup
Commit: 89ebdfdb83b78136307682edcb74508e7e1dd6b0 Author: Jacques Lucke Date: Sun Jun 27 16:39:49 2021 +0200 Branches: temp-cpp-type-cleanup https://developer.blender.org/rB89ebdfdb83b78136307682edcb74508e7e1dd6b0 cleanup === M source/blender/functions/FN_cpp_type.hh M source/blender/functions/FN_multi_function_builder.hh === diff --git a/source/blender/functions/FN_cpp_type.hh b/source/blender/functions/FN_cpp_type.hh index e4c21885b40..0b7e378dcc2 100644 --- a/source/blender/functions/FN_cpp_type.hh +++ b/source/blender/functions/FN_cpp_type.hh @@ -548,7 +548,7 @@ class CPPType : NonCopyable, NonMovable { void print_or_default(const void *value, std::stringstream &ss, StringRef default_value) const { if (this->is_printable()) { - m_.print(value, ss); + this->print(value, ss); } else { ss << default_value; @@ -562,6 +562,14 @@ class CPPType : NonCopyable, NonMovable { return m_.is_equal(a, b); } + bool is_equal_or_false(const void *a, const void *b) const + { +if (this->is_equality_comparable()) { + return this->is_equal(a, b); +} +return false; + } + uint64_t hash(const void *value) const { BLI_assert(this->pointer_can_point_to_instance(value)); diff --git a/source/blender/functions/FN_multi_function_builder.hh b/source/blender/functions/FN_multi_function_builder.hh index 691abeb18c0..7a526bb640b 100644 --- a/source/blender/functions/FN_multi_function_builder.hh +++ b/source/blender/functions/FN_multi_function_builder.hh @@ -398,7 +398,7 @@ template class CustomMF_Constant : public MultiFunction { if (other2 != nullptr) { const CPPType &type = CPPType::get(); if (type == other2->type_) { -return type.is_equal(static_cast(&value_), other2->value_); +return type.is_equal_or_false(static_cast(&value_), other2->value_); } } return false; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [739056418ef] temp-cpp-type-cleanup: simplify fill assign/construct
Commit: 739056418ef344de03cd2e866f13ee21062c872b Author: Jacques Lucke Date: Sun Jun 27 15:30:23 2021 +0200 Branches: temp-cpp-type-cleanup https://developer.blender.org/rB739056418ef344de03cd2e866f13ee21062c872b simplify fill assign/construct === M source/blender/functions/FN_cpp_type.hh M source/blender/functions/FN_cpp_type_make.hh M source/blender/functions/intern/generic_virtual_array.cc M source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc M source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc === diff --git a/source/blender/functions/FN_cpp_type.hh b/source/blender/functions/FN_cpp_type.hh index 60b51266138..dd772671a1e 100644 --- a/source/blender/functions/FN_cpp_type.hh +++ b/source/blender/functions/FN_cpp_type.hh @@ -104,10 +104,8 @@ struct CPPTypeMembers { void (*relocate_construct)(void *src, void *dst) = nullptr; void (*relocate_construct_indices)(void *src, void *dst, IndexMask mask) = nullptr; - void (*fill_assign)(const void *value, void *dst, int64_t n) = nullptr; void (*fill_assign_indices)(const void *value, void *dst, IndexMask mask) = nullptr; - void (*fill_construct)(const void *value, void *dst, int64_t n) = nullptr; void (*fill_construct_indices)(const void *value, void *dst, IndexMask mask) = nullptr; void (*debug_print)(const void *value, std::stringstream &ss) = nullptr; @@ -496,12 +494,9 @@ class CPPType : NonCopyable, NonMovable { * * Other instances of the same type should live in the array before this method is called. */ - void fill_assign(const void *value, void *dst, int64_t n) const + void fill_assign_n(const void *value, void *dst, int64_t n) const { -BLI_assert(n == 0 || this->pointer_can_point_to_instance(value)); -BLI_assert(n == 0 || this->pointer_can_point_to_instance(dst)); - -m_.fill_assign(value, dst, n); +this->fill_assign_indices(value, dst, IndexMask(n)); } void fill_assign_indices(const void *value, void *dst, IndexMask mask) const @@ -517,12 +512,9 @@ class CPPType : NonCopyable, NonMovable { * * The array should be uninitialized before this method is called. */ - void fill_construct(const void *value, void *dst, int64_t n) const + void fill_construct_n(const void *value, void *dst, int64_t n) const { -BLI_assert(n == 0 || this->pointer_can_point_to_instance(value)); -BLI_assert(n == 0 || this->pointer_can_point_to_instance(dst)); - -m_.fill_construct(value, dst, n); +this->fill_construct_indices(value, dst, IndexMask(n)); } void fill_construct_indices(const void *value, void *dst, IndexMask mask) const diff --git a/source/blender/functions/FN_cpp_type_make.hh b/source/blender/functions/FN_cpp_type_make.hh index 8a12b32b805..8760c49ffe2 100644 --- a/source/blender/functions/FN_cpp_type_make.hh +++ b/source/blender/functions/FN_cpp_type_make.hh @@ -233,11 +233,9 @@ template inline std::unique_ptr create_cpp_type(Strin } } if constexpr (std::is_copy_assignable_v) { -m.fill_assign = fill_assign_cb; m.fill_assign_indices = fill_assign_indices_cb; } if constexpr (std::is_copy_constructible_v) { -m.fill_construct = fill_construct_cb; m.fill_construct_indices = fill_construct_indices_cb; } m.debug_print = debug_print_cb; diff --git a/source/blender/functions/intern/generic_virtual_array.cc b/source/blender/functions/intern/generic_virtual_array.cc index b25daf40568..bd033a429de 100644 --- a/source/blender/functions/intern/generic_virtual_array.cc +++ b/source/blender/functions/intern/generic_virtual_array.cc @@ -182,7 +182,7 @@ void GVMutableArray::fill(const void *value) { if (this->is_span()) { const GMutableSpan span = this->get_internal_span(); -type_->fill_assign(value, span.data(), size_); +type_->fill_assign_n(value, span.data(), size_); } else { for (int64_t i : IndexRange(size_)) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc index 1e1533e48cf..e37822bd262 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc @@ -298,7 +298,7 @@ static void copy_spline_domain_attributes(const CurveComponent &curve_component, if (size != 0) { BUFFER_FOR_CPP_TYPE_VALUE(type, buffer); spline_attribute->get(i, buffer); -type.fill_assign(buffer, result[offset], size); +type.fill_assign_n(buffer, result[offset], size); } } diff --git a/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc index 2f6d3ef0d6c..730cf08feaa 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc +++ b/so
[Bf-blender-cvs] [93641b7866e] temp-cpp-type-cleanup: improve comment
Commit: 93641b7866ee68590cef9d7359cb51e09a9cd703 Author: Jacques Lucke Date: Sun Jun 27 16:28:43 2021 +0200 Branches: temp-cpp-type-cleanup https://developer.blender.org/rB93641b7866ee68590cef9d7359cb51e09a9cd703 improve comment === M source/blender/functions/FN_cpp_type.hh === diff --git a/source/blender/functions/FN_cpp_type.hh b/source/blender/functions/FN_cpp_type.hh index dd772671a1e..70fd9131da5 100644 --- a/source/blender/functions/FN_cpp_type.hh +++ b/source/blender/functions/FN_cpp_type.hh @@ -19,10 +19,9 @@ /** \file * \ingroup fn * - * The CPPType class is the core of the runtime-type-system used by the functions system. It can - * represent C++ types that are default-constructible, destructible, movable, copyable, - * equality comparable and hashable. In the future we might want to make some of these properties - * optional. + * The `CPPType` class is the core of a runtime-type-system. It allows working with arbitrary C++ + * types in a generic way. An instance of `CPPType` wraps exactly one type like `int` or + * `std::string`. * * Every type has a size and an alignment. Every function dealing with C++ types in a generic way, * has to make sure that alignment rules are followed. The methods provided by a CPPType instance ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b6cb04cd0f6] temp-cpp-type-cleanup: improve hashing
Commit: b6cb04cd0f6ed548169815906f17803ce091965a Author: Jacques Lucke Date: Sun Jun 27 16:49:38 2021 +0200 Branches: temp-cpp-type-cleanup https://developer.blender.org/rBb6cb04cd0f6ed548169815906f17803ce091965a improve hashing === M source/blender/functions/FN_cpp_type.hh M source/blender/functions/intern/multi_function_builder.cc M source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc === diff --git a/source/blender/functions/FN_cpp_type.hh b/source/blender/functions/FN_cpp_type.hh index 0b7e378dcc2..4de0533a46d 100644 --- a/source/blender/functions/FN_cpp_type.hh +++ b/source/blender/functions/FN_cpp_type.hh @@ -576,6 +576,14 @@ class CPPType : NonCopyable, NonMovable { return m_.hash(value); } + uint64_t hash_or_fallback(const void *value, uint64_t fallback_hash) const + { +if (this->is_hashable()) { + return this->hash(value); +} +return fallback_hash; + } + /** * Get a pointer to a constant value of this type. The specific value depends on the type. * It is usually a zero-initialized or default constructed value. diff --git a/source/blender/functions/intern/multi_function_builder.cc b/source/blender/functions/intern/multi_function_builder.cc index 69b2b6e0b93..c6b3b808130 100644 --- a/source/blender/functions/intern/multi_function_builder.cc +++ b/source/blender/functions/intern/multi_function_builder.cc @@ -41,7 +41,7 @@ void CustomMF_GenericConstant::call(IndexMask mask, uint64_t CustomMF_GenericConstant::hash() const { - return type_.hash(value_); + return type_.hash_or_fallback(value_, (uintptr_t)this); } bool CustomMF_GenericConstant::equals(const MultiFunction &other) const diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc index eeb77abd624..15d419a003a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc @@ -189,6 +189,7 @@ Array get_geometry_element_ids_as_uints(const GeometryComponent &compo if (hash_attribute) { BLI_assert(hashes.size() == hash_attribute->size()); const CPPType &cpp_type = hash_attribute->type(); +BLI_assert(cpp_type.is_hashable()); GVArray_GSpan items{*hash_attribute}; threading::parallel_for(hashes.index_range(), 512, [&](IndexRange range) { for (const int i : range) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8cd16b40146] temp-cpp-type-cleanup: better support types without default value
Commit: 8cd16b401467bf874c5f4f80c735cc8b8593125e Author: Jacques Lucke Date: Sun Jun 27 15:34:08 2021 +0200 Branches: temp-cpp-type-cleanup https://developer.blender.org/rB8cd16b401467bf874c5f4f80c735cc8b8593125e better support types without default value === M source/blender/functions/FN_cpp_type_make.hh === diff --git a/source/blender/functions/FN_cpp_type_make.hh b/source/blender/functions/FN_cpp_type_make.hh index 8760c49ffe2..7af68f3e23a 100644 --- a/source/blender/functions/FN_cpp_type_make.hh +++ b/source/blender/functions/FN_cpp_type_make.hh @@ -190,17 +190,16 @@ template inline std::unique_ptr create_cpp_type(Strin { using namespace cpp_type_util; - static T default_value; - CPPTypeMembers m; m.name = name; m.size = (int64_t)sizeof(T); m.alignment = (int64_t)alignof(T); - m.default_value = (void *)&default_value; m.is_trivially_destructible = std::is_trivially_destructible_v; if constexpr (std::is_default_constructible_v) { m.default_construct = default_construct_cb; m.default_construct_indices = default_construct_indices_cb; +static T default_value; +m.default_value = (void *)&default_value; } if constexpr (std::is_destructible_v) { m.destruct = destruct_cb; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c55061f539b] temp-cpp-type-cleanup: remove more duplication
Commit: c55061f539b5166709d30e50e3c2b57874f65a65 Author: Jacques Lucke Date: Sun Jun 27 14:10:04 2021 +0200 Branches: temp-cpp-type-cleanup https://developer.blender.org/rBc55061f539b5166709d30e50e3c2b57874f65a65 remove more duplication === M source/blender/functions/FN_cpp_type.hh M source/blender/functions/FN_cpp_type_make.hh === diff --git a/source/blender/functions/FN_cpp_type.hh b/source/blender/functions/FN_cpp_type.hh index 0c1d349bb4f..a8cc8494585 100644 --- a/source/blender/functions/FN_cpp_type.hh +++ b/source/blender/functions/FN_cpp_type.hh @@ -80,35 +80,27 @@ struct CPPTypeMembers { bool is_trivially_destructible = 0; void (*construct_default)(void *ptr) = nullptr; - void (*construct_default_n)(void *ptr, int64_t n) = nullptr; void (*construct_default_indices)(void *ptr, IndexMask mask) = nullptr; void (*destruct)(void *ptr) = nullptr; - void (*destruct_n)(void *ptr, int64_t n) = nullptr; void (*destruct_indices)(void *ptr, IndexMask mask) = nullptr; void (*copy_to_initialized)(const void *src, void *dst) = nullptr; - void (*copy_to_initialized_n)(const void *src, void *dst, int64_t n) = nullptr; void (*copy_to_initialized_indices)(const void *src, void *dst, IndexMask mask) = nullptr; void (*copy_to_uninitialized)(const void *src, void *dst) = nullptr; - void (*copy_to_uninitialized_n)(const void *src, void *dst, int64_t n) = nullptr; void (*copy_to_uninitialized_indices)(const void *src, void *dst, IndexMask mask) = nullptr; void (*move_to_initialized)(void *src, void *dst) = nullptr; - void (*move_to_initialized_n)(void *src, void *dst, int64_t n) = nullptr; void (*move_to_initialized_indices)(void *src, void *dst, IndexMask mask) = nullptr; void (*move_to_uninitialized)(void *src, void *dst) = nullptr; - void (*move_to_uninitialized_n)(void *src, void *dst, int64_t n) = nullptr; void (*move_to_uninitialized_indices)(void *src, void *dst, IndexMask mask) = nullptr; void (*relocate_to_initialized)(void *src, void *dst) = nullptr; - void (*relocate_to_initialized_n)(void *src, void *dst, int64_t n) = nullptr; void (*relocate_to_initialized_indices)(void *src, void *dst, IndexMask mask) = nullptr; void (*relocate_to_uninitialized)(void *src, void *dst) = nullptr; - void (*relocate_to_uninitialized_n)(void *src, void *dst, int64_t n) = nullptr; void (*relocate_to_uninitialized_indices)(void *src, void *dst, IndexMask mask) = nullptr; void (*fill_initialized)(const void *value, void *dst, int64_t n) = nullptr; @@ -230,9 +222,7 @@ class CPPType : NonCopyable, NonMovable { void construct_default_n(void *ptr, int64_t n) const { -BLI_assert(n == 0 || this->pointer_can_point_to_instance(ptr)); - -m_.construct_default_n(ptr, n); +this->construct_default_indices(ptr, IndexMask(n)); } void construct_default_indices(void *ptr, IndexMask mask) const @@ -259,9 +249,7 @@ class CPPType : NonCopyable, NonMovable { void destruct_n(void *ptr, int64_t n) const { -BLI_assert(n == 0 || this->pointer_can_point_to_instance(ptr)); - -m_.destruct_n(ptr, n); +this->destruct_indices(ptr, IndexMask(n)); } void destruct_indices(void *ptr, IndexMask mask) const @@ -288,11 +276,7 @@ class CPPType : NonCopyable, NonMovable { void copy_to_initialized_n(const void *src, void *dst, int64_t n) const { -BLI_assert(n == 0 || src != dst); -BLI_assert(n == 0 || this->pointer_can_point_to_instance(src)); -BLI_assert(n == 0 || this->pointer_can_point_to_instance(dst)); - -m_.copy_to_initialized_n(src, dst, n); +this->copy_to_initialized_indices(src, dst, IndexMask(n)); } void copy_to_initialized_indices(const void *src, void *dst, IndexMask mask) const @@ -323,11 +307,7 @@ class CPPType : NonCopyable, NonMovable { void copy_to_uninitialized_n(const void *src, void *dst, int64_t n) const { -BLI_assert(n == 0 || src != dst); -BLI_assert(n == 0 || this->pointer_can_point_to_instance(src)); -BLI_assert(n == 0 || this->pointer_can_point_to_instance(dst)); - -m_.copy_to_uninitialized_n(src, dst, n); +this->copy_to_uninitialized_indices(src, dst, IndexMask(n)); } void copy_to_uninitialized_indices(const void *src, void *dst, IndexMask mask) const @@ -358,11 +338,7 @@ class CPPType : NonCopyable, NonMovable { void move_to_initialized_n(void *src, void *dst, int64_t n) const { -BLI_assert(n == 0 || src != dst); -BLI_assert(n == 0 || this->pointer_can_point_to_instance(src)); -BLI_assert(n == 0 || this->pointer_can_point_to_instance(dst)); - -m_.move_to_initialized_n(src, dst, n); +this->move_to_initialized_indices(src, dst, IndexMask(n)); } void move_to_initialized_indices(void *src, void *dst, IndexMask mask) const @@ -393,11 +369,7 @@ class CPPTy
[Bf-blender-cvs] [25c1f9cd089] temp-cpp-type-cleanup: reduce duplication in CPPType
Commit: 25c1f9cd08925565ed4441252570959da6c59542 Author: Jacques Lucke Date: Sun Jun 27 14:01:38 2021 +0200 Branches: temp-cpp-type-cleanup https://developer.blender.org/rB25c1f9cd08925565ed4441252570959da6c59542 reduce duplication in CPPType === M source/blender/functions/FN_cpp_type.hh M source/blender/functions/FN_cpp_type_make.hh M source/blender/functions/intern/multi_function_network_optimization.cc === diff --git a/source/blender/functions/FN_cpp_type.hh b/source/blender/functions/FN_cpp_type.hh index 14eab2704e9..0c1d349bb4f 100644 --- a/source/blender/functions/FN_cpp_type.hh +++ b/source/blender/functions/FN_cpp_type.hh @@ -73,177 +73,67 @@ namespace blender::fn { -class CPPType : NonCopyable, NonMovable { - public: - using ConstructDefaultF = void (*)(void *ptr); - using ConstructDefaultNF = void (*)(void *ptr, int64_t n); - using ConstructDefaultIndicesF = void (*)(void *ptr, IndexMask mask); - - using DestructF = void (*)(void *ptr); - using DestructNF = void (*)(void *ptr, int64_t n); - using DestructIndicesF = void (*)(void *ptr, IndexMask mask); - - using CopyToInitializedF = void (*)(const void *src, void *dst); - using CopyToInitializedNF = void (*)(const void *src, void *dst, int64_t n); - using CopyToInitializedIndicesF = void (*)(const void *src, void *dst, IndexMask mask); - - using CopyToUninitializedF = void (*)(const void *src, void *dst); - using CopyToUninitializedNF = void (*)(const void *src, void *dst, int64_t n); - using CopyToUninitializedIndicesF = void (*)(const void *src, void *dst, IndexMask mask); - - using MoveToInitializedF = void (*)(void *src, void *dst); - using MoveToInitializedNF = void (*)(void *src, void *dst, int64_t n); - using MoveToInitializedIndicesF = void (*)(void *src, void *dst, IndexMask mask); - - using MoveToUninitializedF = void (*)(void *src, void *dst); - using MoveToUninitializedNF = void (*)(void *src, void *dst, int64_t n); - using MoveToUninitializedIndicesF = void (*)(void *src, void *dst, IndexMask mask); +struct CPPTypeMembers { + int64_t size = 0; + int64_t alignment = 0; + uintptr_t alignment_mask = 0; + bool is_trivially_destructible = 0; - using RelocateToInitializedF = void (*)(void *src, void *dst); - using RelocateToInitializedNF = void (*)(void *src, void *dst, int64_t n); - using RelocateToInitializedIndicesF = void (*)(void *src, void *dst, IndexMask mask); - - using RelocateToUninitializedF = void (*)(void *src, void *dst); - using RelocateToUninitializedNF = void (*)(void *src, void *dst, int64_t n); - using RelocateToUninitializedIndicesF = void (*)(void *src, void *dst, IndexMask mask); - - using FillInitializedF = void (*)(const void *value, void *dst, int64_t n); - using FillInitializedIndicesF = void (*)(const void *value, void *dst, IndexMask mask); - - using FillUninitializedF = void (*)(const void *value, void *dst, int64_t n); - using FillUninitializedIndicesF = void (*)(const void *value, void *dst, IndexMask mask); - - using DebugPrintF = void (*)(const void *value, std::stringstream &ss); - using IsEqualF = bool (*)(const void *a, const void *b); - using HashF = uint64_t (*)(const void *value); - - private: - int64_t size_; - int64_t alignment_; - uintptr_t alignment_mask_; - bool is_trivially_destructible_; + void (*construct_default)(void *ptr) = nullptr; + void (*construct_default_n)(void *ptr, int64_t n) = nullptr; + void (*construct_default_indices)(void *ptr, IndexMask mask) = nullptr; - ConstructDefaultF construct_default_; - ConstructDefaultNF construct_default_n_; - ConstructDefaultIndicesF construct_default_indices_; + void (*destruct)(void *ptr) = nullptr; + void (*destruct_n)(void *ptr, int64_t n) = nullptr; + void (*destruct_indices)(void *ptr, IndexMask mask) = nullptr; - DestructF destruct_; - DestructNF destruct_n_; - DestructIndicesF destruct_indices_; + void (*copy_to_initialized)(const void *src, void *dst) = nullptr; + void (*copy_to_initialized_n)(const void *src, void *dst, int64_t n) = nullptr; + void (*copy_to_initialized_indices)(const void *src, void *dst, IndexMask mask) = nullptr; - CopyToInitializedF copy_to_initialized_; - CopyToInitializedNF copy_to_initialized_n_; - CopyToInitializedIndicesF copy_to_initialized_indices_; + void (*copy_to_uninitialized)(const void *src, void *dst) = nullptr; + void (*copy_to_uninitialized_n)(const void *src, void *dst, int64_t n) = nullptr; + void (*copy_to_uninitialized_indices)(const void *src, void *dst, IndexMask mask) = nullptr; - CopyToUninitializedF copy_to_uninitialized_; - CopyToUninitializedNF copy_to_uninitialized_n_; - CopyToUninitializedIndicesF copy_to_uninitialized_indices_; + void (*move_to_initialized)(void *src, void *dst) = nullptr; + void (*move_to_initialized_n)(void *src, void *dst, int64
[Bf-blender-cvs] [f36974123b1] soc-2021-simulation-display: Merge branch 'master' into soc-2021-simulation-display
Commit: f36974123b1693c29f2014f314d517b75bbf2da0 Author: soumya pochiraju Date: Sun Jun 27 20:27:50 2021 +0530 Branches: soc-2021-simulation-display https://developer.blender.org/rBf36974123b1693c29f2014f314d517b75bbf2da0 Merge branch 'master' into soc-2021-simulation-display === === diff --cc source/blender/blenkernel/intern/softbody.c index 2cb0cd85207,123843c88db..bf8c9d60e0a --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@@ -2111,10 -2111,9 +2111,10 @@@ static int _softbody_calc_forces_slice_ float eval_sb_fric_force_scale = sb_fric_force_scale(ob); pd_point_from_soft(scene, bp->pos, bp->vec, sb->bpoint - bp, &epoint); -BKE_effectors_apply(effectors, NULL, sb->effector_weights, &epoint, force, NULL, speed); +BKE_effectors_apply( +effectors, NULL, sb->effector_weights, &epoint, force, NULL, speed, NULL); - /* apply forcefield*/ + /* Apply force-field. */ mul_v3_fl(force, fieldfactor * eval_sb_fric_force_scale); add_v3_v3(bp->force, force); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c604a944df7] soc-2021-simulation-display: make format
Commit: c604a944df72f08bd1bba7e5cd2cfa9b166c8484 Author: soumya pochiraju Date: Tue Apr 27 12:44:53 2021 +0530 Branches: soc-2021-simulation-display https://developer.blender.org/rBc604a944df72f08bd1bba7e5cd2cfa9b166c8484 make format === M intern/libmv/third_party/msinttypes/inttypes.h M intern/libmv/third_party/msinttypes/stdint.h === diff --git a/intern/libmv/third_party/msinttypes/inttypes.h b/intern/libmv/third_party/msinttypes/inttypes.h index 71f5693def6..eae057851f6 100644 --- a/intern/libmv/third_party/msinttypes/inttypes.h +++ b/intern/libmv/third_party/msinttypes/inttypes.h @@ -32,277 +32,276 @@ // /// -#ifndef _MSC_VER // [ -#error "Use this header only with Microsoft Visual C++ compilers!" -#endif // _MSC_VER ] +#ifndef _MSC_VER // [ +# error "Use this header only with Microsoft Visual C++ compilers!" +#endif // _MSC_VER ] -#ifndef _MSC_INTTYPES_H_ // [ -#define _MSC_INTTYPES_H_ +#ifndef _MSC_INTTYPES_H_ // [ +# define _MSC_INTTYPES_H_ -#if _MSC_VER > 1000 -#pragma once -#endif +# if _MSC_VER > 1000 +#pragma once +# endif -#include +# include // 7.8 Format conversion of integer types typedef struct { - intmax_t quot; - intmax_t rem; + intmax_t quot; + intmax_t rem; } imaxdiv_t; // 7.8.1 Macros for format specifiers -#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198 +# if !defined(__cplusplus) || \ + defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198 // The fprintf macros for signed integers are: -#define PRId8 "d" -#define PRIi8 "i" -#define PRIdLEAST8 "d" -#define PRIiLEAST8 "i" -#define PRIdFAST8 "d" -#define PRIiFAST8 "i" - -#define PRId16 "hd" -#define PRIi16 "hi" -#define PRIdLEAST16 "hd" -#define PRIiLEAST16 "hi" -#define PRIdFAST16 "hd" -#define PRIiFAST16 "hi" - -#define PRId32 "I32d" -#define PRIi32 "I32i" -#define PRIdLEAST32 "I32d" -#define PRIiLEAST32 "I32i" -#define PRIdFAST32 "I32d" -#define PRIiFAST32 "I32i" - -#define PRId64 "I64d" -#define PRIi64 "I64i" -#define PRIdLEAST64 "I64d" -#define PRIiLEAST64 "I64i" -#define PRIdFAST64 "I64d" -#define PRIiFAST64 "I64i" - -#define PRIdMAX "I64d" -#define PRIiMAX "I64i" - -#define PRIdPTR "Id" -#define PRIiPTR "Ii" +#define PRId8 "d" +#define PRIi8 "i" +#define PRIdLEAST8 "d" +#define PRIiLEAST8 "i" +#define PRIdFAST8 "d" +#define PRIiFAST8 "i" + +#define PRId16 "hd" +#define PRIi16 "hi" +#define PRIdLEAST16 "hd" +#define PRIiLEAST16 "hi" +#define PRIdFAST16 "hd" +#define PRIiFAST16 "hi" + +#define PRId32 "I32d" +#define PRIi32 "I32i" +#define PRIdLEAST32 "I32d" +#define PRIiLEAST32 "I32i" +#define PRIdFAST32 "I32d" +#define PRIiFAST32 "I32i" + +#define PRId64 "I64d" +#define PRIi64 "I64i" +#define PRIdLEAST64 "I64d" +#define PRIiLEAST64 "I64i" +#define PRIdFAST64 "I64d" +#define PRIiFAST64 "I64i" + +#define PRIdMAX "I64d" +#define PRIiMAX "I64i" + +#define PRIdPTR "Id" +#define PRIiPTR "Ii" // The fprintf macros for unsigned integers are: -#define PRIo8 "o" -#define PRIu8 "u" -#define PRIx8 "x" -#define PRIX8 "X" -#define PRIoLEAST8 "o" -#define PRIuLEAST8 "u" -#define PRIxLEAST8 "x" -#define PRIXLEAST8 "X" -#define PRIoFAST8 "o" -#define PRIuFAST8 "u" -#define PRIxFAST8 "x" -#define PRIXFAST8 "X" - -#define PRIo16 "ho" -#define PRIu16 "hu" -#define PRIx16 "hx" -#define PRIX16 "hX" -#define PRIoLEAST16 "ho" -#define PRIuLEAST16 "hu" -#define PRIxLEAST16 "hx" -#define PRIXLEAST16 "hX" -#define PRIoFAST16 "ho" -#define PRIuFAST16 "hu" -#define PRIxFAST16 "hx" -#define PRIXFAST16 "hX" - -#define PRIo32 "I32o" -#define PRIu32 "I32u" -#define PRIx32 "I32x" -#define PRIX32 "I32X" -#define PRIoLEAST32 "I32o" -#define PRIuLEAST32 "I32u" -#define PRIxLEAST32 "I32x" -#define PRIXLEAST32 "I32X" -#define PRIoFAST32 "I32o" -#define PRIuFAST32 "I32u" -#define PRIxFAST32 "I32x" -#define PRIXFAST32 "I32X" - -#define PRIo64 "I64o" -#define PRIu64 "I64u" -#define PRIx64 "I64x" -#define PRIX64 "I64X" -#define PRIoLEAST64 "I64o" -#define PRIuLEAST64 "I64u" -#define PRIxLEAST64 "I64x" -#define PRIXLEAST64 "I64X" -#define PRIoFAST64 "I64o" -#define PRIuFAST64 "I64u" -#define PRIxFAST64 "I64x" -#define PRIXFAST64 "I64X" - -#define PRIoMAX "I64o" -#define PRIuMAX "I64u" -#define PRIxMAX "I64x" -#define PRIXMAX "I64X" - -#define PRIoPTR "Io" -#define PRIuPTR "Iu" -#define PRIxPTR "Ix" -#define PRIXPTR "IX" +#
[Bf-blender-cvs] [b9903c78c1b] soc-2021-simulation-display: Physics: Added visualisation for rigid body states and a small fix for forces
Commit: b9903c78c1bcab424f7faf98737d32888abe97d0 Author: soumya pochiraju Date: Sun Jun 27 20:12:46 2021 +0530 Branches: soc-2021-simulation-display https://developer.blender.org/rBb9903c78c1bcab424f7faf98737d32888abe97d0 Physics: Added visualisation for rigid body states and a small fix for forces === M intern/rigidbody/rb_bullet_api.cpp M release/scripts/startup/bl_ui/properties_physics_rigidbody.py M source/blender/blenkernel/intern/rigidbody.c M source/blender/draw/engines/overlay/overlay_extra.c M source/blender/draw/engines/workbench/workbench_materials.c M source/blender/makesdna/DNA_rigidbody_types.h M source/blender/makesrna/intern/rna_rigidbody.c === diff --git a/intern/rigidbody/rb_bullet_api.cpp b/intern/rigidbody/rb_bullet_api.cpp index d46b18416d3..cf079653678 100644 --- a/intern/rigidbody/rb_bullet_api.cpp +++ b/intern/rigidbody/rb_bullet_api.cpp @@ -225,10 +225,10 @@ void RB_dworld_get_impulse(rbDynamicsWorld *world, const void *obB = contactManifold->getBody1(); if (num_norm_forces > 2) break; -if (obA != rbo->body && obB != rbo->body) { - continue; -} -else { +if (obA != rbo->body && obB != rbo->body) { + continue; +} +else { btVector3 tot_impulse = btVector3(0.0, 0.0, 0.0); btVector3 final_loc = btVector3(0.0, 0.0, 0.0); btScalar tot_impulse_magnitude = 0.f; @@ -238,13 +238,15 @@ void RB_dworld_get_impulse(rbDynamicsWorld *world, for (int j = 0; j < numContacts; j++) { /* Find points where impulse was appplied. */ btManifoldPoint &pt = contactManifold->getContactPoint(j); -if (pt.getAppliedImpulse() > 0.f) +if (pt.getAppliedImpulse() > 0.f || -pt.getAppliedImpulse() > 0.f) { num_impulse_points++; + printf("getApplied:%f\n",pt.getAppliedImpulse()); +} } for (int j = 0; j < numContacts; j++) { btManifoldPoint &pt = contactManifold->getContactPoint(j); -if (pt.getAppliedImpulse() > 0.f) { +if (pt.getAppliedImpulse() > 0.f || -pt.getAppliedImpulse() > 0.f) { const btVector3 &loc = pt.getPositionWorldOnB(); const btVector3 imp = (rbo->body == obB) ? -pt.m_normalWorldOnB * pt.getAppliedImpulse() / timeSubStep : diff --git a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py index 058fbc5c295..99b71657bea 100644 --- a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py +++ b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py @@ -324,6 +324,7 @@ class PHYSICS_PT_rigid_body_display_options(PHYSICS_PT_rigidbody_panel, Panel): col.prop(rbo, "display_acceleration") col.prop(rbo, "display_velocity") col.prop(rbo, "display_collisions") +col.prop(rbo, "display_state") class PHYSICS_PT_rigid_body_display_force_types(PHYSICS_PT_rigidbody_panel, Panel): bl_label = "Forces" diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index 80a66de6ddc..0be8137ef2d 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -2260,6 +2260,14 @@ void BKE_rigidbody_do_simulation(Depsgraph *depsgraph, Scene *scene, float ctime const float interp_step = 1.0f / rbw->substeps_per_frame; float cur_interp_val = interp_step; +/* Set all Objects normal forces to zero. */ +for (int i = 0; i < rbw->numbodies; i++) { +Object *ob = rbw->objects[i]; +zero_v3(ob->rigidbody_object->norm_forces[0].vector); +zero_v3(ob->rigidbody_object->norm_forces[1].vector); +zero_v3(ob->rigidbody_object->norm_forces[2].vector); +} + for (int i = 0; i < rbw->substeps_per_frame; i++) { rigidbody_update_kinematic_obj_substep(&substep_targets, cur_interp_val); RB_dworld_step_simulation(rbw->shared->physics_world, substep, 0, substep); @@ -2286,18 +2294,16 @@ void BKE_rigidbody_do_simulation(Depsgraph *depsgraph, Scene *scene, float ctime vec_locations, norm_flag, fric_flag); -copy_v3_v3(ob->rigidbody_object->vec_locations[0].vector, vec_locations[0]); -copy_v3_v3(ob->rigidbody_object->vec_locations[1].vector, vec_locations[1]); -copy_v3_v3(ob->rigidbody_object->vec_locations[2].vector, vec_locations[2]); -if (norm_flag) { - copy_v3_v3(ob->rigidbody_object->norm_forces[0].vector, norm_forces[0]); - copy_v3_v3(ob->rigidbody_object->norm_forces[1].vector, norm_forces[1]); - copy_v3_v3(ob->rigidbody_object->norm_for
[Bf-blender-cvs] [bad23a721f5] soc-2021-vse-strip-thumbnails: Thumbnail Code Cleanup
Commit: bad23a721f547a6bb6151b6f33e9f85ac05ce5c8 Author: Aditya Y Jeppu Date: Sun Jun 27 18:39:06 2021 +0530 Branches: soc-2021-vse-strip-thumbnails https://developer.blender.org/rBbad23a721f547a6bb6151b6f33e9f85ac05ce5c8 Thumbnail Code Cleanup Improved from the hacky way of cropping using the same process for scaling to thumb size to using dedicated IMB_rect_crop method. Cleaned up unnecessary code and variables. === M source/blender/editors/space_sequencer/sequencer_draw.c M source/blender/sequencer/SEQ_render.h M source/blender/sequencer/intern/image_cache.c M source/blender/sequencer/intern/image_cache.h M source/blender/sequencer/intern/render.c === diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 30b1d68f9a2..03ef414d9e6 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -1099,8 +1099,11 @@ static void draw_seq_strip_thumbnail(View2D *v2d, SeqRenderData context = {0}; ImBuf *ibuf; bool min_size, clipped = false; - float aspect_ratio, image_x, image_y, cropx_min, cropx_max; - rctf crop; + float aspect_ratio, image_y, cropx_min, cropx_max; + rcti crop; + + /* Not sending v2d directly to have Drawing and Internal code separation */ + float cache_limits[4] = {v2d->tot.xmin, v2d->tot.xmax, v2d->cur.xmin, v2d->cur.xmax}; /* if thumbs too small ignore */ min_size = ((y2 - y1) / pixely) > 40 * U.dpi_fac; @@ -1115,8 +1118,7 @@ static void draw_seq_strip_thumbnail(View2D *v2d, context.is_proxy_render = false; context.is_thumb = true; - ibuf = SEQ_render_thumbnail(&context, seq, seq->startdisp, v2d, &crop, clipped); - image_x = ibuf->x; + ibuf = SEQ_render_thumbnail(&context, seq, seq->startdisp, cache_limits, &crop, false); image_y = ibuf->y; /*Calculate thumb dimensions */ @@ -1133,7 +1135,7 @@ static void draw_seq_strip_thumbnail(View2D *v2d, x1 = seq->start; float cut_off = 0; - float upper_thumb_bound = seq->endstill ? seq->enddisp - seq->endstill : seq->enddisp; + float upper_thumb_bound = (seq->endstill) ? (seq->start + seq->len) : seq->enddisp; while (x1 < upper_thumb_bound) { x2 = x1 + thumb_w; @@ -1162,7 +1164,6 @@ static void draw_seq_strip_thumbnail(View2D *v2d, } /* clip if full thumbnail cannot be displayed */ - if (x2 > (upper_thumb_bound)) { x2 = upper_thumb_bound; clipped = true; @@ -1172,19 +1173,17 @@ static void draw_seq_strip_thumbnail(View2D *v2d, cropx_min = (cut_off / pixelx) / (zoom_y / pixely); cropx_max = ((x2 - x1) / pixelx) / (zoom_y / pixely); -BLI_rctf_init(&crop, cropx_min, cropx_max, 0, image_y); -/* Get the image */ +BLI_rcti_init(&crop, (int)(cropx_min), (int)(cropx_max)-1, 0, (int)(image_y)-1); -ibuf = SEQ_render_thumbnail(&context, seq, x1 + (int)(cut_off), v2d, &crop, clipped); +/* Get the image */ +ibuf = SEQ_render_thumbnail(&context, seq, x1 + (int)(cut_off), cache_limits, &crop, clipped); -GPU_blend(GPU_BLEND_ALPHA); if (ibuf) { - ED_draw_imbuf_ctx_clipping(C, ibuf, x1, y1, false, x1 + cut_off, y1, x2, y2, zoom_x, zoom_y); + ED_draw_imbuf_ctx_clipping( + C, ibuf, x1 + cut_off, y1, true, x1 + cut_off, y1, x2, y2, zoom_x, zoom_y); IMB_freeImBuf(ibuf); } -GPU_blend(GPU_BLEND_NONE); - cut_off = 0; x1 = x2; } diff --git a/source/blender/sequencer/SEQ_render.h b/source/blender/sequencer/SEQ_render.h index 06ebbfac36d..6860b2c15d2 100644 --- a/source/blender/sequencer/SEQ_render.h +++ b/source/blender/sequencer/SEQ_render.h @@ -71,8 +71,8 @@ struct ImBuf *SEQ_render_give_ibuf_direct(const SeqRenderData *context, struct ImBuf *SEQ_render_thumbnail(SeqRenderData *context, struct Sequence *seq, float timeline_frame, - View2D *v2d, - rctf *crop, + float *cache_limits, + rcti *crop, bool clipped); void SEQ_render_init_colorspace(struct Sequence *seq); void SEQ_render_new_render_data(struct Main *bmain, diff --git a/source/blender/sequencer/intern/image_cache.c b/source/blender/sequencer/intern/image_cache.c index 06c081c1ba1..8d0d6a28941 100644 --- a/source/blender/sequencer/intern/image_cache.c +++ b/source/blender/sequencer/intern/image_cache.c @@ -1339,7 +1339,7 @@ void seq_cache_cleanup_sequence(Scene *scene, seq_cache_unlock(scene); } -void seq_cache_thumbnail_cleanup(Scene *scene, Sequence *seq, Sequence *seq_changed) +void seq_cache_thumbnail_cleanup(Scene *scene, Sequence *seq_changed) { SeqC
[Bf-blender-cvs] [9f5d9c16293] soc-2021-vse-strip-thumbnails: Merge branch 'master' into soc-2021-vse-strip-thumbnails
Commit: 9f5d9c1629328912f290cf963dbbbca60e868506 Author: Aditya Y Jeppu Date: Sun Jun 27 10:14:36 2021 +0530 Branches: soc-2021-vse-strip-thumbnails https://developer.blender.org/rB9f5d9c1629328912f290cf963dbbbca60e868506 Merge branch 'master' into soc-2021-vse-strip-thumbnails === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [561d3f3b98c] soc-2021-curves: Explicitly mentioned array lengths in method signatures for clarity
Commit: 561d3f3b98cc6941c2942cb7b799cde5f2c5e06c Author: dilithjay Date: Sun Jun 27 17:19:14 2021 +0530 Branches: soc-2021-curves https://developer.blender.org/rB561d3f3b98cc6941c2942cb7b799cde5f2c5e06c Explicitly mentioned array lengths in method signatures for clarity === M source/blender/editors/curve/editcurve_pen.c === diff --git a/source/blender/editors/curve/editcurve_pen.c b/source/blender/editors/curve/editcurve_pen.c index 9b291379efe..806ff3cbe58 100644 --- a/source/blender/editors/curve/editcurve_pen.c +++ b/source/blender/editors/curve/editcurve_pen.c @@ -87,8 +87,8 @@ struct TempBeztData { } TempBeztData; /* Convert mouse location to worldspace coordinates. */ -static void mouse_location_to_worldspace(const int *mouse_loc, - const float *depth, +static void mouse_location_to_worldspace(const int mouse_loc[2], + const float depth[3], const ViewContext *vc, float r_location[3]) { @@ -228,7 +228,7 @@ static void delete_bp_from_nurb(BPoint *bp, Nurb *nu) } /* Get a measure of how zoomed in the current view is. */ -static float get_view_zoom(const float *depth, const ViewContext *vc) +static float get_view_zoom(const float depth[3], const ViewContext *vc) { int p1[2] = {0, 0}; int p2[2] = {100, 0}; @@ -239,7 +239,7 @@ static float get_view_zoom(const float *depth, const ViewContext *vc) } /* Get the closest point on an edge to a given point based on perpendicular distance. */ -static bool get_closest_point_on_edge(float *point, +static bool get_closest_point_on_edge(float point[3], const float pos[2], const float pos1[3], const float pos2[3], @@ -466,12 +466,12 @@ static void select_and_get_point(ViewContext *vc, } /* Calculates handle lengths of added and adjacent control points such that shape is preserved. */ -static void calculate_new_bezier_point(const float *point_prev, - float *handle_prev, - float *new_left_handle, - float *new_right_handle, - float *handle_next, - const float *point_next, +static void calculate_new_bezier_point(const float point_prev[3], + float handle_prev[3], + float new_left_handle[3], + float new_right_handle[3], + float handle_next[3], + const float point_next[3], const float parameter) { float center_point[3]; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [71ef45f142b] soc-2021-curves: Removed unnecessary memory allocation when deleting a point
Commit: 71ef45f142b3efc2fd1032ce0e92ec4abdacc1ed Author: dilithjay Date: Sun Jun 27 17:24:44 2021 +0530 Branches: soc-2021-curves https://developer.blender.org/rB71ef45f142b3efc2fd1032ce0e92ec4abdacc1ed Removed unnecessary memory allocation when deleting a point === M source/blender/editors/curve/editcurve_pen.c === diff --git a/source/blender/editors/curve/editcurve_pen.c b/source/blender/editors/curve/editcurve_pen.c index 806ff3cbe58..336ee8e94fb 100644 --- a/source/blender/editors/curve/editcurve_pen.c +++ b/source/blender/editors/curve/editcurve_pen.c @@ -205,12 +205,7 @@ static void delete_bezt_from_nurb(BezTriple *bezt, Nurb *nu) BLI_assert(nu->type == CU_BEZIER); int index = BKE_curve_nurb_vert_index_get(nu, bezt); nu->pntsu -= 1; - BezTriple *bezt1 = (BezTriple *)MEM_mallocN(nu->pntsu * sizeof(BezTriple), "NewBeztCurve"); - memcpy(bezt1, nu->bezt, index * sizeof(BezTriple)); - memcpy(bezt1 + index, nu->bezt + index + 1, (nu->pntsu - index) * sizeof(BezTriple)); - - MEM_freeN(nu->bezt); - nu->bezt = bezt1; + memcpy(nu->bezt + index, nu->bezt + index + 1, (nu->pntsu - index) * sizeof(BezTriple)); } /* Delete given BPoint from given Nurb. */ @@ -219,12 +214,7 @@ static void delete_bp_from_nurb(BPoint *bp, Nurb *nu) BLI_assert(nu->type == CU_NURBS); int index = BKE_curve_nurb_vert_index_get(nu, bp); nu->pntsu -= 1; - BPoint *bp1 = (BPoint *)MEM_mallocN(nu->pntsu * sizeof(BPoint), "NewBpCurve"); - memcpy(bp1, nu->bp, index * sizeof(BPoint)); - memcpy(bp1 + index, nu->bp + index + 1, (nu->pntsu - index) * sizeof(BPoint)); - - MEM_freeN(nu->bp); - nu->bp = bp1; + memcpy(nu->bp + index, nu->bp + index + 1, (nu->pntsu - index) * sizeof(BPoint)); } /* Get a measure of how zoomed in the current view is. */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b8c0929428c] soc-2021-curves: Fixed several build warnings
Commit: b8c0929428c04f6e8032480f182939a23e0ed896 Author: dilithjay Date: Sun Jun 27 11:42:51 2021 +0530 Branches: soc-2021-curves https://developer.blender.org/rBb8c0929428c04f6e8032480f182939a23e0ed896 Fixed several build warnings === M source/blender/editors/curve/editcurve_pen.c === diff --git a/source/blender/editors/curve/editcurve_pen.c b/source/blender/editors/curve/editcurve_pen.c index afbe26139cc..68500d6fc9f 100644 --- a/source/blender/editors/curve/editcurve_pen.c +++ b/source/blender/editors/curve/editcurve_pen.c @@ -168,7 +168,7 @@ static void free_up_handles_for_movement(BezTriple *bezt, bool f1, bool f3) } } -static void move_selected_bezt_to_mouse(BezTriple *bezt, ViewContext *vc, wmEvent *event) +static void move_selected_bezt_to_mouse(BezTriple *bezt, ViewContext *vc, const wmEvent *event) { /* Get mouse location in 3D space. */ float location[3]; @@ -283,12 +283,12 @@ static bool get_closest_point_on_edge(float *point, } /* Get closest control point in all nurbs in given ListBase to a given point. */ -static void *get_closest_cp_to_point_in_nurbs(ListBase *nurbs, - Nurb **r_nu, - BezTriple **r_bezt, - BPoint **r_bp, - const float point[2], - const ViewContext *vc) +static void get_closest_cp_to_point_in_nurbs(ListBase *nurbs, + Nurb **r_nu, + BezTriple **r_bezt, + BPoint **r_bp, + const float point[2], + const ViewContext *vc) { float min_distance_bezt = 1; float min_distance_bp = 1; @@ -474,7 +474,7 @@ static void calculate_new_bezier_point(const float *point_prev, const float *point_next, const float parameter) { - const float center_point[3]; + float center_point[3]; interp_v3_v3v3(center_point, handle_prev, handle_next, parameter); interp_v3_v3v3(handle_prev, point_prev, handle_prev, parameter); interp_v3_v3v3(handle_next, handle_next, point_next, parameter); @@ -501,7 +501,7 @@ static void update_data_for_all_nurbs(ListBase *nurbs, ViewContext *vc, void *op } int i; - BezTriple *bezt; + BezTriple *bezt = NULL; for (i = 0; i < nu->pntsu - 1; i++) { bezt = &nu->bezt[i]; update_data_if_nearest_point_in_segment(bezt, bezt + 1, nu, i, vc, screen_co, data); @@ -567,7 +567,7 @@ static void add_bezt_to_nurb(Nurb *nu, void *op_data, Curve *cu) } /* Make a cut on the nearest nurb at the closest point. */ -static void make_cut(wmEvent *event, Curve *cu, Nurb **r_nu, ViewContext *vc) +static void make_cut(const wmEvent *event, Curve *cu, Nurb **r_nu, ViewContext *vc) { struct TempBeztData data = {.bezt_index = 0, .min_dist = 1, @@ -594,7 +594,7 @@ static void make_cut(wmEvent *event, Curve *cu, Nurb **r_nu, ViewContext *vc) } /* Add a new control point connected to the selected control point. */ -static void add_point_connected_to_selected_point(Curve *cu, ViewContext *vc, wmEvent *event) +static void add_point_connected_to_selected_point(Curve *cu, ViewContext *vc, const wmEvent *event) { Nurb *nu = NULL; BezTriple *bezt = NULL; @@ -691,7 +691,8 @@ static int curve_pen_modal(bContext *C, wmOperator *op, const wmEvent *event) } if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE) && !cut_or_delete) { -if (!dragging && WM_event_drag_test(event, &event->prevclickx) && event->val == KM_PRESS) { +int prev_xy[2] = {event->prevclickx, event->prevclicky}; +if (!dragging && WM_event_drag_test(event, prev_xy) && event->val == KM_PRESS) { RNA_boolean_set(op->ptr, "dragging", true); dragging = true; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [9c3fa785fb4] soc-2021-curves: Fixed bug where points were added with a displacement
Commit: 9c3fa785fb49aa41a24a41cf746a8250c179251e Author: dilithjay Date: Sun Jun 27 14:02:49 2021 +0530 Branches: soc-2021-curves https://developer.blender.org/rB9c3fa785fb49aa41a24a41cf746a8250c179251e Fixed bug where points were added with a displacement === M source/blender/editors/curve/editcurve_pen.c === diff --git a/source/blender/editors/curve/editcurve_pen.c b/source/blender/editors/curve/editcurve_pen.c index 68500d6fc9f..9b291379efe 100644 --- a/source/blender/editors/curve/editcurve_pen.c +++ b/source/blender/editors/curve/editcurve_pen.c @@ -594,11 +594,14 @@ static void make_cut(const wmEvent *event, Curve *cu, Nurb **r_nu, ViewContext * } /* Add a new control point connected to the selected control point. */ -static void add_point_connected_to_selected_point(Curve *cu, ViewContext *vc, const wmEvent *event) +static void add_point_connected_to_selected_point(ViewContext *vc, + Object *obedit, + const wmEvent *event) { Nurb *nu = NULL; BezTriple *bezt = NULL; BPoint *bp = NULL; + Curve *cu = vc->obedit->data; float location[3]; @@ -616,6 +619,11 @@ static void add_point_connected_to_selected_point(Curve *cu, ViewContext *vc, co ED_view3d_win_to_3d_int(vc->v3d, vc->region, location, event->mval, location); EditNurb *editnurb = cu->editnurb; + + float imat[4][4]; + invert_m4_m4(imat, obedit->obmat); + mul_m4_v3(imat, location); + ed_editcurve_addvert(cu, editnurb, vc->v3d, location); ED_curve_nurb_vert_selected_find(cu, vc->v3d, &nu, &bezt, &bp); if (bezt) { @@ -662,7 +670,6 @@ static int curve_pen_modal(bContext *C, wmOperator *op, const wmEvent *event) Object *obedit = CTX_data_edit_object(C); ED_view3d_viewcontext_init(C, &vc, depsgraph); - Curve *cu = vc.obedit->data; BezTriple *bezt = NULL; BPoint *bp = NULL; @@ -727,6 +734,7 @@ static int curve_pen_modal(bContext *C, wmOperator *op, const wmEvent *event) if (cut_or_delete) { /* Delete retrieved control point. */ +Curve *cu = vc.obedit->data; ListBase *nurbs = BKE_curve_editNurbs_get(cu); float mouse_point[2] = {(float)event->mval[0], (float)event->mval[1]}; @@ -757,7 +765,7 @@ static int curve_pen_modal(bContext *C, wmOperator *op, const wmEvent *event) RNA_boolean_set(op->ptr, "new", !retval); if (!retval) { - add_point_connected_to_selected_point(cu, &vc, event); + add_point_connected_to_selected_point(&vc, obedit, event); } } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs