- attempt to improve rendering speed
This commit is contained in:
parent
413c492684
commit
c04b83259e
|
@ -455,6 +455,7 @@ void Renderer::renderParticleManager(ResourceScope rs){
|
||||||
void Renderer::swapBuffers(){
|
void Renderer::swapBuffers(){
|
||||||
|
|
||||||
//glFlush(); // should not be required - http://www.opengl.org/wiki/Common_Mistakes
|
//glFlush(); // should not be required - http://www.opengl.org/wiki/Common_Mistakes
|
||||||
|
glFlush();
|
||||||
|
|
||||||
GraphicsInterface::getInstance().getCurrentContext()->swapBuffers();
|
GraphicsInterface::getInstance().getCurrentContext()->swapBuffers();
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ private:
|
||||||
Vec3f *vertices;
|
Vec3f *vertices;
|
||||||
Vec3f *normals;
|
Vec3f *normals;
|
||||||
|
|
||||||
std::map<std::string, Vec3f *> cacheVertices;
|
//std::map<std::string, Vec3f *> cacheVertices;
|
||||||
std::map<std::string, Vec3f *> cacheNormals;
|
//std::map<std::string, Vec3f *> cacheNormals;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InterpolationData(const Mesh *mesh);
|
InterpolationData(const Mesh *mesh);
|
||||||
|
|
|
@ -39,14 +39,15 @@ InterpolationData::InterpolationData(const Mesh *mesh){
|
||||||
normals= new Vec3f[mesh->getVertexCount()];
|
normals= new Vec3f[mesh->getVertexCount()];
|
||||||
}
|
}
|
||||||
|
|
||||||
cacheVertices.clear();
|
//cacheVertices.clear();
|
||||||
cacheNormals.clear();
|
//cacheNormals.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
InterpolationData::~InterpolationData(){
|
InterpolationData::~InterpolationData(){
|
||||||
delete [] vertices;
|
delete [] vertices;
|
||||||
delete [] normals;
|
delete [] normals;
|
||||||
|
|
||||||
|
/*
|
||||||
for(std::map<std::string, Vec3f *>::iterator iterVert = cacheVertices.begin();
|
for(std::map<std::string, Vec3f *>::iterator iterVert = cacheVertices.begin();
|
||||||
iterVert != cacheVertices.end(); iterVert++) {
|
iterVert != cacheVertices.end(); iterVert++) {
|
||||||
delete [] iterVert->second;
|
delete [] iterVert->second;
|
||||||
|
@ -55,6 +56,7 @@ InterpolationData::~InterpolationData(){
|
||||||
iterVert != cacheNormals.end(); iterVert++) {
|
iterVert != cacheNormals.end(); iterVert++) {
|
||||||
delete [] iterVert->second;
|
delete [] iterVert->second;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void InterpolationData::update(float t, bool cycle){
|
void InterpolationData::update(float t, bool cycle){
|
||||||
|
@ -69,6 +71,7 @@ void InterpolationData::updateVertices(float t, bool cycle) {
|
||||||
uint32 vertexCount= mesh->getVertexCount();
|
uint32 vertexCount= mesh->getVertexCount();
|
||||||
|
|
||||||
if(frameCount > 1) {
|
if(frameCount > 1) {
|
||||||
|
/*
|
||||||
std::string lookupKey = floatToStr(t) + "_" + boolToStr(cycle);
|
std::string lookupKey = floatToStr(t) + "_" + boolToStr(cycle);
|
||||||
std::map<std::string, Vec3f *>::iterator iterFind = cacheVertices.find(lookupKey);
|
std::map<std::string, Vec3f *>::iterator iterFind = cacheVertices.find(lookupKey);
|
||||||
|
|
||||||
|
@ -82,7 +85,7 @@ void InterpolationData::updateVertices(float t, bool cycle) {
|
||||||
cacheVertices[lookupKey] = new Vec3f[vertexCount];
|
cacheVertices[lookupKey] = new Vec3f[vertexCount];
|
||||||
iterFind = cacheVertices.find(lookupKey);
|
iterFind = cacheVertices.find(lookupKey);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
const Vec3f *meshVertices= mesh->getVertices();
|
const Vec3f *meshVertices= mesh->getVertices();
|
||||||
|
|
||||||
//misc vars
|
//misc vars
|
||||||
|
@ -99,7 +102,7 @@ void InterpolationData::updateVertices(float t, bool cycle) {
|
||||||
//interpolate vertices
|
//interpolate vertices
|
||||||
for(uint32 j=0; j<vertexCount; ++j){
|
for(uint32 j=0; j<vertexCount; ++j){
|
||||||
vertices[j]= meshVertices[prevFrameBase+j].lerp(localT, meshVertices[nextFrameBase+j]);
|
vertices[j]= meshVertices[prevFrameBase+j].lerp(localT, meshVertices[nextFrameBase+j]);
|
||||||
iterFind->second[j] = vertices[j];
|
// iterFind->second[j] = vertices[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,6 +114,7 @@ void InterpolationData::updateNormals(float t, bool cycle){
|
||||||
uint32 vertexCount= mesh->getVertexCount();
|
uint32 vertexCount= mesh->getVertexCount();
|
||||||
|
|
||||||
if(frameCount > 1) {
|
if(frameCount > 1) {
|
||||||
|
/*
|
||||||
std::string lookupKey = floatToStr(t) + "_" + boolToStr(cycle);
|
std::string lookupKey = floatToStr(t) + "_" + boolToStr(cycle);
|
||||||
std::map<std::string, Vec3f *>::iterator iterFind = cacheNormals.find(lookupKey);
|
std::map<std::string, Vec3f *>::iterator iterFind = cacheNormals.find(lookupKey);
|
||||||
if(iterFind != cacheNormals.end()) {
|
if(iterFind != cacheNormals.end()) {
|
||||||
|
@ -123,7 +127,7 @@ void InterpolationData::updateNormals(float t, bool cycle){
|
||||||
cacheNormals[lookupKey] = new Vec3f[mesh->getVertexCount()];
|
cacheNormals[lookupKey] = new Vec3f[mesh->getVertexCount()];
|
||||||
iterFind = cacheNormals.find(lookupKey);
|
iterFind = cacheNormals.find(lookupKey);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
const Vec3f *meshNormals= mesh->getNormals();
|
const Vec3f *meshNormals= mesh->getNormals();
|
||||||
|
|
||||||
//misc vars
|
//misc vars
|
||||||
|
@ -140,7 +144,7 @@ void InterpolationData::updateNormals(float t, bool cycle){
|
||||||
//interpolate vertices
|
//interpolate vertices
|
||||||
for(uint32 j=0; j<vertexCount; ++j){
|
for(uint32 j=0; j<vertexCount; ++j){
|
||||||
normals[j]= meshNormals[prevFrameBase+j].lerp(localT, meshNormals[nextFrameBase+j]);
|
normals[j]= meshNormals[prevFrameBase+j].lerp(localT, meshNormals[nextFrameBase+j]);
|
||||||
iterFind->second[j] = normals[j];
|
// iterFind->second[j] = normals[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user