update color at picking and cleanup code from some warnings
This commit is contained in:
38
src/util.cpp
38
src/util.cpp
@@ -369,8 +369,8 @@ std::vector<vertex_t> triangulate(const std::vector<vertex_t>& points)
|
||||
while (node)
|
||||
{
|
||||
if (outline.empty() || // if empty insert right away
|
||||
outline.back() != node->a && // insert only if different than the last post
|
||||
(outline.front() != node->a || !node->end)) // if is the end check against the first one
|
||||
(outline.back() != node->a && // insert only if different than the last post
|
||||
(outline.front() != node->a || !node->end))) // if is the end check against the first one
|
||||
{
|
||||
outline.push_back(node->a);
|
||||
}
|
||||
@@ -438,8 +438,8 @@ glm::vec3 convert_rgb2hsv(const glm::vec3 c)
|
||||
std::vector<std::string> split(const std::string& subject, char d, int max_split/* = 0*/)
|
||||
{
|
||||
std::vector<std::string> ret;
|
||||
int start = 0;
|
||||
int n = subject.find_first_of(d);
|
||||
size_t start = 0;
|
||||
size_t n = subject.find_first_of(d);
|
||||
while (n != std::string::npos)
|
||||
{
|
||||
ret.push_back(subject.substr(start, n - start));
|
||||
@@ -499,10 +499,10 @@ std::string wstr2str(const std::wstring & wstr)
|
||||
|
||||
bool str_iequals(const std::string& a, const std::string& b)
|
||||
{
|
||||
unsigned int sz = a.size();
|
||||
size_t sz = a.size();
|
||||
if (b.size() != sz)
|
||||
return false;
|
||||
for (unsigned int i = 0; i < sz; ++i)
|
||||
for (size_t i = 0; i < sz; ++i)
|
||||
if (std::tolower(a[i]) != std::tolower(b[i]))
|
||||
return false;
|
||||
return true;
|
||||
@@ -586,25 +586,25 @@ size_t curl_data_write(void *ptr, size_t size, size_t nmemb, FILE *stream)
|
||||
/// @param use_threads : enable / disable threads.
|
||||
///
|
||||
///
|
||||
void parallel_for(unsigned nb_elements, std::function<void(int i)> functor, bool use_threads)
|
||||
void parallel_for(size_t nb_elements, std::function<void(size_t i)> functor, bool use_threads)
|
||||
{
|
||||
// -------
|
||||
unsigned nb_threads_hint = std::thread::hardware_concurrency();
|
||||
unsigned nb_threads = nb_threads_hint == 0 ? 8 : (nb_threads_hint);
|
||||
size_t nb_threads_hint = std::thread::hardware_concurrency();
|
||||
size_t nb_threads = nb_threads_hint == 0 ? 8 : (nb_threads_hint);
|
||||
|
||||
unsigned batch_size = nb_elements / nb_threads;
|
||||
unsigned batch_remainder = nb_elements % nb_threads;
|
||||
size_t batch_size = nb_elements / nb_threads;
|
||||
size_t batch_remainder = nb_elements % nb_threads;
|
||||
|
||||
std::vector< std::thread > my_threads(nb_threads);
|
||||
|
||||
if (use_threads)
|
||||
{
|
||||
// Multithread execution
|
||||
for (unsigned i = 0; i < nb_threads; ++i)
|
||||
for (size_t i = 0; i < nb_threads; ++i)
|
||||
{
|
||||
int start = i * batch_size;
|
||||
size_t start = i * batch_size;
|
||||
my_threads[i] = std::thread([functor, start, batch_size]() {
|
||||
for (int j = start; j < start + batch_size; j++)
|
||||
for (size_t j = start; j < start + batch_size; j++)
|
||||
functor(j);
|
||||
});
|
||||
}
|
||||
@@ -612,16 +612,16 @@ void parallel_for(unsigned nb_elements, std::function<void(int i)> functor, bool
|
||||
else
|
||||
{
|
||||
// Single thread execution (for easy debugging)
|
||||
for (unsigned i = 0; i < nb_threads; ++i) {
|
||||
int start = i * batch_size;
|
||||
for (int j = start; j < start + batch_size; j++)
|
||||
for (size_t i = 0; i < nb_threads; ++i) {
|
||||
size_t start = i * batch_size;
|
||||
for (size_t j = start; j < start + batch_size; j++)
|
||||
functor(j);
|
||||
}
|
||||
}
|
||||
|
||||
// Deform the elements left
|
||||
int start = nb_threads * batch_size;
|
||||
for (int j = start; j < start + batch_remainder; j++)
|
||||
size_t start = nb_threads * batch_size;
|
||||
for (size_t j = start; j < start + batch_remainder; j++)
|
||||
functor(j);
|
||||
|
||||
// Wait for the other thread to finish their task
|
||||
|
||||
Reference in New Issue
Block a user