Skip to content

Commit

Permalink
Small bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
betajippity committed Feb 22, 2014
1 parent 3ceeedb commit e4b6380
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/scene/sceneloader.cpp
Expand Up @@ -125,7 +125,7 @@ void sceneloader::loadCamera(const Json::Value& jsoncamera){
}
//load camera fov
if(jsoncamera.isMember("fovx")){
camera_fov[0] = jsoncamera["fovx"].asFloat();
camera_fov[0] = jsoncamera["fovx"].asFloat()/2.0f;
float xscaled = tan(camera_fov.x*(PI/180));
float yscaled = (xscaled * camera_resolution.y)/camera_resolution.x;
camera_fov.y = (atan(xscaled)*180)/PI;
Expand Down
31 changes: 23 additions & 8 deletions src/viewer/viewer.cpp
Expand Up @@ -40,6 +40,7 @@ void viewer::load(fluidCore::flipsim* sim, bool retina, vec2 resolution,
siminitialized = false;

drawobjects = true;
drawInvalid = false;

dumpFramebuffer = false;
dumpReady = false;
Expand Down Expand Up @@ -139,14 +140,18 @@ void viewer::mainLoop(){

for(int j=0; j<psize; j++){
if(particles->operator[](j)->type==FLUID){
vertexData.push_back(particles->operator[](j)->p*maxd);
float c = length(particles->operator[](j)->u)/3.0f;
c = glm::max(c, 1.0f*glm::max((.7f - particles->operator[](j)->density),0.0f));
bool invalid = particles->operator[](j)->invalid;
if(invalid){
colorData.push_back(vec4(1,0,0,0));
}else{
colorData.push_back(vec4(c,c,1,0));
if(!particles->operator[](j)->invalid ||
(particles->operator[](j)->invalid && drawInvalid)){
vertexData.push_back(particles->operator[](j)->p*maxd);
float c = length(particles->operator[](j)->u)/3.0f;
c = glm::max(c,
1.0f*glm::max((.7f-particles->operator[](j)->density),0.0f));
bool invalid = particles->operator[](j)->invalid;
if(invalid){
colorData.push_back(vec4(1,0,0,0));
}else{
colorData.push_back(vec4(c,c,1,0));
}
}
}
}
Expand Down Expand Up @@ -364,6 +369,16 @@ void viewer::updateInputs(){
cout << "\nPARTIO Export OFF.\n" << endl;
}
}
}else if(glfwGetKey(window, GLFW_KEY_I) == GLFW_PRESS){
if(cam.currentKey!=GLFW_KEY_I){
drawInvalid = !drawInvalid;
cam.currentKey = GLFW_KEY_I;
if(drawInvalid){
cout << "\nDraw out of bound particles ON.\n" << endl;
}else{
cout << "\nDraw out of bound particles OFF.\n" << endl;
}
}
}else{
cam.currentKey = 0;
}
Expand Down
3 changes: 2 additions & 1 deletion src/viewer/viewer.hpp
Expand Up @@ -110,7 +110,8 @@ class viewer{
fluidCore::flipsim* sim;
bool siminitialized;
bool drawobjects;

bool drawInvalid;

unsigned char* bitmapData;
bool dumpFramebuffer;
bool dumpReady;
Expand Down

0 comments on commit e4b6380

Please sign in to comment.