Skip to content

Commit 5c8554b

Browse files
committed
Merge pull request #109 from AlexeySmolenchuk/MSVC_friendly
* AlexeySmolenchuk/MSVC_friendly: add "Cd" channel fix opacity by swapping logic check by sorted indices (order not guarantied for different platforms) widnows friendly build
2 parents d567c52 + 7f0bb37 commit 5c8554b

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

src/lib/core/KdTree.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
3434
*/
3535
#ifndef KdTree_h
3636
#define KdTree_h
37-
#if defined(__clang__) && defined(_LIBCPP_VERSION)
37+
#if defined(__clang__) && defined(_LIBCPP_VERSION) || defined(_MSC_VER)
3838
#include <numeric>
3939
#elif defined(__GNUC__)
4040
#include <ext/numeric>
@@ -290,7 +290,7 @@ void KdTree<k>::setPoints(const float* p, int n)
290290

291291
// assign sequential ids
292292
_ids.resize(n);
293-
#if defined(__clang__) && defined(_LIBCPP_VERSION)
293+
#if defined(__clang__) && defined(_LIBCPP_VERSION) || defined(_MSC_VER)
294294
std::iota(_ids.begin(), _ids.end(), 0);
295295
#elif defined(__GNUC__)
296296
__gnu_cxx::iota(_ids.begin(), _ids.end(), 0);

src/tests/testcache.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ int main(int argc,char* argv[])
4343
p->addParticle();
4444
float* pos=p->dataWrite<float>(attr,0);
4545
pos[0]=1;pos[1]=2;pos[2]=3;
46-
Partio::write("/tmp/test.bgeo",*p);
46+
Partio::write("test.bgeo",*p);
4747
p->release();
4848

49-
Partio::ParticlesInfo* p1=Partio::readCached("/tmp/test.bgeo",false);
50-
Partio::ParticlesInfo* p2=Partio::readCached("/tmp/test.bgeo",false);
49+
Partio::ParticlesInfo* p1=Partio::readCached("test.bgeo",false);
50+
Partio::ParticlesInfo* p2=Partio::readCached("test.bgeo",false);
5151
assert(p1==p2);
5252
p1->release();p2->release();
53-
Partio::ParticlesInfo* p3=Partio::readCached("/tmp/test.bgeo",false);
53+
Partio::ParticlesInfo* p3=Partio::readCached("test.bgeo",false);
5454
p3->release();
5555
//assert(p2!=p3);
5656

src/tests/testkdtree.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
3838
#include <iostream>
3939
#include <cmath>
4040
#include <stdexcept>
41+
#include <algorithm>
4142
#define GRIDN 9
4243

4344

@@ -86,17 +87,19 @@ int main(int argc,char *argv[])
8687

8788
foo->findNPoints(point, 5, 0.15f, indices, dists);
8889
TESTASSERT (indices.size() == 5);
89-
90+
91+
std::sort(indices.begin(), indices.end());
92+
9093
const float *pos = foo->data<float>(posAttr, indices[0]);
9194
TESTASSERT (pos[0] == 0.375f && pos[1] == 0.5 && pos[2] == 0.5);
9295
pos = foo->data<float>(posAttr, indices[1]);
93-
TESTASSERT (pos[0] == 0.625 && pos[1] == 0.5 && pos[2] == 0.5);
96+
TESTASSERT (pos[0] == 0.5 && pos[1] == 0.5 && pos[2] == 0.5);
9497
pos = foo->data<float>(posAttr, indices[2]);
9598
TESTASSERT (pos[0] == 0.5 && pos[1] == 0.5 && pos[2] == 0.625);
9699
pos = foo->data<float>(posAttr, indices[3]);
97100
TESTASSERT (pos[0] == 0.5 && pos[1] == 0.625 && pos[2] == 0.5);
98101
pos = foo->data<float>(posAttr, indices[4]);
99-
TESTASSERT (pos[0] == 0.5 && pos[1] == 0.5 && pos[2] == 0.5);
102+
TESTASSERT (pos[0] == 0.625 && pos[1] == 0.5 && pos[2] == 0.5);
100103

101104
std::cout << "Test passed\n";
102105
}
@@ -109,17 +112,19 @@ int main(int argc,char *argv[])
109112
float finalDist;
110113
int returned=foo->findNPoints(point, 5, 0.15f, indices, dists,&finalDist);
111114
TESTASSERT(returned == 5);
112-
115+
116+
std::sort(indices, indices + returned);
117+
113118
const float *pos = foo->data<float>(posAttr, indices[0]);
114119
TESTASSERT (pos[0] == 0.375f && pos[1] == 0.5 && pos[2] == 0.5);
115120
pos = foo->data<float>(posAttr, indices[1]);
116-
TESTASSERT (pos[0] == 0.625 && pos[1] == 0.5 && pos[2] == 0.5);
121+
TESTASSERT (pos[0] == 0.5 && pos[1] == 0.5 && pos[2] == 0.5);
117122
pos = foo->data<float>(posAttr, indices[2]);
118123
TESTASSERT (pos[0] == 0.5 && pos[1] == 0.5 && pos[2] == 0.625);
119124
pos = foo->data<float>(posAttr, indices[3]);
120125
TESTASSERT (pos[0] == 0.5 && pos[1] == 0.625 && pos[2] == 0.5);
121126
pos = foo->data<float>(posAttr, indices[4]);
122-
TESTASSERT (pos[0] == 0.5 && pos[1] == 0.5 && pos[2] == 0.5);
127+
TESTASSERT (pos[0] == 0.625 && pos[1] == 0.5 && pos[2] == 0.5);
123128

124129
std::cout << "Test passed\n";
125130
}

src/tools/partview.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static void drawParticles()
9999
//cout << "not inited" << endl;
100100
inited=true;
101101
colorMissing = true;
102-
colorMissing = true;
102+
alphaMissing = true;
103103

104104

105105
glEnable(GL_DEPTH_TEST);
@@ -139,7 +139,8 @@ static void drawParticles()
139139
if (particles->attributeInfo("pointColor", colorAttr) ||
140140
particles->attributeInfo("color", colorAttr) ||
141141
particles->attributeInfo("rgb", colorAttr) ||
142-
particles->attributeInfo("rgbPP", colorAttr))
142+
particles->attributeInfo("rgbPP", colorAttr) ||
143+
particles->attributeInfo("Cd", colorAttr))
143144
{
144145
//std::cerr<<"Found color attribute "<<std::endl;
145146
colorMissing = false;
@@ -152,7 +153,6 @@ static void drawParticles()
152153
particles->attributeInfo("opacityPP", alphaAttr) ||
153154
particles->attributeInfo("opacity", alphaAttr))
154155
{
155-
//std::cerr<<"Found alpha attribute "<<std::endl;
156156
glEnable(GL_BLEND);
157157
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
158158
alphaMissing = false;

0 commit comments

Comments
 (0)