diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-03-05 20:49:47 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-03-05 21:05:24 +0300 |
commit | e290a0b0568ecfcf47aa55b059de468b2c651e19 (patch) | |
tree | f0351e84edcf595f6bf61a77c4fb21384559f32b /intern/cycles/render/attribute.cpp | |
parent | 25c935e65fd901f42d2f26fede91749ee39b29f9 (diff) |
Cleanup: add asserts to catch cases where wrong attribute type is used.
Diffstat (limited to 'intern/cycles/render/attribute.cpp')
-rw-r--r-- | intern/cycles/render/attribute.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/intern/cycles/render/attribute.cpp b/intern/cycles/render/attribute.cpp index 70f75a4b573..0ce30b3bca6 100644 --- a/intern/cycles/render/attribute.cpp +++ b/intern/cycles/render/attribute.cpp @@ -69,6 +69,8 @@ void Attribute::resize(size_t num_elements) void Attribute::add(const float& f) { + assert(data_sizeof() == sizeof(float)); + char *data = (char*)&f; size_t size = sizeof(f); @@ -78,6 +80,19 @@ void Attribute::add(const float& f) void Attribute::add(const uchar4& f) { + assert(data_sizeof() == sizeof(uchar4)); + + char *data = (char*)&f; + size_t size = sizeof(f); + + for(size_t i = 0; i < size; i++) + buffer.push_back(data[i]); +} + +void Attribute::add(const float2& f) +{ + assert(data_sizeof() == sizeof(float2)); + char *data = (char*)&f; size_t size = sizeof(f); @@ -87,6 +102,8 @@ void Attribute::add(const uchar4& f) void Attribute::add(const float3& f) { + assert(data_sizeof() == sizeof(float3)); + char *data = (char*)&f; size_t size = sizeof(f); @@ -96,6 +113,8 @@ void Attribute::add(const float3& f) void Attribute::add(const Transform& f) { + assert(data_sizeof() == sizeof(Transform)); + char *data = (char*)&f; size_t size = sizeof(f); @@ -105,6 +124,8 @@ void Attribute::add(const Transform& f) void Attribute::add(const VoxelAttribute& f) { + assert(data_sizeof() == sizeof(VoxelAttribute)); + char *data = (char*)&f; size_t size = sizeof(f); @@ -128,6 +149,8 @@ size_t Attribute::data_sizeof() const return sizeof(uchar4); else if(type == TypeDesc::TypeFloat) return sizeof(float); + else if(type == TypeFloat2) + return sizeof(float2); else if(type == TypeDesc::TypeMatrix) return sizeof(Transform); else |