Cleanup: use C style comments for descriptive text, doxygen doc-strings

Also replace add-hoc groups in BKE_collision.h with doxy groups.
This commit is contained in:
Campbell Barton
2025-07-22 01:01:03 +00:00
parent f470a0bbd0
commit 996210999b
12 changed files with 94 additions and 66 deletions

View File

@@ -15,9 +15,11 @@ struct CollisionModifierData;
struct Depsgraph;
struct Object;
////////////////////////////////////////
// used for collisions in collision.cc
////////////////////////////////////////
/* -------------------------------------------------------------------- */
/** \name Collision Data Types
*
* Used for collisions in `collision.cc`.
* \{ */
/* COLLISION FLAGS */
typedef enum {
@@ -29,10 +31,6 @@ typedef enum {
COLLISION_INACTIVE = (1 << 4),
} COLLISION_FLAGS;
////////////////////////////////////////
// used for collisions in collision.cc
////////////////////////////////////////
/* used for collisions in collision.cc */
typedef struct CollPair {
unsigned int face1; /* cloth face */
unsigned int face2; /* object face */
@@ -56,7 +54,6 @@ typedef struct CollPair {
int pointsb[4];
} CollPair;
/* used for collisions in collision.cc */
typedef struct EdgeCollPair {
unsigned int p11, p12, p21, p22;
float normal[3];
@@ -66,7 +63,6 @@ typedef struct EdgeCollPair {
float pa[3], pb[3]; /* collision point p1 on face1, p2 on face2 */
} EdgeCollPair;
/* used for collisions in collision.cc */
typedef struct FaceCollPair {
unsigned int p11, p12, p13, p21;
float normal[3];
@@ -76,16 +72,15 @@ typedef struct FaceCollPair {
float pa[3], pb[3]; /* collision point p1 on face1, p2 on face2 */
} FaceCollPair;
////////////////////////////////////////
/** \} */
/////////////////////////////////////////////////
// forward declarations
/////////////////////////////////////////////////
/////////////////////////////////////////////////
// used in modifier.cc from collision.cc
/////////////////////////////////////////////////
/* Forward declarations. */
/* -------------------------------------------------------------------- */
/** \name BVH Tree Utilities
*
* Used in `modifier.cc` from `collision.cc`.
* \{ */
struct BVHTree *bvhtree_build_from_mvert(const float (*positions)[3],
const blender::int3 *vert_tris,
int tri_num,
@@ -96,8 +91,11 @@ void bvhtree_update_from_mvert(struct BVHTree *bvhtree,
const blender::int3 *vert_tris,
int tri_num,
bool moving);
/** \} */
/////////////////////////////////////////////////
/* -------------------------------------------------------------------- */
/** \name Collision Modifier Data
* \{ */
/**
* Move Collision modifier object inter-frame with step = [0,1]
@@ -114,7 +112,13 @@ void collision_get_collider_velocity(float vel_old[3],
struct CollisionModifierData *collmd,
struct CollPair *collpair);
/* Collision relations for dependency graph build. */
/** \} */
/* -------------------------------------------------------------------- */
/** \name Collision Relations
*
* Collision relations for dependency graph build.
* \{ */
typedef struct CollisionRelation {
struct CollisionRelation *next, *prev;
@@ -144,6 +148,12 @@ struct Object **BKE_collision_objects_create(struct Depsgraph *depsgraph,
unsigned int modifier_type);
void BKE_collision_objects_free(struct Object **objects);
/** \} */
/* -------------------------------------------------------------------- */
/** \name Collision Cache
* \{ */
typedef struct ColliderCache {
struct ColliderCache *next, *prev;
struct Object *ob;
@@ -159,6 +169,4 @@ struct ListBase *BKE_collider_cache_create(struct Depsgraph *depsgraph,
struct Collection *collection);
void BKE_collider_cache_free(struct ListBase **colliders);
/////////////////////////////////////////////////
/////////////////////////////////////////////////
/** \} */

View File

@@ -20,7 +20,7 @@ struct UniqueName_Map;
namespace blender::bke::library {
struct LibraryRuntime {
/* Used for efficient calculations of unique names. */
/** Used for efficient calculations of unique names. */
UniqueName_Map *name_map = nullptr;
/**

View File

@@ -25,31 +25,39 @@ typedef enum LightLinkingType {
LIGHT_LINKING_BLOCKER,
} LightLinkingType;
/* Free object's light_linking if it is not needed to hold any of collections. */
/**
* Free object's light_linking if it is not needed to hold any of collections.
*/
void BKE_light_linking_free_if_empty(struct Object *object);
/* Get a collection of the given light linking type of the given object. */
/**
* Get a collection of the given light linking type of the given object.
*/
struct Collection *BKE_light_linking_collection_get(const struct Object *object,
LightLinkingType link_type);
/* Create new collection and assign it as a light or shadow linking collection (denoted by the
/**
* Create new collection and assign it as a light or shadow linking collection (denoted by the
* link_type) of the given object.
*
* The collection is created outside of the view layer collections.
* If the object already has light linking collection set up it is unreferenced from the object.
*
* Returns the newly created collection. */
* \return the newly created collection.
*/
struct Collection *BKE_light_linking_collection_new(struct Main *bmain,
struct Object *object,
LightLinkingType link_type);
/* Assign given light or shadow linking collection (denoted by the link_type) to the given object.
/**
* Assign given light or shadow linking collection (denoted by the link_type) to the given object.
* Maintains user counters of the collection: old collection is decreased the user counter, the new
* one is increased after this call.
* The new_collection is allowed to be null pointer.
*
* The assign_only variant takes care of (re)assigning the collection and maintaining the user
* counter, but not the dependency graph tagging for update. */
* counter, but not the dependency graph tagging for update.
*/
void BKE_light_linking_collection_assign_only(struct Object *object,
struct Collection *new_collection,
LightLinkingType link_type);
@@ -58,9 +66,11 @@ void BKE_light_linking_collection_assign(struct Main *bmain,
struct Collection *new_collection,
LightLinkingType link_type);
/* Add receiver to the given light linking collection.
* The ID is expected to either be collection or an object. Passing other types of IDs has no
* effect */
/**
* Add receiver to the given light linking collection.
* The ID is expected to either be collection or an object.
* Passing other types of IDs has no effect.
*/
void BKE_light_linking_add_receiver_to_collection(struct Main *bmain,
struct Collection *collection,
struct ID *receiver,
@@ -78,7 +88,8 @@ void BKE_light_linking_add_receiver_to_collection_after(
const struct ID *after,
const eCollectionLightLinkingState link_state);
/* Remove the given ID from the light or shadow linking collection of the given object.
/**
* Remove the given ID from the light or shadow linking collection of the given object.
*
* The collection is expected to be either receiver_collection or blocker_collection from an
* emitter object.
@@ -86,28 +97,33 @@ void BKE_light_linking_add_receiver_to_collection_after(
* The ID is expected to either be collection or an object. If other ID type is passed to the
* function an error is reported and false is returned.
*
* Returns true if the ID was unlinked from the receiver collection, false otherwise. The unlinking
* \return true if the ID was unlinked from the receiver collection, false otherwise. The unlinking
* will be unsuccessful if, for example, the receiver collection is a linked data-block.
*
* The optional reports argument is used to provide human-readable details about why unlinking was
* not successful. If it is nullptr then the report is printed to the console. */
* not successful. If it is nullptr then the report is printed to the console.
*/
bool BKE_light_linking_unlink_id_from_collection(struct Main *bmain,
struct Collection *collection,
struct ID *id,
struct ReportList *reports);
/* Link receiver object to the given emitter.
/**
* Link receiver object to the given emitter.
*
* If the emitter already has light linking collection specified the object is added to that
* collection. Otherwise, first a new collection is created and assigned, and the receiver is added
* to it. */
* to it.
*/
void BKE_light_linking_link_receiver_to_emitter(struct Main *bmain,
struct Object *emitter,
struct Object *receiver,
LightLinkingType link_type,
eCollectionLightLinkingState link_state);
/* Select all objects which are linked to the given emitter via the given light link type. */
/**
* Select all objects which are linked to the given emitter via the given light link type.
*/
void BKE_light_linking_select_receivers_of_emitter(struct Scene *scene,
struct ViewLayer *view_layer,
struct Object *emitter,

View File

@@ -41,7 +41,7 @@ struct StructRNA;
struct IDCacheKey;
enum class ModifierTypeType {
/* Should not be used, only for None modifier type */
/** Should not be used, only for None modifier type. */
None,
/**
@@ -54,7 +54,7 @@ enum class ModifierTypeType {
/** Modifier adds geometry. */
Constructive,
/* Modifier can add and remove geometry. */
/** Modifier can add and remove geometry. */
Nonconstructive,
/**
@@ -249,7 +249,7 @@ struct ModifierTypeInfo {
Mesh *mesh,
blender::MutableSpan<blender::float3> positions);
/* Set deform matrix per vertex for crazy-space correction */
/** Set deform matrix per vertex for crazy-space correction. */
void (*deform_matrices_EM)(ModifierData *md,
const ModifierEvalContext *ctx,
const BMEditMesh *em,

View File

@@ -314,9 +314,11 @@ struct bNodePanelExtent {
class bNodePanelRuntime : NonCopyable, NonMovable {
public:
/* The vertical location of the panel in the tree, calculated while drawing the nodes and invalid
/**
* The vertical location of the panel in the tree, calculated while drawing the nodes and invalid
* if the node tree hasn't been drawn yet. In the node tree's "world space" (the same as
* #bNode::runtime::draw_bounds). */
* #bNode::runtime::draw_bounds).
*/
std::optional<float> header_center_y;
std::optional<bNodePanelExtent> content_extent;
/** Optional socket that is part of the panel header. */
@@ -402,7 +404,7 @@ class bNodeRuntime : NonCopyable, NonMovable {
int toposort_left_to_right_index = -1;
int toposort_right_to_left_index = -1;
/* Panel runtime state */
/** Panel runtime state. */
Array<bNodePanelRuntime> panels;
};

View File

@@ -32,9 +32,11 @@ struct PaintRuntime : NonCopyable, NonMovable {
blender::float3 average_stroke_accum = float3(0.0f, 0.0f, 0.0f);
int average_stroke_counter = 0;
/* How much brush should be rotated in the view plane, 0 means x points right, y points up.
/**
* How much brush should be rotated in the view plane, 0 means x points right, y points up.
* The convention is that the brush's _negative_ Y axis points in the tangent direction (of the
* mouse curve, Bezier curve, etc.) */
* mouse curve, Bezier curve, etc.)
*/
float brush_rotation = 0.0f;
float brush_rotation_sec = 0.0f;

View File

@@ -635,7 +635,7 @@ void VKFrameBuffer::rendering_ensure_render_pass(VKContext &context)
srgb_ && enabled_srgb_,
VKImageViewArrayed::DONT_CARE};
const VKImageView &image_view = color_texture.image_view_get(image_view_info);
// TODO: Use VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL for readonly attachments.
/* TODO: Use VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL for read-only attachments. */
VkImageLayout vk_image_layout = (attachment_state == GPU_ATTACHMENT_READ) ?
VK_IMAGE_LAYOUT_GENERAL :
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;

View File

@@ -157,7 +157,7 @@ void VKDiscardPool::destroy_discarded_resources(VKDevice &device, bool force)
vkDestroyRenderPass(device.vk_handle(), vk_render_pass, nullptr);
});
// TODO: Introduce reuse_old as the allocations can all be reused by resetting the pool.
/* TODO: Introduce reuse_old as the allocations can all be reused by resetting the pool. */
descriptor_pools_.remove_old(current_timeline, [&](VkDescriptorPool vk_descriptor_pool) {
vkResetDescriptorPool(device.vk_handle(), vk_descriptor_pool, 0);
vkDestroyDescriptorPool(device.vk_handle(), vk_descriptor_pool, nullptr);

View File

@@ -87,7 +87,7 @@ void LightData::init()
}
pxr::GfVec3f color(light->r, light->g, light->b);
data_[pxr::HdLightTokens->color] = color; // We multiply the Temperature by 1
data_[pxr::HdLightTokens->color] = color; /* We multiply the Temperature by 1. */
data_[pxr::HdLightTokens->enableColorTemperature] = (light->mode & LA_USE_TEMPERATURE) != 0;
data_[pxr::HdLightTokens->colorTemperature] = light->temperature;

View File

@@ -425,15 +425,15 @@ static void ExpandAttributePerInstance(const GetterFunc &getter,
const std::vector<std::pair<int, int>> &instance_object_map,
const pxr::UsdTimeCode &time)
{
// MARK: Handle Collection Prototypes
// -----------------------------------------------------------------------------
// In Blender, a Collection is not an actual Object type. When exporting, the iterator
// flattens the Collection hierarchy, treating each object inside the Collection as an
// individual prototype. However, all these prototypes share the same instance attributes
// (e.g., positions, orientations, scales).
//
// To ensure correct arrangement, reading, and drawing in OpenUSD, we need to explicitly
// duplicate the instance attributes across all prototypes derived from the Collection.
/* MARK: Handle Collection Prototypes
* ----------------------------------
* In Blender, a Collection is not an actual Object type. When exporting, the iterator
* flattens the Collection hierarchy, treating each object inside the Collection as an
* individual prototype. However, all these prototypes share the same instance attributes
* (e.g., positions, orientations, scales).
*
* To ensure correct arrangement, reading, and drawing in OpenUSD, we need to explicitly
* duplicate the instance attributes across all prototypes derived from the Collection. */
pxr::VtArray<T> original_values;
if (!getter().Get(&original_values, time) || original_values.empty()) {
return;
@@ -542,11 +542,11 @@ void USDPointInstancerWriter::handle_collection_prototypes(
}
}
// MARK: Ensure Instance Indices Exist
// -----------------------------------------------------------------------------
// If the PointInstancer has no authored instance indices, manually generate a default
// sequence of indices to ensure the PointInstancer functions correctly in OpenUSD.
// This guarantees that each instance can correctly reference its prototype.
/* MARK: Ensure Instance Indices Exist
* -----------------------------------
* If the PointInstancer has no authored instance indices, manually generate a default
* sequence of indices to ensure the PointInstancer functions correctly in OpenUSD.
* This guarantees that each instance can correctly reference its prototype. */
pxr::UsdAttribute proto_indices_attr = usd_instancer.GetProtoIndicesAttr();
if (!proto_indices_attr.HasAuthoredValue()) {
std::vector<int> index;

View File

@@ -214,8 +214,8 @@ std::optional<std::string> USDVolumeWriter::construct_vdb_relative_file_path(
}
/* Following code was written with an assumption that Blender's relative paths start with
* // characters as well as have OS dependent slashes. Inside of USD files those relative
* paths should start with either ./ or ../ characters and have always forward slashes (/)
* `//` characters as well as have OS dependent slashes. Inside of USD files those relative
* paths should start with either `./` or `../` characters and have always forward slashes (`/`)
* separating directories. This is the convention used in USD documentation (and it seems
* to be used in other DCC packages as well). */
std::string relative_path_processed = pxr::TfNormPath(relative_path + 2);

View File

@@ -23,7 +23,7 @@
#include "MEM_guardedalloc.h"
#include "zbuf.h" // for rasterizer
#include "zbuf.h" /* For rasterizer (#ZSpan and associated functions). */
#include "RE_texture_margin.h"