[Bf-blender-cvs] [0bf70bde169] functions: rename try_get_T to try_get<T>
Jacques Lucke
noreply at git.blender.org
Mon Jul 29 17:57:53 CEST 2019
Commit: 0bf70bde169bda3512856d1f5615ae01c9f829ba
Author: Jacques Lucke
Date: Mon Jul 29 17:07:03 2019 +0200
Branches: functions
https://developer.blender.org/rB0bf70bde169bda3512856d1f5615ae01c9f829ba
rename try_get_T to try_get<T>
===================================================================
M source/blender/simulations/bparticles/actions.cpp
M source/blender/simulations/bparticles/attributes.hpp
===================================================================
diff --git a/source/blender/simulations/bparticles/actions.cpp b/source/blender/simulations/bparticles/actions.cpp
index 26daafb00f2..f16bf71be22 100644
--- a/source/blender/simulations/bparticles/actions.cpp
+++ b/source/blender/simulations/bparticles/actions.cpp
@@ -12,8 +12,8 @@ void ChangeDirectionAction::execute(ActionInterface &interface)
{
ParticleSet particles = interface.particles();
auto velocities = particles.attributes().get<float3>("Velocity");
- auto position_offsets = interface.attribute_offsets().try_get_float3("Position");
- auto velocity_offsets = interface.attribute_offsets().try_get_float3("Velocity");
+ auto position_offsets = interface.attribute_offsets().try_get<float3>("Position");
+ auto velocity_offsets = interface.attribute_offsets().try_get<float3>("Velocity");
auto inputs = m_compute_inputs->compute(interface);
diff --git a/source/blender/simulations/bparticles/attributes.hpp b/source/blender/simulations/bparticles/attributes.hpp
index 97f53e5e80d..7f8c51b1513 100644
--- a/source/blender/simulations/bparticles/attributes.hpp
+++ b/source/blender/simulations/bparticles/attributes.hpp
@@ -425,10 +425,16 @@ class AttributeArrays {
* Get access to the arrays.
* Does not assert when the attribute does not exist.
*/
- Optional<ArrayRef<uint8_t>> try_get_byte(StringRef name);
- Optional<ArrayRef<int32_t>> try_get_integer(StringRef name);
- Optional<ArrayRef<float>> try_get_float(StringRef name);
- Optional<ArrayRef<float3>> try_get_float3(StringRef name);
+ template<typename T> Optional<ArrayRef<T>> try_get(StringRef name)
+ {
+ int index = this->info().attribute_index_try(name, attribute_type_by_type<T>::value);
+ if (index == -1) {
+ return {};
+ }
+ else {
+ return this->get<T>((uint)index);
+ }
+ }
/**
* Get a continuous slice of the attribute arrays.
@@ -559,50 +565,6 @@ inline void AttributeArrays::init_default(StringRef name)
this->init_default(this->attribute_index(name));
}
-inline Optional<ArrayRef<uint8_t>> AttributeArrays::try_get_byte(StringRef name)
-{
- int index = this->info().attribute_index_try(name, AttributeType::Byte);
- if (index == -1) {
- return {};
- }
- else {
- return this->get<uint8_t>((uint)index);
- }
-}
-
-inline Optional<ArrayRef<int32_t>> AttributeArrays::try_get_integer(StringRef name)
-{
- int index = this->info().attribute_index_try(name, AttributeType::Integer);
- if (index == -1) {
- return {};
- }
- else {
- return this->get<int32_t>((uint)index);
- }
-}
-
-inline Optional<ArrayRef<float>> AttributeArrays::try_get_float(StringRef name)
-{
- int index = this->info().attribute_index_try(name, AttributeType::Float);
- if (index == -1) {
- return {};
- }
- else {
- return this->get<float>((uint)index);
- }
-}
-
-inline Optional<ArrayRef<float3>> AttributeArrays::try_get_float3(StringRef name)
-{
- int index = this->info().attribute_index_try(name, AttributeType::Float3);
- if (index == -1) {
- return {};
- }
- else {
- return this->get<float3>((uint)index);
- }
-}
-
inline AttributeArrays AttributeArrays::slice(uint start, uint size) const
{
return AttributeArrays(m_core, m_start + start, size);
More information about the Bf-blender-cvs
mailing list