Changeset View
Standalone View
source/blender/depsgraph/intern/depsgraph_type.h
| Show All 33 Lines | |||||
| /* TODO(sergey): Ideally we'll just use char* and statically allocated strings | /* TODO(sergey): Ideally we'll just use char* and statically allocated strings | ||||
| * to avoid any possible overhead caused by string (re)allocation/formatting. */ | * to avoid any possible overhead caused by string (re)allocation/formatting. */ | ||||
| #include <string> | #include <string> | ||||
| #include <vector> | #include <vector> | ||||
| #include <algorithm> | #include <algorithm> | ||||
| struct Depsgraph; | struct Depsgraph; | ||||
| struct CustomData_MeshMasks; | |||||
| namespace DEG { | namespace DEG { | ||||
| /* Commonly used types. */ | /* Commonly used types. */ | ||||
| using std::string; | using std::string; | ||||
| using std::vector; | using std::vector; | ||||
| /* Commonly used functions. */ | /* Commonly used functions. */ | ||||
| using std::max; | using std::max; | ||||
| Show All 15 Lines | enum eUpdateSource { | ||||
| /* Update caused by user directly or indirectly influencing the node. */ | /* Update caused by user directly or indirectly influencing the node. */ | ||||
| DEG_UPDATE_SOURCE_USER_EDIT = (1 << 1), | DEG_UPDATE_SOURCE_USER_EDIT = (1 << 1), | ||||
| /* Update is happening as a special response for the relations update. */ | /* Update is happening as a special response for the relations update. */ | ||||
| DEG_UPDATE_SOURCE_RELATIONS = (1 << 2), | DEG_UPDATE_SOURCE_RELATIONS = (1 << 2), | ||||
| /* Update is happening due to visibility change. */ | /* Update is happening due to visibility change. */ | ||||
| DEG_UPDATE_SOURCE_VISIBILITY = (1 << 3), | DEG_UPDATE_SOURCE_VISIBILITY = (1 << 3), | ||||
| }; | }; | ||||
| /* C++ wrapper around DNA's CustomData_MeshMasks struct. */ | |||||
sergey: Probably ok for now. But maybe consider adding `depsgraph_customdata.h` and… | |||||
Done Inline ActionsNot sure what should go into depsgraph_customdata_impl.h… Wouldn’t we rather need a depsgraph_customdata.cc ? mont29: Not sure what should go into `depsgraph_customdata_impl.h`… Wouldn’t we rather need a… | |||||
| struct DEGCustomDataMeshMasks { | |||||
| uint64_t vert_mask; | |||||
| uint64_t edge_mask; | |||||
| uint64_t face_mask; | |||||
Done Inline ActionsDon't mix snake style with camel case. sergey: Don't mix snake style with camel case.
Types are to start with capital and be camel case. | |||||
| uint64_t loop_mask; | |||||
| uint64_t poly_mask; | |||||
| DEGCustomDataMeshMasks() : | |||||
| vert_mask(0), | |||||
Not Done Inline ActionsUse CustomData_MeshMasks. sergey: Use `CustomData_MeshMasks`. | |||||
Done Inline ActionsDon’t understand that one? That would make something like CustomData_MeshMasks masks;, and then would have to access the masks with customdata_masks.masks.vmask? Also implies that we include DNA_customdata_types.h here... Or did you mean 'Use CustomDataMask' (from BKE_customdata.h's typedef uint64_t CustomDataMask;)? mont29: Don’t understand that one? That would make something like `CustomData_MeshMasks masks;`, and… | |||||
| edge_mask(0), | |||||
Done Inline ActionsAdd default constructor, which initializes masks to 0. sergey: Add default constructor, which initializes masks to 0.
Also, probably worth adding constructor… | |||||
| face_mask(0), | |||||
| loop_mask(0), | |||||
| poly_mask(0) | |||||
| { | |||||
| } | |||||
| DEGCustomDataMeshMasks(const CustomData_MeshMasks *other); | |||||
sergeyUnsubmitted Done Inline ActionsMark as explicit. Also not sure why implementation of this specific constructor is in .cc file. sergey: Mark as `explicit`.
Also not sure why implementation of this specific constructor is in `.cc`… | |||||
mont29AuthorUnsubmitted Done Inline Actions
Yes, did not want to have to include DNA_customdata_types.h in that header mont29: > Also not sure why implementation of this specific constructor is in .cc file.
> Feels weird… | |||||
| DEGCustomDataMeshMasks& operator|=(const DEGCustomDataMeshMasks& other) | |||||
| { | |||||
| this->vert_mask |= other.vert_mask; | |||||
Done Inline Actionsa -> other. sergey: `a` -> `other`. | |||||
| this->edge_mask |= other.edge_mask; | |||||
| this->face_mask |= other.face_mask; | |||||
Done Inline ActionsI would do it as DEGCustomDataMeshMasks result; result.vert_mask = this.vert_mask | other.vert_mask; ... Might be looking more verbose, but is way less fragile. sergey: I would do it as
DEGCustomDataMeshMasks result;
result.vert_mask = this.vert_mask | other. | |||||
| this->loop_mask |= other.loop_mask; | |||||
| this->poly_mask |= other.poly_mask; | |||||
| return *this; | |||||
| } | |||||
| DEGCustomDataMeshMasks operator|(const DEGCustomDataMeshMasks& other) const | |||||
| { | |||||
| DEGCustomDataMeshMasks result; | |||||
Done Inline Actionsbool operator==(const DEG_CustomData_MeshMasks& other) const with all the equality and then sergey: `bool operator==(const DEG_CustomData_MeshMasks& other) const` with all the equality and then… | |||||
| result.vert_mask = this->vert_mask | other.vert_mask; | |||||
| result.edge_mask = this->edge_mask | other.edge_mask; | |||||
| result.face_mask = this->face_mask | other.face_mask; | |||||
| result.loop_mask = this->loop_mask | other.loop_mask; | |||||
| result.poly_mask = this->poly_mask | other.poly_mask; | |||||
| return result; | |||||
| } | |||||
| bool operator==(const DEGCustomDataMeshMasks& other) const | |||||
| { | |||||
| return (this->vert_mask == other.vert_mask && | |||||
Done Inline ActionsDEGCustomDataMeshMasks result; sergey: DEGCustomDataMeshMasks result;
result.vert_mask = vert_mask;
return result; | |||||
| this->edge_mask == other.edge_mask && | |||||
| this->face_mask == other.face_mask && | |||||
| this->loop_mask == other.loop_mask && | |||||
| this->poly_mask == other.poly_mask); | |||||
| } | |||||
| bool operator!=(const DEGCustomDataMeshMasks& other) const | |||||
| { | |||||
| return !(*this == other); | |||||
| } | |||||
| static DEGCustomDataMeshMasks MaskVert(const uint64_t vert_mask) | |||||
| { | |||||
| DEGCustomDataMeshMasks result; | |||||
| result.vert_mask = vert_mask; | |||||
| return result; | |||||
| } | |||||
| static DEGCustomDataMeshMasks MaskEdge(const uint64_t edge_mask) | |||||
| { | |||||
| DEGCustomDataMeshMasks result; | |||||
| result.edge_mask = edge_mask; | |||||
| return result; | |||||
| } | |||||
| static DEGCustomDataMeshMasks MaskFace(const uint64_t face_mask) | |||||
| { | |||||
| DEGCustomDataMeshMasks result; | |||||
| result.face_mask = face_mask; | |||||
| return result; | |||||
| } | |||||
| static DEGCustomDataMeshMasks MaskLoop(const uint64_t loop_mask) | |||||
| { | |||||
| DEGCustomDataMeshMasks result; | |||||
| result.loop_mask = loop_mask; | |||||
| return result; | |||||
| } | |||||
| static DEGCustomDataMeshMasks MaskPoly(const uint64_t poly_mask) | |||||
| { | |||||
| DEGCustomDataMeshMasks result; | |||||
| result.poly_mask = poly_mask; | |||||
| return result; | |||||
| } | |||||
| }; | |||||
| } // namespace DEG | } // namespace DEG | ||||
Probably ok for now. But maybe consider adding depsgraph_customdata.h and depsgraph_customdata_impl.h.