From 460b52ad11e7426a9ea9f19d2b6d3559146e43f3 Mon Sep 17 00:00:00 2001 From: Kearwood Gilbert Date: Sun, 9 Jul 2017 20:13:48 -0700 Subject: [PATCH] Fixing warnings --- kraken/KRAABB.cpp | 59 ++++++++++++++++++++------------------- kraken/KRCamera.cpp | 5 ++-- kraken/KRContext.cpp | 4 +-- kraken/KRLODSet.cpp | 6 ++++ kraken/KRResource+obj.cpp | 4 +-- kraken_ios/KrakenView.mm | 2 +- 6 files changed, 44 insertions(+), 36 deletions(-) diff --git a/kraken/KRAABB.cpp b/kraken/KRAABB.cpp index 74002d7..97c2a8f 100755 --- a/kraken/KRAABB.cpp +++ b/kraken/KRAABB.cpp @@ -208,26 +208,26 @@ bool KRAABB::intersectsLine(const KRVector3 &v1, const KRVector3 &v2) const bool KRAABB::intersectsRay(const KRVector3 &v1, const KRVector3 &dir) const { - /* - Fast Ray-Box Intersection - by Andrew Woo - from "Graphics Gems", Academic Press, 1990 - */ - - // FINDME, TODO - Perhaps there is a more efficient algorithm, as we don't actually need the exact coordinate of the intersection - - enum { - RIGHT = 0, - LEFT = 1, - MIDDLE = 2 - } quadrant[3]; - - bool inside = true; - KRVector3 maxT; - KRVector3 coord; + /* + Fast Ray-Box Intersection + by Andrew Woo + from "Graphics Gems", Academic Press, 1990 + */ + + // FINDME, TODO - Perhaps there is a more efficient algorithm, as we don't actually need the exact coordinate of the intersection + + enum { + RIGHT = 0, + LEFT = 1, + MIDDLE = 2 + } quadrant[3]; + + bool inside = true; + KRVector3 maxT; + KRVector3 coord; double candidatePlane[3]; - - // Find candidate planes; this loop can be avoided if rays cast all from the eye(assume perpsective view) + + // Find candidate planes; this loop can be avoided if rays cast all from the eye(assume perpsective view) for (int i=0; i<3; i++) if(v1.c[i] < min.c[i]) { quadrant[i] = LEFT; @@ -237,42 +237,45 @@ bool KRAABB::intersectsRay(const KRVector3 &v1, const KRVector3 &dir) const quadrant[i] = RIGHT; candidatePlane[i] = max.c[i]; inside = false; - } else { + } else { quadrant[i] = MIDDLE; } /* Ray v1 inside bounding box */ - if(inside) { + if (inside) { coord = v1; return true; } - - + /* Calculate T distances to candidate planes */ for (int i = 0; i < 3; i++) { - if (quadrant[i] != MIDDLE && dir[i] !=0.) { + if (quadrant[i] != MIDDLE && dir[i] != 0.0f) { maxT.c[i] = (candidatePlane[i]-v1.c[i]) / dir[i]; } else { maxT.c[i] = -1.0f; - } } + } /* Get largest of the maxT's for final choice of intersection */ int whichPlane = 0; for (int i = 1; i < 3; i++) { if (maxT.c[whichPlane] < maxT.c[i]) { whichPlane = i; - } } + } /* Check final candidate actually inside box */ - if (maxT.c[whichPlane] < 0.0f) return false; + if (maxT.c[whichPlane] < 0.0f) { + return false; + } for (int i = 0; i < 3; i++) { if (whichPlane != i) { coord[i] = v1.c[i] + maxT.c[whichPlane] *dir[i]; - if (coord[i] < min.c[i] || coord[i] > max.c[i]) + if (coord[i] < min.c[i] || coord[i] > max.c[i]) { return false; + } } else { + assert(quadrant[i] != MIDDLE); // This should not be possible coord[i] = candidatePlane[i]; } } diff --git a/kraken/KRCamera.cpp b/kraken/KRCamera.cpp index 70d1d03..1b739da 100755 --- a/kraken/KRCamera.cpp +++ b/kraken/KRCamera.cpp @@ -100,7 +100,7 @@ void KRCamera::renderFrame(GLint defaultFBO, GLint renderBufferWidth, GLint rend // ----====---- Record timing information for measuring FPS ----====---- uint64_t current_time = m_pContext->getAbsoluteTimeMilliseconds(); if(m_last_frame_start != 0) { - m_frame_times[m_pContext->getCurrentFrame() % KRAKEN_FPS_AVERAGE_FRAME_COUNT] = (current_time - m_last_frame_start); + m_frame_times[m_pContext->getCurrentFrame() % KRAKEN_FPS_AVERAGE_FRAME_COUNT] = (int)(current_time - m_last_frame_start); if(m_frame_times_filled < KRAKEN_FPS_AVERAGE_FRAME_COUNT) m_frame_times_filled++; } m_last_frame_start = current_time; @@ -914,10 +914,9 @@ std::string KRCamera::getDebugText() for(int i=0; i < KRAKEN_FPS_AVERAGE_FRAME_COUNT; i++) { fps += m_frame_times[i]; } + fps = 1000000 / (fps / KRAKEN_FPS_AVERAGE_FRAME_COUNT); // Order of division chosen to prevent overflow } - fps = 1000000 / (fps / KRAKEN_FPS_AVERAGE_FRAME_COUNT); // Order of division chosen to prevent overflow - switch(settings.debug_display) { case KRRenderSettings::KRENGINE_DEBUG_DISPLAY_NONE: // ----====---- No debug display ----====---- break; diff --git a/kraken/KRContext.cpp b/kraken/KRContext.cpp index e8bbe56..d37ddf1 100755 --- a/kraken/KRContext.cpp +++ b/kraken/KRContext.cpp @@ -351,13 +351,13 @@ void KRContext::getMemoryStats(long &free_memory) mach_msg_type_number_t host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t); vm_size_t pagesize = 0; vm_statistics_data_t vm_stat; - int total_ram = 256 * 1024 * 1024; + // int total_ram = 256 * 1024 * 1024; if(host_page_size(host_port, &pagesize) != KERN_SUCCESS) { KRContext::Log(KRContext::LOG_LEVEL_ERROR, "Could not get VM page size."); } else if(host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS) { KRContext::Log(KRContext::LOG_LEVEL_ERROR, "Could not get VM stats."); } else { - total_ram = (vm_stat.wire_count + vm_stat.active_count + vm_stat.inactive_count + vm_stat.free_count) * pagesize; + // total_ram = (vm_stat.wire_count + vm_stat.active_count + vm_stat.inactive_count + vm_stat.free_count) * pagesize; free_memory = (vm_stat.free_count + vm_stat.inactive_count) * pagesize; } diff --git a/kraken/KRLODSet.cpp b/kraken/KRLODSet.cpp index bb1f144..d9dda66 100755 --- a/kraken/KRLODSet.cpp +++ b/kraken/KRLODSet.cpp @@ -39,16 +39,22 @@ void KRLODSet::loadXML(tinyxml2::XMLElement *e) void KRLODSet::updateLODVisibility(const KRViewport &viewport) { if(m_lod_visible >= LOD_VISIBILITY_PRESTREAM) { + /* + // FINDME, TODO, HACK - Disabled streamer delayed LOD load due to performance issues: KRLODGroup *new_active_lod_group = NULL; + */ // Upgrade and downgrade LOD groups as needed for(std::set::iterator itr=m_childNodes.begin(); itr != m_childNodes.end(); ++itr) { KRLODGroup *lod_group = dynamic_cast(*itr); assert(lod_group != NULL); LodVisibility group_lod_visibility = KRMIN(lod_group->calcLODVisibility(viewport), m_lod_visible); + /* + // FINDME, TODO, HACK - Disabled streamer delayed LOD load due to performance issues: if(group_lod_visibility == LOD_VISIBILITY_VISIBLE) { new_active_lod_group = lod_group; } + */ lod_group->setLODVisibility(group_lod_visibility); } diff --git a/kraken/KRResource+obj.cpp b/kraken/KRResource+obj.cpp index 90406b1..04569f3 100755 --- a/kraken/KRResource+obj.cpp +++ b/kraken/KRResource+obj.cpp @@ -98,7 +98,7 @@ std::vector KRResource::LoadObj(KRContext &context, const std::str // -----=====----- Populate vertexes and faces -----=====----- - int *pFaces = (int *)malloc(sizeof(int *) * (cFaces + 1)); + int *pFaces = (int *)malloc(sizeof(int) * (cFaces + 1)); assert(pFaces != NULL); std::vector indexed_vertices; @@ -337,4 +337,4 @@ std::vector KRResource::LoadObj(KRContext &context, const std::str } return resources; -} \ No newline at end of file +} diff --git a/kraken_ios/KrakenView.mm b/kraken_ios/KrakenView.mm index 8c21327..6382d6a 100644 --- a/kraken_ios/KrakenView.mm +++ b/kraken_ios/KrakenView.mm @@ -164,7 +164,7 @@ #endif GLDEBUG(glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer)); - BOOL success = [self.context presentRenderbuffer:GL_RENDERBUFFER]; + [self.context presentRenderbuffer:GL_RENDERBUFFER]; if (self.delegate && delegateRespondsTo.postRender) { [self.delegate postRender:context withDeltaTime:deltaTime];