2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
* Copyright 2005 Blender Foundation. All rights reserved. */
|
2009-10-03 15:35:01 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup gpu
|
2011-02-21 06:58:46 +00:00
|
|
|
*/
|
|
|
|
|
|
2009-10-03 15:35:01 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
2015-07-17 12:25:05 +02:00
|
|
|
#include <stddef.h>
|
|
|
|
|
|
2022-04-05 11:42:55 -07:00
|
|
|
#include "BKE_attribute.h"
|
2022-06-08 12:30:01 -07:00
|
|
|
#include "BKE_pbvh.h"
|
2022-04-05 11:42:55 -07:00
|
|
|
|
2020-03-02 15:28:47 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-12-30 18:24:54 +00:00
|
|
|
struct BMesh;
|
2012-05-10 20:33:09 +00:00
|
|
|
struct CCGElem;
|
|
|
|
|
struct CCGKey;
|
|
|
|
|
struct DMFlagMat;
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
struct GSet;
|
2022-06-08 12:30:01 -07:00
|
|
|
struct TableGSet;
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
struct MLoop;
|
2019-05-14 20:20:01 +10:00
|
|
|
struct MLoopCol;
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
struct MLoopTri;
|
|
|
|
|
struct MPoly;
|
2020-09-30 11:51:13 +10:00
|
|
|
struct MPropCol;
|
2015-07-16 16:22:28 +02:00
|
|
|
struct MVert;
|
2019-12-17 10:08:47 +11:00
|
|
|
struct Mesh;
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
struct PBVH;
|
2020-04-03 08:29:09 -06:00
|
|
|
struct SubdivCCG;
|
2022-06-08 12:30:01 -07:00
|
|
|
struct CustomData;
|
|
|
|
|
|
|
|
|
|
typedef struct PBVHGPUFormat PBVHGPUFormat;
|
2015-07-14 16:48:23 +02:00
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
|
* Buffers for drawing from PBVH grids.
|
|
|
|
|
*/
|
2014-01-02 22:22:36 +02:00
|
|
|
typedef struct GPU_PBVH_Buffers GPU_PBVH_Buffers;
|
2012-02-22 22:48:34 +00:00
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
|
* Build must be called once before using the other functions,
|
|
|
|
|
* used every time mesh topology changes.
|
|
|
|
|
*
|
|
|
|
|
* Threaded: do not call any functions that use OpenGL calls!
|
|
|
|
|
*/
|
2020-05-14 15:27:11 +02:00
|
|
|
GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const struct MPoly *mpoly,
|
2015-07-17 03:36:03 +10:00
|
|
|
const struct MLoop *mloop,
|
|
|
|
|
const struct MLoopTri *looptri,
|
2020-09-04 20:59:13 +02:00
|
|
|
const struct MVert *mvert,
|
2015-07-17 03:36:03 +10:00
|
|
|
const int *face_indices,
|
2020-09-04 20:59:13 +02:00
|
|
|
const int *sculpt_face_sets,
|
2022-01-07 11:38:08 +11:00
|
|
|
int face_indices_len,
|
2019-10-09 19:03:57 +02:00
|
|
|
const struct Mesh *mesh);
|
2012-02-22 22:48:34 +00:00
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
|
* Threaded: do not call any functions that use OpenGL calls!
|
|
|
|
|
*/
|
2022-06-29 21:04:07 -07:00
|
|
|
GPU_PBVH_Buffers *GPU_pbvh_grid_buffers_build(int totgrid,
|
|
|
|
|
unsigned int **grid_hidden,
|
|
|
|
|
bool smooth);
|
2012-02-22 22:48:34 +00:00
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
|
* Threaded: do not call any functions that use OpenGL calls!
|
|
|
|
|
*/
|
2017-05-11 22:03:50 +10:00
|
|
|
GPU_PBVH_Buffers *GPU_pbvh_bmesh_buffers_build(bool smooth_shading);
|
2012-12-30 18:24:54 +00:00
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
|
* Free part of data for update. Not thread safe, must run in OpenGL main thread.
|
|
|
|
|
*/
|
2019-09-27 22:42:57 +02:00
|
|
|
void GPU_pbvh_bmesh_buffers_update_free(GPU_PBVH_Buffers *buffers);
|
|
|
|
|
void GPU_pbvh_grid_buffers_update_free(GPU_PBVH_Buffers *buffers,
|
|
|
|
|
const struct DMFlagMat *grid_flag_mats,
|
2020-07-13 11:27:09 +02:00
|
|
|
const int *grid_indices);
|
2014-05-05 21:13:27 +03:00
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
|
* Update mesh buffers without topology changes. Threaded.
|
|
|
|
|
*/
|
2018-01-12 17:35:26 +01:00
|
|
|
enum {
|
2018-01-15 11:38:56 +01:00
|
|
|
GPU_PBVH_BUFFERS_SHOW_MASK = (1 << 1),
|
2020-03-05 14:53:23 +01:00
|
|
|
GPU_PBVH_BUFFERS_SHOW_VCOL = (1 << 2),
|
|
|
|
|
GPU_PBVH_BUFFERS_SHOW_SCULPT_FACE_SETS = (1 << 3),
|
2018-01-12 17:35:26 +01:00
|
|
|
};
|
|
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
2022-06-08 12:30:01 -07:00
|
|
|
* Creates a vertex buffer (coordinate, normal, color) and,
|
|
|
|
|
* if smooth shading, an element index buffer.
|
2021-12-09 20:01:47 +11:00
|
|
|
* Threaded: do not call any functions that use OpenGL calls!
|
|
|
|
|
*/
|
2022-06-08 12:30:01 -07:00
|
|
|
void GPU_pbvh_mesh_buffers_update(PBVHGPUFormat *vbo_id,
|
|
|
|
|
GPU_PBVH_Buffers *buffers,
|
2015-07-16 16:22:28 +02:00
|
|
|
const struct MVert *mvert,
|
2022-06-08 12:30:01 -07:00
|
|
|
const CustomData *vdata,
|
|
|
|
|
const CustomData *ldata,
|
2015-07-11 03:25:28 +10:00
|
|
|
const float *vmask,
|
2020-03-05 14:53:23 +01:00
|
|
|
const int *sculpt_face_sets,
|
2022-06-08 12:30:01 -07:00
|
|
|
const int face_sets_color_seed,
|
|
|
|
|
const int face_sets_color_default,
|
|
|
|
|
const int update_flags,
|
|
|
|
|
const float (*vert_normals)[3]);
|
|
|
|
|
|
|
|
|
|
bool GPU_pbvh_attribute_names_update(PBVHType pbvh_type,
|
|
|
|
|
PBVHGPUFormat *vbo_id,
|
|
|
|
|
const struct CustomData *vdata,
|
|
|
|
|
const struct CustomData *ldata,
|
|
|
|
|
bool active_attrs_only);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
|
* Creates a vertex buffer (coordinate, normal, color) and,
|
|
|
|
|
* if smooth shading, an element index buffer.
|
|
|
|
|
* Threaded: do not call any functions that use OpenGL calls!
|
|
|
|
|
*/
|
2022-06-08 12:30:01 -07:00
|
|
|
void GPU_pbvh_bmesh_buffers_update(PBVHGPUFormat *vbo_id,
|
|
|
|
|
struct GPU_PBVH_Buffers *buffers,
|
2017-05-11 22:03:50 +10:00
|
|
|
struct BMesh *bm,
|
|
|
|
|
struct GSet *bm_faces,
|
|
|
|
|
struct GSet *bm_unique_verts,
|
|
|
|
|
struct GSet *bm_other_verts,
|
2022-06-08 12:30:01 -07:00
|
|
|
const int update_flags);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
|
* Threaded: do not call any functions that use OpenGL calls!
|
|
|
|
|
*/
|
2022-06-08 12:30:01 -07:00
|
|
|
void GPU_pbvh_grid_buffers_update(PBVHGPUFormat *vbo_id,
|
|
|
|
|
GPU_PBVH_Buffers *buffers,
|
2020-04-01 01:03:20 +02:00
|
|
|
struct SubdivCCG *subdiv_ccg,
|
2017-05-11 22:03:50 +10:00
|
|
|
struct CCGElem **grids,
|
|
|
|
|
const struct DMFlagMat *grid_flag_mats,
|
|
|
|
|
int *grid_indices,
|
|
|
|
|
int totgrid,
|
2020-04-01 01:03:20 +02:00
|
|
|
const int *sculpt_face_sets,
|
2022-01-07 11:38:08 +11:00
|
|
|
int face_sets_color_seed,
|
|
|
|
|
int face_sets_color_default,
|
2017-05-11 22:03:50 +10:00
|
|
|
const struct CCGKey *key,
|
2022-01-07 11:38:08 +11:00
|
|
|
int update_flags);
|
2012-02-22 22:48:34 +00:00
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
2022-06-08 12:30:01 -07:00
|
|
|
* Finish update. Not thread safe, must run in OpenGL main
|
|
|
|
|
* thread.
|
2021-12-09 20:01:47 +11:00
|
|
|
*/
|
2019-09-27 22:42:57 +02:00
|
|
|
void GPU_pbvh_buffers_update_flush(GPU_PBVH_Buffers *buffers);
|
|
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
|
* Free buffers. Not thread safe, must run in OpenGL main thread.
|
|
|
|
|
*/
|
2019-09-27 22:42:57 +02:00
|
|
|
void GPU_pbvh_buffers_free(GPU_PBVH_Buffers *buffers);
|
|
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/** Draw. */
|
2019-02-14 20:24:13 +01:00
|
|
|
struct GPUBatch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast, bool wires);
|
2012-02-22 22:48:34 +00:00
|
|
|
|
2019-05-04 00:46:26 +02:00
|
|
|
short GPU_pbvh_buffers_material_index_get(GPU_PBVH_Buffers *buffers);
|
2020-03-21 18:09:43 +01:00
|
|
|
bool GPU_pbvh_buffers_has_overlays(GPU_PBVH_Buffers *buffers);
|
2018-08-24 16:46:42 +02:00
|
|
|
|
2022-06-09 09:48:37 +10:00
|
|
|
PBVHGPUFormat *GPU_pbvh_make_format(void);
|
2022-06-08 12:30:01 -07:00
|
|
|
void GPU_pbvh_free_format(PBVHGPUFormat *vbo_id);
|
|
|
|
|
|
2020-03-02 15:28:47 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|