Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core small changes #7952

Merged
merged 3 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion addons/ofxKinect/src/ofxKinect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

==============================================================================*/
#include "ofxKinect.h"
#include "ofMain.h"

#include "libfreenect_registration.h"
#include "freenect_internal.h" // for access to freenect_device.registration.zero_plane_info
Expand Down
9 changes: 1 addition & 8 deletions addons/ofxOpenCv/src/ofxCvContourFinder.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@

#include "ofxCvContourFinder.h"



//--------------------------------------------------------------------------------
static bool sort_carea_compare( const CvSeq* a, const CvSeq* b) {

// use opencv to calc size, then sort based on size
float areaa = cvContourArea(a, CV_WHOLE_SEQ);
float areab = cvContourArea(b, CV_WHOLE_SEQ);

return (areaa > areab);
}




//--------------------------------------------------------------------------------
ofxCvContourFinder::ofxCvContourFinder() {
_width = 0;
Expand Down Expand Up @@ -218,7 +211,7 @@ void ofxCvContourFinder::setAnchorPercent( float xPct, float yPct ){
}

//--------------------------------------------------------------------------------
void ofxCvContourFinder::setAnchorPoint( int x, int y ){
void ofxCvContourFinder::setAnchorPoint( float x, float y ){
anchor.x = x;
anchor.y = y;
bAnchorIsPct = false;
Expand Down
69 changes: 34 additions & 35 deletions addons/ofxOpenCv/src/ofxCvContourFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,52 +16,51 @@
#include <algorithm>

class ofxCvContourFinder : public ofBaseDraws {
public:

public:

std::vector<ofxCvBlob> blobs;
int nBlobs; // DEPRECATED: use blobs.size() instead

std::vector<ofxCvBlob> blobs;
int nBlobs; // DEPRECATED: use blobs.size() instead


ofxCvContourFinder();
virtual ~ofxCvContourFinder();
ofxCvContourFinder();
virtual ~ofxCvContourFinder();
virtual float getWidth() const { return _width; }; //set after first findContours call
virtual float getHeight() const { return _height; }; //set after first findContours call
virtual int findContours( ofxCvGrayscaleImage& input,
int minArea, int maxArea,
int nConsidered, bool bFindHoles,
bool bUseApproximation = true);
// approximation = don't do points for all points
// of the contour, if the contour runs
// along a straight line, for example...
virtual int findContours( ofxCvGrayscaleImage& input,
int minArea, int maxArea,
int nConsidered, bool bFindHoles,
bool bUseApproximation = true);
// approximation = don't do points for all points
// of the contour, if the contour runs
// along a straight line, for example...

virtual void draw() const { draw(0,0, _width, _height); };
virtual void draw( float x, float y ) const { draw(x,y, _width, _height); };
virtual void draw( float x, float y, float w, float h ) const;
virtual void draw(const glm::vec2 & point) const;
virtual void draw(const ofRectangle & rect) const;
virtual void draw() const { draw(0,0, _width, _height); };
virtual void draw( float x, float y ) const { draw(x,y, _width, _height); };
virtual void draw( float x, float y, float w, float h ) const;
virtual void draw(const glm::vec2 & point) const;
virtual void draw(const ofRectangle & rect) const;
virtual void setAnchorPercent(float xPct, float yPct);
virtual void setAnchorPoint(int x, int y);
virtual void setAnchorPoint(float x, float y);
virtual void resetAnchor();
//virtual ofxCvBlob getBlob(int num);
//virtual ofxCvBlob getBlob(int num);



protected:
protected:

int _width;
int _height;
ofxCvGrayscaleImage inputCopy;
CvMemStorage* contour_storage;
CvMemStorage* storage;
CvMoments* myMoments;
std::vector<CvSeq*> cvSeqBlobs; //these will become blobs
ofPoint anchor;
bool bAnchorIsPct;
int _width;
int _height;
ofxCvGrayscaleImage inputCopy;
CvMemStorage* contour_storage;
CvMemStorage* storage;
CvMoments* myMoments;
std::vector<CvSeq*> cvSeqBlobs; //these will become blobs
ofPoint anchor;
bool bAnchorIsPct;

virtual void reset();
virtual void reset();

};
7 changes: 5 additions & 2 deletions libs/openFrameworks/3d/ofEasyCam.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#pragma once

#include "ofCamera.h"
#include "ofEvents.h"
#include "ofRectangle.h"
//#include "ofEvents.h"
class ofEventListeners;
class ofEventArgs;
//#include "ofRectangle.h"
class ofRectangle;

#define GLM_FORCE_CTOR_INIT
#define GLM_ENABLE_EXPERIMENTAL
Expand Down
36 changes: 21 additions & 15 deletions libs/openFrameworks/3d/ofMesh.inl
Original file line number Diff line number Diff line change
Expand Up @@ -1782,9 +1782,11 @@ void ofMesh_<V,N,C,T>::smoothNormals( float angle ) {
if( getMode() == OF_PRIMITIVE_TRIANGLES) {
std::vector<ofMeshFace_<V,N,C,T>> triangles = getUniqueFaces();
std::vector<V> verts;
verts.reserve( triangles.size() * 3 );

for(ofIndexType i = 0; i < triangles.size(); i++) {
for(ofIndexType j = 0; j < 3; j++) {
verts.push_back( triangles[i].getVertex(j) );
verts.emplace_back( triangles[i].getVertex(j) );
}
}

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

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

std::string xStr, yStr, zStr;

for(ofIndexType i = 0; i < verts.size(); i++ ) {
xStr = "x"+ofToString(verts[i].x==-0?0:verts[i].x);
yStr = "y"+ofToString(verts[i].y==-0?0:verts[i].y);
zStr = "z"+ofToString(verts[i].z==-0?0:verts[i].z);
std::string vstring = xStr+yStr+zStr;
std::string vstring {
"x"+ofToString(verts[i].x==-0?0:verts[i].x) +
"y"+ofToString(verts[i].y==-0?0:verts[i].y) +
"z"+ofToString(verts[i].z==-0?0:verts[i].z)
};

if(vertHash.find(vstring) == vertHash.end()) {
for(ofIndexType j = 0; j < triangles.size(); j++) {
for(ofIndexType k = 0; k < 3; k++) {
if(verts[i].x == triangles[j].getVertex(k).x) {
if(verts[i].y == triangles[j].getVertex(k).y) {
if(verts[i].z == triangles[j].getVertex(k).z) {
vertHash[vstring].push_back( j );
vertHash[vstring].emplace_back( j );
}
}
}
Expand All @@ -1846,11 +1849,12 @@ void ofMesh_<V,N,C,T>::smoothNormals( float angle ) {
for(ofIndexType j = 0; j < triangles.size(); j++) {
for(ofIndexType k = 0; k < 3; k++) {
vert = triangles[j].getVertex(k);
xStr = "x"+ofToString(vert.x==-0?0:vert.x);
yStr = "y"+ofToString(vert.y==-0?0:vert.y);
zStr = "z"+ofToString(vert.z==-0?0:vert.z);

std::string vstring = xStr+yStr+zStr;
std::string vstring {
"x"+ofToString(vert.x==-0?0:vert.x) +
"y"+ofToString(vert.y==-0?0:vert.y) +
"z"+ofToString(vert.z==-0?0:vert.z)
};

numNormals=0;
normal = {0.f,0.f,0.f};
if(vertHash.find(vstring) != vertHash.end()) {
Expand Down Expand Up @@ -2118,8 +2122,8 @@ ofMesh_<V,N,C,T> ofMesh_<V,N,C,T>::sphere( float radius, int res, ofPrimitiveMod
//--------------------------------------------------------------
template<class V, class N, class C, class T>
ofMesh_<V,N,C,T> ofMesh_<V,N,C,T>::icosahedron(float radius) {
auto mesh = icosphere(radius, 0);
mesh.flatNormals();
auto mesh { icosphere(radius, 0) };
mesh.flatNormals();
return mesh;
}

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


// FIXME: addvertices XAXA
sphere.addVertex(invnorm * V(-1, phi, 0));//0
sphere.addVertex(invnorm * V( 1, phi, 0));//1
sphere.addVertex(invnorm * V(0, 1, -phi));//2
Expand Down Expand Up @@ -2173,7 +2179,7 @@ ofMesh_<V,N,C,T> ofMesh_<V,N,C,T>::icosphere(float radius, std::size_t iteration
10,11,9
};

for(ofIndexType i = 0; i < 60; i+=3) {
for(ofIndexType i = 0; i < 60; i+=3) {
sphere.addTriangle(firstFaces[i], firstFaces[i+1], firstFaces[i+2]);
}

Expand Down
23 changes: 12 additions & 11 deletions libs/openFrameworks/gl/ofCubeMapShaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ofCubeMapShaders {
};

static std::string getGLSLHeader() {
std::string vstr = "#version 150\n";
std::string vstr { "#version 150\n" };
if( ofGetGLRenderer() ) {
vstr = "#version "+ofGLSLVersionFromGL(ofGetGLRenderer()->getGLVersionMajor(), ofGetGLRenderer()->getGLVersionMinor())+"\n";
}
Expand All @@ -40,18 +40,19 @@ class ofCubeMapShaders {
}

static std::string defaultVertShader() {
std::string vshader = getGLSLHeader();

std::string vshader { getGLSLHeader() };
vshader += R"(in vec4 position;
uniform mat4 uProjection;
uniform mat4 uView;
out vec3 oLocalPos;
void main() {
oLocalPos = position.xyz;
gl_Position = uProjection * uView * vec4(position.xyz, 1.0);
}
)";
uniform mat4 uView;

out vec3 oLocalPos;

void main() {
oLocalPos = position.xyz;
gl_Position = uProjection * uView * vec4(position.xyz, 1.0);
}
)";

return vshader;
}
Expand Down
3 changes: 1 addition & 2 deletions libs/openFrameworks/gl/ofGLUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "ofGraphicsConstants.h"
// MARK: Targets / Defines
#include "ofConstants.h"
//#include "ofConstants.h"

class ofShader;
class ofGLProgrammableRenderer;
Expand All @@ -18,7 +18,6 @@ class ofTexture;

template<typename T>
class ofPixels_;

typedef ofPixels_<unsigned char> ofPixels;
typedef ofPixels_<float> ofFloatPixels;
typedef ofPixels_<unsigned short> ofShortPixels;
Expand Down
4 changes: 2 additions & 2 deletions libs/openFrameworks/gl/ofMaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ bool ofMaterial::loadTexture( const ofMaterialTextureType& aMaterialTextureType,
bool bWasUsingArb = ofGetUsingArbTex();
bTex2d ? ofDisableArbTex() : ofEnableArbTex();

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

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

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

auto customUniforms = data.customUniforms;
for( auto & custom : mCustomUniforms ){
Expand Down
Loading