[Bf-blender-cvs] [ef53859d24a] master: Cleanup: Make ChunkOrderHotspot a struct
Jeroen Bakker
noreply at git.blender.org
Wed Feb 17 15:25:29 CET 2021
Commit: ef53859d24a9720882e3ca6c5415faefec6fb82c
Author: Jeroen Bakker
Date: Wed Feb 17 15:00:04 2021 +0100
Branches: master
https://developer.blender.org/rBef53859d24a9720882e3ca6c5415faefec6fb82c
Cleanup: Make ChunkOrderHotspot a struct
===================================================================
M source/blender/compositor/intern/COM_ChunkOrder.cpp
M source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp
M source/blender/compositor/intern/COM_ChunkOrderHotspot.h
===================================================================
diff --git a/source/blender/compositor/intern/COM_ChunkOrder.cpp b/source/blender/compositor/intern/COM_ChunkOrder.cpp
index 91437aff9e0..3baa50da487 100644
--- a/source/blender/compositor/intern/COM_ChunkOrder.cpp
+++ b/source/blender/compositor/intern/COM_ChunkOrder.cpp
@@ -29,13 +29,12 @@ ChunkOrder::ChunkOrder()
void ChunkOrder::update_distance(ChunkOrderHotspot **hotspots, unsigned int len_hotspots)
{
- unsigned int index;
double new_distance = FLT_MAX;
- for (index = 0; index < len_hotspots; index++) {
+ for (int index = 0; index < len_hotspots; index++) {
ChunkOrderHotspot *hotspot = hotspots[index];
- double ndistance = hotspot->determineDistance(x, y);
- if (ndistance < new_distance) {
- new_distance = ndistance;
+ double distance_to_hotspot = hotspot->calc_distance(x, y);
+ if (distance_to_hotspot < new_distance) {
+ new_distance = distance_to_hotspot;
}
}
this->distance = new_distance;
diff --git a/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp b/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp
index b111fba44b7..bbc98d086a6 100644
--- a/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp
+++ b/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp
@@ -21,16 +21,16 @@
ChunkOrderHotspot::ChunkOrderHotspot(int x, int y, float addition)
{
- this->m_x = x;
- this->m_y = y;
- this->m_addition = addition;
+ x = x;
+ y = y;
+ addition = addition;
}
-double ChunkOrderHotspot::determineDistance(int x, int y)
+double ChunkOrderHotspot::calc_distance(int x, int y)
{
- int dx = x - this->m_x;
- int dy = y - this->m_y;
+ int dx = x - x;
+ int dy = y - y;
double result = sqrt((double)(dx * dx + dy * dy));
- result += (double)this->m_addition;
+ result += (double)addition;
return result;
}
diff --git a/source/blender/compositor/intern/COM_ChunkOrderHotspot.h b/source/blender/compositor/intern/COM_ChunkOrderHotspot.h
index afacf5fc672..af0cf897673 100644
--- a/source/blender/compositor/intern/COM_ChunkOrderHotspot.h
+++ b/source/blender/compositor/intern/COM_ChunkOrderHotspot.h
@@ -22,15 +22,15 @@
# include "MEM_guardedalloc.h"
#endif
-class ChunkOrderHotspot {
- private:
- int m_x;
- int m_y;
- float m_addition;
+struct ChunkOrderHotspot {
+ int x;
+ int y;
+ float addition;
public:
ChunkOrderHotspot(int x, int y, float addition);
- double determineDistance(int x, int y);
+
+ double calc_distance(int x, int y);
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("COM:ChunkOrderHotspot")
More information about the Bf-blender-cvs
mailing list