Skip to content

Commit 74eca36

Browse files
authored
Core small changes (#7952)
1 parent 3498bfd commit 74eca36

11 files changed

Lines changed: 138 additions & 114 deletions

File tree

addons/ofxKinect/src/ofxKinect.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
3131
==============================================================================*/
3232
#include "ofxKinect.h"
33-
#include "ofMain.h"
3433

3534
#include "libfreenect_registration.h"
3635
#include "freenect_internal.h" // for access to freenect_device.registration.zero_plane_info

addons/ofxOpenCv/src/ofxCvContourFinder.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
11

22
#include "ofxCvContourFinder.h"
33

4-
5-
64
//--------------------------------------------------------------------------------
75
static bool sort_carea_compare( const CvSeq* a, const CvSeq* b) {
8-
96
// use opencv to calc size, then sort based on size
107
float areaa = cvContourArea(a, CV_WHOLE_SEQ);
118
float areab = cvContourArea(b, CV_WHOLE_SEQ);
12-
139
return (areaa > areab);
1410
}
1511

16-
17-
18-
1912
//--------------------------------------------------------------------------------
2013
ofxCvContourFinder::ofxCvContourFinder() {
2114
_width = 0;
@@ -218,7 +211,7 @@ void ofxCvContourFinder::setAnchorPercent( float xPct, float yPct ){
218211
}
219212

220213
//--------------------------------------------------------------------------------
221-
void ofxCvContourFinder::setAnchorPoint( int x, int y ){
214+
void ofxCvContourFinder::setAnchorPoint( float x, float y ){
222215
anchor.x = x;
223216
anchor.y = y;
224217
bAnchorIsPct = false;

addons/ofxOpenCv/src/ofxCvContourFinder.h

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,52 +16,51 @@
1616
#include <algorithm>
1717

1818
class ofxCvContourFinder : public ofBaseDraws {
19+
public:
1920

20-
public:
21-
22-
std::vector<ofxCvBlob> blobs;
23-
int nBlobs; // DEPRECATED: use blobs.size() instead
24-
21+
std::vector<ofxCvBlob> blobs;
22+
int nBlobs; // DEPRECATED: use blobs.size() instead
23+
2524

26-
ofxCvContourFinder();
27-
virtual ~ofxCvContourFinder();
28-
25+
ofxCvContourFinder();
26+
virtual ~ofxCvContourFinder();
27+
2928
virtual float getWidth() const { return _width; }; //set after first findContours call
3029
virtual float getHeight() const { return _height; }; //set after first findContours call
31-
32-
virtual int findContours( ofxCvGrayscaleImage& input,
33-
int minArea, int maxArea,
34-
int nConsidered, bool bFindHoles,
35-
bool bUseApproximation = true);
36-
// approximation = don't do points for all points
37-
// of the contour, if the contour runs
38-
// along a straight line, for example...
30+
31+
virtual int findContours( ofxCvGrayscaleImage& input,
32+
int minArea, int maxArea,
33+
int nConsidered, bool bFindHoles,
34+
bool bUseApproximation = true);
35+
// approximation = don't do points for all points
36+
// of the contour, if the contour runs
37+
// along a straight line, for example...
3938

40-
virtual void draw() const { draw(0,0, _width, _height); };
41-
virtual void draw( float x, float y ) const { draw(x,y, _width, _height); };
42-
virtual void draw( float x, float y, float w, float h ) const;
43-
virtual void draw(const glm::vec2 & point) const;
44-
virtual void draw(const ofRectangle & rect) const;
39+
virtual void draw() const { draw(0,0, _width, _height); };
40+
virtual void draw( float x, float y ) const { draw(x,y, _width, _height); };
41+
virtual void draw( float x, float y, float w, float h ) const;
42+
virtual void draw(const glm::vec2 & point) const;
43+
virtual void draw(const ofRectangle & rect) const;
4544
virtual void setAnchorPercent(float xPct, float yPct);
46-
virtual void setAnchorPoint(int x, int y);
45+
virtual void setAnchorPoint(float x, float y);
4746
virtual void resetAnchor();
48-
//virtual ofxCvBlob getBlob(int num);
47+
//virtual ofxCvBlob getBlob(int num);
4948

5049

5150

52-
protected:
51+
protected:
5352

54-
int _width;
55-
int _height;
56-
ofxCvGrayscaleImage inputCopy;
57-
CvMemStorage* contour_storage;
58-
CvMemStorage* storage;
59-
CvMoments* myMoments;
60-
std::vector<CvSeq*> cvSeqBlobs; //these will become blobs
61-
62-
ofPoint anchor;
63-
bool bAnchorIsPct;
53+
int _width;
54+
int _height;
55+
ofxCvGrayscaleImage inputCopy;
56+
CvMemStorage* contour_storage;
57+
CvMemStorage* storage;
58+
CvMoments* myMoments;
59+
std::vector<CvSeq*> cvSeqBlobs; //these will become blobs
60+
61+
ofPoint anchor;
62+
bool bAnchorIsPct;
6463

65-
virtual void reset();
64+
virtual void reset();
6665

6766
};

libs/openFrameworks/3d/ofEasyCam.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#pragma once
22

33
#include "ofCamera.h"
4-
#include "ofEvents.h"
5-
#include "ofRectangle.h"
4+
//#include "ofEvents.h"
5+
class ofEventListeners;
6+
class ofEventArgs;
7+
//#include "ofRectangle.h"
8+
class ofRectangle;
69

710
#define GLM_FORCE_CTOR_INIT
811
#define GLM_ENABLE_EXPERIMENTAL

libs/openFrameworks/3d/ofMesh.inl

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,9 +1782,11 @@ void ofMesh_<V,N,C,T>::smoothNormals( float angle ) {
17821782
if( getMode() == OF_PRIMITIVE_TRIANGLES) {
17831783
std::vector<ofMeshFace_<V,N,C,T>> triangles = getUniqueFaces();
17841784
std::vector<V> verts;
1785+
verts.reserve( triangles.size() * 3 );
1786+
17851787
for(ofIndexType i = 0; i < triangles.size(); i++) {
17861788
for(ofIndexType j = 0; j < 3; j++) {
1787-
verts.push_back( triangles[i].getVertex(j) );
1789+
verts.emplace_back( triangles[i].getVertex(j) );
17881790
}
17891791
}
17901792

@@ -1811,20 +1813,21 @@ void ofMesh_<V,N,C,T>::smoothNormals( float angle ) {
18111813

18121814
//ofLogNotice("ofMesh") << "smoothNormals(): num verts = " << verts.size() << " tris size = " << triangles.size();
18131815

1814-
std::string xStr, yStr, zStr;
18151816

18161817
for(ofIndexType i = 0; i < verts.size(); i++ ) {
1817-
xStr = "x"+ofToString(verts[i].x==-0?0:verts[i].x);
1818-
yStr = "y"+ofToString(verts[i].y==-0?0:verts[i].y);
1819-
zStr = "z"+ofToString(verts[i].z==-0?0:verts[i].z);
1820-
std::string vstring = xStr+yStr+zStr;
1818+
std::string vstring {
1819+
"x"+ofToString(verts[i].x==-0?0:verts[i].x) +
1820+
"y"+ofToString(verts[i].y==-0?0:verts[i].y) +
1821+
"z"+ofToString(verts[i].z==-0?0:verts[i].z)
1822+
};
1823+
18211824
if(vertHash.find(vstring) == vertHash.end()) {
18221825
for(ofIndexType j = 0; j < triangles.size(); j++) {
18231826
for(ofIndexType k = 0; k < 3; k++) {
18241827
if(verts[i].x == triangles[j].getVertex(k).x) {
18251828
if(verts[i].y == triangles[j].getVertex(k).y) {
18261829
if(verts[i].z == triangles[j].getVertex(k).z) {
1827-
vertHash[vstring].push_back( j );
1830+
vertHash[vstring].emplace_back( j );
18281831
}
18291832
}
18301833
}
@@ -1846,11 +1849,12 @@ void ofMesh_<V,N,C,T>::smoothNormals( float angle ) {
18461849
for(ofIndexType j = 0; j < triangles.size(); j++) {
18471850
for(ofIndexType k = 0; k < 3; k++) {
18481851
vert = triangles[j].getVertex(k);
1849-
xStr = "x"+ofToString(vert.x==-0?0:vert.x);
1850-
yStr = "y"+ofToString(vert.y==-0?0:vert.y);
1851-
zStr = "z"+ofToString(vert.z==-0?0:vert.z);
1852-
1853-
std::string vstring = xStr+yStr+zStr;
1852+
std::string vstring {
1853+
"x"+ofToString(vert.x==-0?0:vert.x) +
1854+
"y"+ofToString(vert.y==-0?0:vert.y) +
1855+
"z"+ofToString(vert.z==-0?0:vert.z)
1856+
};
1857+
18541858
numNormals=0;
18551859
normal = {0.f,0.f,0.f};
18561860
if(vertHash.find(vstring) != vertHash.end()) {
@@ -2118,8 +2122,8 @@ ofMesh_<V,N,C,T> ofMesh_<V,N,C,T>::sphere( float radius, int res, ofPrimitiveMod
21182122
//--------------------------------------------------------------
21192123
template<class V, class N, class C, class T>
21202124
ofMesh_<V,N,C,T> ofMesh_<V,N,C,T>::icosahedron(float radius) {
2121-
auto mesh = icosphere(radius, 0);
2122-
mesh.flatNormals();
2125+
auto mesh { icosphere(radius, 0) };
2126+
mesh.flatNormals();
21232127
return mesh;
21242128
}
21252129

@@ -2137,6 +2141,8 @@ ofMesh_<V,N,C,T> ofMesh_<V,N,C,T>::icosphere(float radius, std::size_t iteration
21372141
const float phi = (1.0f + sqrt5) * 0.5f;
21382142
const float invnorm = 1/sqrt(phi*phi+1);
21392143

2144+
2145+
// FIXME: addvertices XAXA
21402146
sphere.addVertex(invnorm * V(-1, phi, 0));//0
21412147
sphere.addVertex(invnorm * V( 1, phi, 0));//1
21422148
sphere.addVertex(invnorm * V(0, 1, -phi));//2
@@ -2173,7 +2179,7 @@ ofMesh_<V,N,C,T> ofMesh_<V,N,C,T>::icosphere(float radius, std::size_t iteration
21732179
10,11,9
21742180
};
21752181

2176-
for(ofIndexType i = 0; i < 60; i+=3) {
2182+
for(ofIndexType i = 0; i < 60; i+=3) {
21772183
sphere.addTriangle(firstFaces[i], firstFaces[i+1], firstFaces[i+2]);
21782184
}
21792185

libs/openFrameworks/gl/ofCubeMapShaders.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ofCubeMapShaders {
1818
};
1919

2020
static std::string getGLSLHeader() {
21-
std::string vstr = "#version 150\n";
21+
std::string vstr { "#version 150\n" };
2222
if( ofGetGLRenderer() ) {
2323
vstr = "#version "+ofGLSLVersionFromGL(ofGetGLRenderer()->getGLVersionMajor(), ofGetGLRenderer()->getGLVersionMinor())+"\n";
2424
}
@@ -40,18 +40,19 @@ class ofCubeMapShaders {
4040
}
4141

4242
static std::string defaultVertShader() {
43-
std::string vshader = getGLSLHeader();
43+
44+
std::string vshader { getGLSLHeader() };
4445
vshader += R"(in vec4 position;
4546
uniform mat4 uProjection;
46-
uniform mat4 uView;
47-
48-
out vec3 oLocalPos;
49-
50-
void main() {
51-
oLocalPos = position.xyz;
52-
gl_Position = uProjection * uView * vec4(position.xyz, 1.0);
53-
}
54-
)";
47+
uniform mat4 uView;
48+
49+
out vec3 oLocalPos;
50+
51+
void main() {
52+
oLocalPos = position.xyz;
53+
gl_Position = uProjection * uView * vec4(position.xyz, 1.0);
54+
}
55+
)";
5556

5657
return vshader;
5758
}

libs/openFrameworks/gl/ofGLUtils.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "ofGraphicsConstants.h"
1111
// MARK: Targets / Defines
12-
#include "ofConstants.h"
12+
//#include "ofConstants.h"
1313

1414
class ofShader;
1515
class ofGLProgrammableRenderer;
@@ -18,7 +18,6 @@ class ofTexture;
1818

1919
template<typename T>
2020
class ofPixels_;
21-
2221
typedef ofPixels_<unsigned char> ofPixels;
2322
typedef ofPixels_<float> ofFloatPixels;
2423
typedef ofPixels_<unsigned short> ofShortPixels;

libs/openFrameworks/gl/ofMaterial.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ bool ofMaterial::loadTexture( const ofMaterialTextureType& aMaterialTextureType,
290290
bool bWasUsingArb = ofGetUsingArbTex();
291291
bTex2d ? ofDisableArbTex() : ofEnableArbTex();
292292

293-
auto tex = std::make_shared<ofTexture>();
293+
auto tex { std::make_shared<ofTexture>() };
294294
bool bLoadOk = ofLoadImage(*tex, apath, mirrorY );
295295

296296
if( bLoadOk ) {
@@ -810,7 +810,7 @@ const ofShader& ofMaterial::getShadowDepthShader( const ofShadow& ashadow, ofGLP
810810
auto shadowShader = mDepthShaders[&renderer]->shaders.find(shadowShaderId);
811811

812812
if(shadowShader == mDepthShaders[&renderer]->shaders.end() || !mDepthShaders[&renderer]->shaders[shadowShaderId] ) {
813-
auto nDepthShader = std::make_shared<ofShader>();
813+
auto nDepthShader { std::make_shared<ofShader>() };
814814

815815
auto customUniforms = data.customUniforms;
816816
for( auto & custom : mCustomUniforms ){

0 commit comments

Comments
 (0)