Mesh: Replace auto smooth with node group #108014

Merged
Hans Goudey merged 149 commits from HooglyBoogly/blender:refactor-mesh-corner-normals-lazy into main 2023-10-20 16:54:20 +02:00
27 changed files with 72 additions and 53 deletions
Showing only changes of commit a1fb62caca - Show all commits

View File

@ -423,7 +423,7 @@ ccl_device_inline float bsdf_aniso_lambda(float alpha_x, float alpha_y, float3 V
return bsdf_lambda_from_sqr_alpha_tan_n<m_type>(sqr_alpha_tan_n);
}
/* Monodirectional shadowing-masking term. */
/* Mono-directional shadowing-masking term. */
template<MicrofacetType m_type> ccl_device_inline float bsdf_G(float alpha2, float cos_N)
{
return 1.0f / (1.0f + bsdf_lambda<m_type>(alpha2, cos_N));

View File

@ -268,13 +268,13 @@ ccl_device_inline float3 sample_wh(
return wh;
}
/* Check micronormal/mesonormal direct visiblity from direction `v`. */
/* Check micronormal/mesonormal direct visibility from direction `v`. */
ccl_device_inline bool microfacet_visible(const float3 v, const float3 m, const float3 h)
{
return (dot(v, h) > 0.0f && dot(v, m) > 0.0f);
}
/* Check micronormal/mesonormal direct visiblity from directions `wi` and `wo`. */
/* Check micronormal/mesonormal direct visibility from directions `wi` and `wo`. */
ccl_device_inline bool microfacet_visible(const float3 wi,
const float3 wo,
const float3 m,
@ -502,7 +502,7 @@ ccl_device Spectrum bsdf_hair_huang_eval_residual(KernelGlobals kg,
const float rcp_norm_wh2 = 1.0f / len(wh2);
wh2 *= rcp_norm_wh2;
const float cos_mh2 = dot(wmt, wh2);
if (cos_mh2 >= 0.0f) { /* Microfacet visiblity from macronormal. */
if (cos_mh2 >= 0.0f) { /* Microfacet visibility from macronormal. */
const float cos_hi2 = dot(-wt, wh2);
const float cos_ho2 = dot(-wo, wh2);
const float cos_mo2 = dot(-wo, wmt);

View File

@ -93,7 +93,12 @@ const char *GHOST_SystemPathsCocoa::getUserSpecialDir(GHOST_TUserSpecialDirTypes
}
const NSString *const basePath = [paths objectAtIndex:0];
strncpy(tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding], sizeof(tempPath));
const char *basePath_cstr = [basePath cStringUsingEncoding:NSASCIIStringEncoding];
int basePath_len = strlen(basePath_cstr);
basePath_len = MIN(basePath_len, sizeof(tempPath) - 1);
memcpy(tempPath, basePath_cstr, basePath_len);
tempPath[basePath_len] = '\0';
}
return tempPath;
}
@ -109,7 +114,12 @@ const char *GHOST_SystemPathsCocoa::getBinaryDir() const
return nullptr;
}
strcpy(tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]);
const char *basePath_cstr = [basePath cStringUsingEncoding:NSASCIIStringEncoding];
int basePath_len = strlen(basePath_cstr);
basePath_len = MIN(basePath_len, sizeof(tempPath) - 1);
memcpy(tempPath, basePath_cstr, basePath_len);
tempPath[basePath_len] = '\0';
}
return tempPath;
}

View File

@ -253,8 +253,9 @@ class bNodeRuntime : NonCopyable, NonMovable {
bNode *original = nullptr;
/**
* XXX TODO
* Node totr size depends on the prvr size, which in turn is determined from preview size.
* XXX:
* TODO: `prvr` does not exist!
* Node totr size depends on the `prvr` size, which in turn is determined from preview size.
* In earlier versions bNodePreview was stored directly in nodes, but since now there can be
* multiple instances using different preview images it is possible that required node size
* varies between instances. preview_xsize, preview_ysize defines a common reserved size for

View File

@ -2069,7 +2069,7 @@ void BKE_movieclip_free_gputexture(MovieClip *clip)
MovieClip_RuntimeGPUTexture *tex = (MovieClip_RuntimeGPUTexture *)BLI_pophead(
&clip->runtime.gputextures);
for (int i = 0; i < TEXTARGET_COUNT; i++) {
/* free glsl image binding */
/* Free GLSL image binding. */
if (tex->gputexture[i]) {
GPU_texture_free(tex->gputexture[i]);
tex->gputexture[i] = nullptr;

View File

@ -1074,7 +1074,7 @@ static float blinn_specular(const float L[3],
return spec_light * (1.0 - w2) + spec_env * w2;
}
/* Keep in sync with the glsl shader function get_world_lighting() */
/* Keep in sync with the GLSL shader function `get_world_lighting()`. */
static void studiolight_lights_eval(StudioLight *sl, float color[3], const float normal[3])
{
float R[3], I[3] = {0.0f, 0.0f, 1.0f}, N[3] = {normal[0], normal[2], -normal[1]};

View File

@ -778,9 +778,9 @@ static void do_versions_291_fcurve_handles_limit(FCurve *fcu)
}
const float factor = time_delta / total_len;
/* Current keyframe's right handle: */
/* Current key-frame's right handle: */
madd_v2_v2v2fl(bezt->vec[2], v1, delta1, -factor); /* vec[2] = v1 - factor * delta1 */
/* Next keyframe's left handle: */
/* Next key-frame's left handle: */
madd_v2_v2v2fl(nextbezt->vec[0], v4, delta2, -factor); /* vec[0] = v4 - factor * delta2 */
}
}

View File

@ -82,7 +82,7 @@ void do_versions_after_linking_400(FileData *fd, Main *bmain)
}
}
/* XXX This was added many years ago (1c19940198) in 'lib_link` code of particles as a bugfix.
/* XXX This was added many years ago (1c19940198) in 'lib_link` code of particles as a bug-fix.
* But this is actually versioning. Should be safe enough here. */
LISTBASE_FOREACH (ParticleSettings *, part, &bmain->particles) {
if (!part->effector_weights) {

View File

@ -173,7 +173,7 @@ enum eObjectInfoFlag {
struct ObjectInfos {
#if defined(GPU_SHADER) && !defined(DRAW_FINALIZE_SHADER)
/* TODO Rename to struct member for glsl too. */
/* TODO Rename to struct member for GLSL too. */
float4 orco_mul_bias[2];
float4 ob_color;
float4 infos;

View File

@ -3530,13 +3530,11 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts)
else if (nu->pntsv == 1) {
BPoint *nextbp;
/*
* All flat lines (ie. co-planar), except flat Nurbs. Flat NURB curves
/* NOTE(@nzc): All flat lines (ie. co-planar), except flat Nurbs. Flat NURB curves
* are handled together with the regular NURB plane division, as it
* should be. I split it off just now, let's see if it is
* stable... nzc 30-5-'00
*/
/* count */
* should be. I split it off just now, let's see if it is stable. */
/* Count. */
a = nu->pntsu;
bp = nu->bp;
while (a--) {
@ -3596,7 +3594,7 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts)
else if (nu->type == CU_NURBS) {
/* This is a very strange test ... */
/**
* Subdivide NURB surfaces - nzc 30-5-'00 -
* NOTE(@nzc): Subdivide NURB surfaces
*
* Subdivision of a NURB curve can be effected by adding a
* control point (insertion of a knot), or by raising the

View File

@ -134,8 +134,10 @@ const ActKeyColumn *ED_keylist_find_any_between(const AnimKeylist *keylist,
bool ED_keylist_is_empty(const AnimKeylist *keylist);
const ListBase /* ActKeyColumn */ *ED_keylist_listbase(const AnimKeylist *keylist);
bool ED_keylist_all_keys_frame_range(const AnimKeylist *keylist, Range2f *r_frame_range);
/* Return the selected keyframe's range. If none are selected, return False and
* do not affect the frame range. */
/**
* Return the selected key-frame's range. If none are selected, return False and
* do not affect the frame range.
*/
bool ED_keylist_selected_keys_frame_range(const AnimKeylist *keylist, Range2f *r_frame_range);
const ActKeyColumn *ED_keylist_array(const AnimKeylist *keylist);
int64_t ED_keylist_array_len(const AnimKeylist *keylist);

View File

@ -115,7 +115,7 @@ struct ShaderPreview {
ID *parent;
MTex *slot;
/* datablocks with nodes need full copy during preview render, glsl uses it too */
/* Data-blocks with nodes need full copy during preview render, GLSL uses it too. */
Material *matcopy;
Tex *texcopy;
Light *lampcopy;

View File

@ -890,7 +890,7 @@ static AZone *area_actionzone_refresh_xy(ScrArea *area, const int xy[2], const b
}
}
else if (az->type == AZONE_REGION_SCROLL && az->region->visible) {
/* If the region is not visible we can ignore this scoller zone. */
/* If the region is not visible we can ignore this scroll-bar zone. */
ARegion *region = az->region;
View2D *v2d = &region->v2d;
int scroll_flag = 0;
@ -960,7 +960,7 @@ static AZone *area_actionzone_refresh_xy(ScrArea *area, const int xy[2], const b
ED_area_tag_redraw_no_rebuild(area);
}
else if (az->type == AZONE_REGION_SCROLL && az->region->visible) {
/* If the region is not visible we can ignore this scoller zone. */
/* If the region is not visible we can ignore this scroll-bar zone. */
if (az->direction == AZ_SCROLL_VERT) {
az->alpha = az->region->v2d.alpha_vert = 0;
area->flag &= ~AREA_FLAG_ACTIONZONES_UPDATE;

View File

@ -1710,8 +1710,8 @@ void node_link_bezier_points_evaluated(const bNodeLink &link,
#define LINK_WIDTH (2.5f * UI_SCALE_FAC)
#define ARROW_SIZE (7 * UI_SCALE_FAC)
/* Reroute arrow shape and mute bar. These are expanded here and shrunk in the glsl code.
* See: gpu_shader_2D_nodelink_vert.glsl */
/* Reroute arrow shape and mute bar. These are expanded here and shrunk in the GLSL code.
* See: `gpu_shader_2D_nodelink_vert.glsl`. */
static float arrow_verts[3][2] = {{-1.0f, 1.0f}, {0.0f, 0.0f}, {-1.0f, -1.0f}};
static float arrow_expand_axis[3][2] = {{0.7071f, 0.7071f}, {M_SQRT2, 0.0f}, {0.7071f, -0.7071f}};
static float mute_verts[3][2] = {{0.7071f, 1.0f}, {0.7071f, 0.0f}, {0.7071f, -1.0f}};

View File

@ -738,7 +738,7 @@ void ED_node_set_active(
ED_node_tree_propagate_change(nullptr, bmain, ntree);
if ((node->flag & NODE_ACTIVE_TEXTURE) && !was_active_texture) {
/* If active texture changed, free glsl materials. */
/* If active texture changed, free GLSL materials. */
LISTBASE_FOREACH (Material *, ma, &bmain->materials) {
if (ma->nodetree && ma->use_nodes && ntreeContainsTree(ma->nodetree, ntree)) {
GPU_material_free(&ma->gpumaterial);

View File

@ -454,8 +454,8 @@ static void connect_nodes_to_aovs(const Span<bNodeTreePath *> treepath,
bNodeSocket *socket_preview = nodesocket.second;
bNode *aov_node = nodeAddStaticNode(nullptr, main_nt, SH_NODE_OUTPUT_AOV);
strcpy(reinterpret_cast<NodeShaderOutputAOV *>(aov_node->storage)->name,
nodesocket.first->name);
STRNCPY(reinterpret_cast<NodeShaderOutputAOV *>(aov_node->storage)->name,
nodesocket.first->name);
if (socket_preview == nullptr) {
continue;
}
@ -600,11 +600,11 @@ static void preview_render(ShaderNodesPreviewJob &job_data)
for (NodeSocketPair nodesocket_iter : job_data.shader_nodes) {
ViewLayer *vl = BKE_view_layer_add(
scene, nodesocket_iter.first->name, AOV_layer, VIEWLAYER_ADD_COPY);
strcpy(vl->name, nodesocket_iter.first->name);
STRNCPY(vl->name, nodesocket_iter.first->name);
}
for (NodeSocketPair nodesocket_iter : job_data.AOV_nodes) {
ViewLayerAOV *aov = BKE_view_layer_add_aov(AOV_layer);
strcpy(aov->name, nodesocket_iter.first->name);
STRNCPY(aov->name, nodesocket_iter.first->name);
}
scene->r.xsch = job_data.tree_previews->preview_size;
scene->r.ysch = job_data.tree_previews->preview_size;

View File

@ -486,6 +486,13 @@ TransDataCurveHandleFlags *initTransDataCurveHandles(TransData *td, BezTriple *b
void clipUVData(TransInfo *t)
{
/* NOTE(@ideasman42): Often used to clip UV's after proportional editing:
* In this case the radius of the proportional region can end outside the clipping area,
* while not ideal an elegant solution here would likely be computationally expensive
* as it would need to calculate the transform value that would meet the UV bounds.
* While it would be technically correct to handle this properly,
* there isn't a strong use case for it. */
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (int a = 0; a < tc->data_len; a++, td++) {

View File

@ -275,8 +275,7 @@ static void applyResize(TransInfo *t)
ElementResize(t, tc, td, mat);
}
/* XXX(@dg): In proportional edit it can happen that vertices
* in the radius of the brush end outside the clipping area. */
/* Not ideal, see #clipUVData code-comment. */
if (t->flag & T_PROP_EDIT) {
clipUVData(t);
}

View File

@ -368,10 +368,7 @@ static void applyRotation(TransInfo *t)
applyRotationValue(t, t->values_final[0], axis_final, is_large_rotation);
}
/* In proportional edit it can happen that */
/* vertices in the radius of the brush end */
/* outside the clipping area */
/* XXX HACK - dg */
/* Not ideal, see #clipUVData code-comment. */
if (t->flag & T_PROP_EDIT) {
clipUVData(t);
}

View File

@ -294,10 +294,7 @@ static void apply_shear(TransInfo *t)
apply_shear_value(t, t->values_final[0]);
}
/* In proportional edit it can happen that */
/* vertices in the radius of the brush end */
/* outside the clipping area */
/* XXX HACK - dg */
/* Not ideal, see #clipUVData code-comment. */
if (t->flag & T_PROP_EDIT) {
clipUVData(t);
}

View File

@ -642,10 +642,7 @@ static void applyTranslation(TransInfo *t)
if (t->flag & T_CLIP_UV && clip_uv_transform_translation(t, global_dir)) {
applyTranslationValue(t, global_dir);
/* In proportional edit it can happen that */
/* vertices in the radius of the brush end */
/* outside the clipping area */
/* XXX HACK - dg */
/* Not ideal, see #clipUVData code-comment. */
if (t->flag & T_PROP_EDIT) {
clipUVData(t);
}

View File

@ -3854,7 +3854,7 @@ void uv_parametrizer_face_add(ParamHandle *phandle,
}
if (permute.size() != nverts) {
const int pm = int(permute.size());
/* Add the remaining pm-gon. */
/* Add the remaining `pm-gon` data. */
Array<ParamKey> vkeys_sub(pm);
Array<const float *> co_sub(pm);
Array<float *> uv_sub(pm);

View File

@ -129,7 +129,7 @@ struct TestOutput {
TestOutputRawData result;
/** TestStatus. */
uint status;
/** Line error in the glsl file. */
/** Line error in the GLSL file. */
int line;
/** TestType of expect and result. */
uint type;

View File

@ -76,7 +76,7 @@ class GeometryExporter : COLLADASW::LibraryGeometries {
std::string makeTexcoordSourceId(std::string &geom_id, int layer_index, bool is_single_layer);
/** Creates <source> for texcoords. */
/** Creates <source> for texture-coordinates. */
void createTexcoordsSource(std::string geom_id, Mesh *me);
/** Creates <source> for normals. */

View File

@ -40,7 +40,7 @@ typedef struct RegionView3D {
float persmat[4][4];
/** Inverse of persmat. */
float persinv[4][4];
/** Offset/scale for camera glsl texcoords. */
/** Offset/scale for camera GLSL texture-coordinates. */
float viewcamtexcofac[4];
/** viewmat/persmat multiplied with object matrix, while drawing and selection. */

View File

@ -122,8 +122,9 @@ typedef struct BPy_StructRNA {
#endif /* !USE_PYRNA_STRUCT_REFERENCE */
#ifdef PYRNA_FREE_SUPPORT
bool freeptr; /* needed in some cases if ptr.data is created on the fly, free when deallocing */
#endif /* PYRNA_FREE_SUPPORT */
/** Needed in some cases if ptr.data is created on the fly, free when deallocating. */
bool freeptr;
#endif /* PYRNA_FREE_SUPPORT */
} BPy_StructRNA;
typedef struct {

View File

@ -45,6 +45,7 @@ dict_custom = {
"anisotropic",
"anisotropy",
"atomicity",
"attenuations",
"bindless",
"bitwise",
"blocky",
@ -148,6 +149,7 @@ dict_custom = {
"imbricated",
"impactful",
"incrementation",
"inferencing",
"initializer",
"initializers",
"inlining",
@ -613,6 +615,14 @@ dict_custom = {
"lossless",
"lossy",
"luma",
"macronormal",
"macronormals",
"mesonormal",
"mesonormals",
"microfacet",
"microfacets",
"micronormal",
"micronormals",
"mipmap",
"mipmapped",
"mipmapping",