Kaydet (Commit) 11b32810 authored tarafından Zolnai Tamás's avatar Zolnai Tamás Kaydeden (comit) Zolnai Tamás

Update libgltf: various fixes, memory usage optimization (second try)

Fixes in the new tarball (beside the upstreamed bug fixes):
- In walkthrough mode camera is moved relative to the current
camera position and not relative to the initial camera position.
- The right FPS numbers are displayed under Linux.
- Some memory optimization to avoid running out of memory
in case of huge models.
- Other freedesktop bugs: fdo#81205, fdo#81207, fdo#81250

Change-Id: Ie0f65be3312688196fcca634eb396c577f991073
Reviewed-on: https://gerrit.libreoffice.org/10274Reviewed-by: 's avatarZolnai Tamás <zolnaitamas2000@gmail.com>
Tested-by: 's avatarZolnai Tamás <zolnaitamas2000@gmail.com>
üst 2729671e
...@@ -156,7 +156,6 @@ $(WORKDIR)/download: $(BUILDDIR)/config_host.mk $(SRCDIR)/download.lst $(SRCDIR) ...@@ -156,7 +156,6 @@ $(WORKDIR)/download: $(BUILDDIR)/config_host.mk $(SRCDIR)/download.lst $(SRCDIR)
$(call fetch_Optional,LIBATOMIC_OPS,LIBATOMIC_OPS_TARBALL) \ $(call fetch_Optional,LIBATOMIC_OPS,LIBATOMIC_OPS_TARBALL) \
$(call fetch_Optional,LIBEOT,LIBEOT_TARBALL) \ $(call fetch_Optional,LIBEOT,LIBEOT_TARBALL) \
$(call fetch_Optional,LIBEXTTEXTCAT,LIBEXTTEXTCAT_TARBALL) \ $(call fetch_Optional,LIBEXTTEXTCAT,LIBEXTTEXTCAT_TARBALL) \
$(call fetch_Optional,LIBGLTF,LIBGLTF_TARBALL) \
$(call fetch_Optional,LIBLANGTAG,LANGTAGREG_TARBALL) \ $(call fetch_Optional,LIBLANGTAG,LANGTAGREG_TARBALL) \
$(call fetch_Optional,LIBLANGTAG,LIBLANGTAG_TARBALL) \ $(call fetch_Optional,LIBLANGTAG,LIBLANGTAG_TARBALL) \
$(call fetch_Optional,LIBPNG,PNG_TARBALL) \ $(call fetch_Optional,LIBPNG,PNG_TARBALL) \
...@@ -236,6 +235,8 @@ $(WORKDIR)/download: $(BUILDDIR)/config_host.mk $(SRCDIR)/download.lst $(SRCDIR) ...@@ -236,6 +235,8 @@ $(WORKDIR)/download: $(BUILDDIR)/config_host.mk $(SRCDIR)/download.lst $(SRCDIR)
$(call fetch_Optional,MOZ,$(MOZ_ZIP_LIB)) \ $(call fetch_Optional,MOZ,$(MOZ_ZIP_LIB)) \
$(call fetch_Optional,MOZ,$(MOZ_ZIP_RUNTIME)) \ $(call fetch_Optional,MOZ,$(MOZ_ZIP_RUNTIME)) \
,$(call fetch_Download_item_unchecked,http://dev-www.libreoffice.org/mozilla,$(item))) ,$(call fetch_Download_item_unchecked,http://dev-www.libreoffice.org/mozilla,$(item)))
$(if $(call fetch_Optional,LIBGLTF,LIBGLTF_TARBALL) \
, $(call fetch_Download_item,http://dev-www.libreoffice.org/src/libgltf,$(call fetch_Optional,LIBGLTF,LIBGLTF_TARBALL)))
@mkdir -p $(dir $@) && touch $@ @mkdir -p $(dir $@) && touch $@
# vim: set noet sw=4 ts=4: # vim: set noet sw=4 ts=4:
...@@ -87,7 +87,7 @@ export LIBATOMIC_OPS_TARBALL := libatomic_ops-7_2d.zip ...@@ -87,7 +87,7 @@ export LIBATOMIC_OPS_TARBALL := libatomic_ops-7_2d.zip
export LIBEOT_MD5SUM := aa24f5dd2a2992f4a116aa72af817548 export LIBEOT_MD5SUM := aa24f5dd2a2992f4a116aa72af817548
export LIBEOT_TARBALL := libeot-0.01.tar.bz2 export LIBEOT_TARBALL := libeot-0.01.tar.bz2
export LIBEXTTEXTCAT_TARBALL := 10d61fbaa6a06348823651b1bd7940fe-libexttextcat-3.4.4.tar.bz2 export LIBEXTTEXTCAT_TARBALL := 10d61fbaa6a06348823651b1bd7940fe-libexttextcat-3.4.4.tar.bz2
export LIBGLTF_TARBALL := 9c8d3455e0d8ef51269784e9a473feeb-libgltf.tar.bz2 export LIBGLTF_TARBALL := 3d9ea1f2828c46f8ba94b88a87b3326d-libgltf-0.0.0.tar.bz2
export LIBLANGTAG_TARBALL := 36271d3fa0d9dec1632029b6d7aac925-liblangtag-0.5.1.tar.bz2 export LIBLANGTAG_TARBALL := 36271d3fa0d9dec1632029b6d7aac925-liblangtag-0.5.1.tar.bz2
export LIBXMLSEC_TARBALL := 1f24ab1d39f4a51faf22244c94a6203f-xmlsec1-1.2.14.tar.gz export LIBXMLSEC_TARBALL := 1f24ab1d39f4a51faf22244c94a6203f-xmlsec1-1.2.14.tar.gz
export LIBXML_TARBALL := 9c0cfef285d5c4a5c80d00904ddab380-libxml2-2.9.1.tar.gz export LIBXML_TARBALL := 9c0cfef285d5c4a5c80d00904ddab380-libxml2-2.9.1.tar.gz
......
...@@ -16,23 +16,6 @@ $(eval $(call gb_UnpackedTarball_set_patchflags,libgltf,--binary)) ...@@ -16,23 +16,6 @@ $(eval $(call gb_UnpackedTarball_set_patchflags,libgltf,--binary))
$(eval $(call gb_UnpackedTarball_set_patchlevel,libgltf,1)) $(eval $(call gb_UnpackedTarball_set_patchlevel,libgltf,1))
$(eval $(call gb_UnpackedTarball_add_patches,libgltf,\ $(eval $(call gb_UnpackedTarball_add_patches,libgltf,\
external/libgltf/patches/libgltf_configure.patch \
external/libgltf/patches/remove_config_h_in_dependencies.patch \
external/libgltf/patches/init_scene_set_handle.patch \
external/libgltf/patches/extend_get_bitmap_for_rgba_ones.patch \
external/libgltf/patches/wrong_duration_caused_by_uninitialized_member.patch \
external/libgltf/patches/wrong_media_time_caused_by_missing_fmod.patch \
external/libgltf/patches/wrong_animation_state_when_set_time_to_null.patch \
external/libgltf/patches/no_effect_of_set_looping.patch \
external/libgltf/patches/wrong_media_time_at_first_run_caused_by_uninitilized_member.patch \
external/libgltf/patches/no_animation_in_orbit_mode.patch \
external/libgltf/patches/walkthrough_mode_affects_orbit_mode_unexpectedly.patch \
external/libgltf/patches/move_fps_closer_to_the_corner.patch \
external/libgltf/patches/compiler_error_fixes.patch \
external/libgltf/patches/fix_package_file.patch \
external/libgltf/patches/comma_at_end_of_enumerator_list.patch \
external/libgltf/patches/extra_semicolon.patch \
external/libgltf/patches/stop_a_potential_memory_leak.patch \
)) ))
# vim: set noet sw=4 ts=4: # vim: set noet sw=4 ts=4:
diff -ur libgltf.org/src/Common.h libgltf/src/Common.h
--- libgltf.org/src/Common.h 2014-06-28 12:17:56.880068394 +0200
+++ libgltf/src/Common.h 2014-06-28 12:22:32.940078647 +0200
@@ -86,7 +86,7 @@
DataType_FLOAT_MAT3 = 0x8B5B,
DataType_FLOAT_MAT4 = 0x8B5C,
DataType_SAMPLER_2D = 0x8B5E,
- DataType_SAMPLER_CUBE = 0x8B60,
+ DataType_SAMPLER_CUBE = 0x8B60
} DataType_E;
class Attribute
@@ -119,7 +119,7 @@
LightSource_DIRECTIONAL = 0x1,
LightSource_POINT = 0x2,
LightSource_SPOT = 0x3,
- LightSource_AMBIET = 0x4,
+ LightSource_AMBIET = 0x4
} LightSourceType_E;
class Light
@@ -252,7 +252,7 @@
TextureType_DISPLACEMENT = 0x9,
TextureType_LIGHTMAP = 0xA,
TextureType_REFLECTION = 0xB,
- TextureType_UNKNOWN = 0xC,
+ TextureType_UNKNOWN = 0xC
} TextureType_E;
class MaterialProperty
@@ -449,7 +449,7 @@
NodeType_Node = 0x1,
NodeType_Mesh = 0x2,
NodeType_Camera = 0x4,
- NodeType_Light = 0x8,
+ NodeType_Light = 0x8
} NodeType_E;
class Node
diff -ur libgltf.org/src/Texture.h libgltf/src/Texture.h
--- libgltf.org/src/Texture.h 2014-06-28 12:17:56.880068394 +0200
+++ libgltf/src/Texture.h 2014-06-28 12:18:19.740069243 +0200
@@ -24,7 +24,7 @@
TEXTURE_FILTER_MIN_BILINEAR,
TEXTURE_FILTER_MIN_NEAREST_MIPMAP,
TEXTURE_FILTER_MIN_BILINEAR_MIPMAP,
- TEXTURE_FILTER_MIN_TRILINEAR,
+ TEXTURE_FILTER_MIN_TRILINEAR
};
class Texture
diff -ur libgltf.org/src/Camera.cpp libgltf/src/Camera.cpp
--- libgltf.org/src/Camera.cpp 2014-06-26 15:49:57.807687346 +0200
+++ libgltf/src/Camera.cpp 2014-06-26 15:50:46.195685296 +0200
@@ -161,7 +161,7 @@
}
else
{
- if (abs(x) > 0.0001 || abs(y) > 0.0001 || abs(z) > 0.0001)
+ if (std::abs(x) > 0.0001 || std::abs(y) > 0.0001 || std::abs(z) > 0.0001)
{
bMoveCmeraModel = true;
}
@@ -240,7 +240,7 @@
{
if (!bAerialView)
return;
- if (abs(horizontal) > planar || abs(vertical) > 0.0001)
+ if (std::abs(horizontal) > planar || std::abs(vertical) > 0.0001)
{
bRotateCameraModel = true;
fRotateCameraXSpeed = 0;
@@ -275,7 +275,7 @@
void CPhysicalCamera::RotateCamera(double horizontal, double vertical,
double planar)
{
- if (abs(horizontal) > planar || abs(vertical) > 0.0001)
+ if (std::abs(horizontal) > planar || std::abs(vertical) > 0.0001)
{
bRotateCameraModel = true;
}
diff -ur libgltf.org/src/Font.cpp libgltf/src/Font.cpp
--- libgltf.org/src/Font.cpp 2014-06-26 15:49:57.807687346 +0200
+++ libgltf/src/Font.cpp 2014-06-26 15:50:57.619684812 +0200
@@ -8,6 +8,7 @@
#include "Font.h"
#include <glm/gtc/matrix_transform.hpp>
+#include <cstdio>
using namespace std;
diff -ur libgltf.org/src/RenderScene.cpp libgltf/src/RenderScene.cpp
--- libgltf.org/src/RenderScene.cpp 2014-06-23 18:49:46.603119797 +0200
+++ libgltf/src/RenderScene.cpp 2014-06-23 19:00:17.583092627 +0200
@@ -1735,28 +1735,29 @@
void RenderScene::setBitZoom(unsigned char* Dstbuffer,
unsigned char* Srcbuffer,
- glTFViewport* pViewport)
+ glTFViewport* pViewport,
+ int bufferDepth )
{
const int width = pViewport->width;
const int height = pViewport->height;
- const int newLineByte = (width * 3 + 3) / 4 * 4;
- const int lineByte = (width * SSAA * 3 + 3) / 4 * 4;
+ const int newLineByte = width * bufferDepth;
+ const int lineByte = width * SSAA * bufferDepth;
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
- for (int k = 0; k < 3; k++)
+ for (int k = 0; k < bufferDepth; k++)
{
long xData = (long)(i * SSAA + 0.5);
long yData = (long)(j * SSAA + 0.5);
if((yData >= 0) && (yData < width * SSAA) &&
(xData >= 0) && (xData < height * SSAA))
{
- *(Dstbuffer + i * newLineByte + j * 3 + k) =
- *(Srcbuffer + xData * lineByte + yData * 3 + k);
+ *(Dstbuffer + i * newLineByte + j * bufferDepth + k) =
+ *(Srcbuffer + xData * lineByte + yData * bufferDepth + k);
}
else
{
- *(Dstbuffer + i * newLineByte + j * 3 + k) = 255;
+ *(Dstbuffer + i * newLineByte + j * bufferDepth + k) = 255;
}
}
}
@@ -1782,12 +1783,20 @@
{
return;
}
- int imageSize = ((width + ((4 - (width % 4)) % 4)) *
- height * 3) + 2;
+
+ int bufferDepth;
+ if( format == GL_RGB || format == GL_BGR )
+ bufferDepth = 3;
+ else if( format == GL_RGBA || format == GL_BGRA )
+ bufferDepth = 4;
+ else
+ return;
+
+ int imageSize = width * height * bufferDepth;
unsigned char *pbuffer = new unsigned char[imageSize];
glReadPixels(0, 0, width, height, format,
GL_UNSIGNED_BYTE, pbuffer);
- setBitZoom(buffer, pbuffer, pViewport);
+ setBitZoom(buffer, pbuffer, pViewport, bufferDepth);
if (pbuffer)
{
delete [] pbuffer;
diff -ur libgltf.org/src/RenderScene.h libgltf/src/RenderScene.h
--- libgltf.org/src/RenderScene.h 2014-06-23 18:49:46.587119798 +0200
+++ libgltf/src/RenderScene.h 2014-06-23 18:59:46.991093944 +0200
@@ -234,7 +234,7 @@
void completeRenderBitmap(glTFViewport* pViewport,
unsigned char* buffer, GLenum format);
void setBitZoom(unsigned char* Dstbuffer,
- unsigned char* Srcbuffer, glTFViewport* pViewport);
+ unsigned char* Srcbuffer, glTFViewport* pViewport, int bufferDepth );
// For animation
void startAnimation();
diff -ur libgltf.org/src/Common.cpp libgltf/src/Common.cpp
--- libgltf.org/src/Common.cpp 2014-06-28 12:30:58.792097436 +0200
+++ libgltf/src/Common.cpp 2014-06-28 12:31:13.884097997 +0200
@@ -550,12 +550,12 @@
/* -- Primitives -- */
Primitives::Primitives()
{
-};
+}
Primitives::~Primitives()
{
mAttributeMap.clear();
-};
+}
void Primitives::setMaterialIndex(std::string materialIndex)
{
diff -ur libgltf.org/libgltf.pc.in libgltf/libgltf.pc.in
--- libgltf.org/libgltf.pc.in 2014-06-27 18:52:24.323562505 +0200
+++ libgltf/libgltf.pc.in 2014-06-27 18:52:48.423561484 +0200
@@ -6,8 +6,7 @@
Name: libgltf-@GLTF_MAJOR_VERSION@.@GLTF_MINOR_VERSION@
Description: Library for rendering glTF models.
Version: @VERSION@
-Requires: glew-1.10.0 glm glu
+Requires: glew
Libs: -L${libdir} -lgltf-@GLTF_MAJOR_VERSION@.@GLTF_MINOR_VERSION@
Cflags: -I${includedir}/libgltf-@GLTF_MAJOR_VERSION@.@GLTF_MINOR_VERSION@
-Requires.private: boost
diff -ur libgltf.org/src/LoadScene.cpp libgltf/src/LoadScene.cpp
--- libgltf.org/src/LoadScene.cpp 2014-06-23 14:55:58.099723870 +0200
+++ libgltf/src/LoadScene.cpp 2014-06-23 14:56:04.399723599 +0200
@@ -149,10 +149,14 @@
return true;
}
-int Parser::parseScene(Scene* pscene)
+void Parser::setScene(Scene* pscene)
+{
+ pScene = pscene;
+}
+
+int Parser::parseScene()
{
int status;
- this->pScene = pscene;
status = this->readBuffers();
if (status < 0)
diff -ur libgltf.org/src/LoadScene.h libgltf/src/LoadScene.h
--- libgltf.org/src/LoadScene.h 2014-06-23 14:55:58.079723871 +0200
+++ libgltf/src/LoadScene.h 2014-06-23 14:56:37.303722182 +0200
@@ -21,7 +21,8 @@
public:
glTFHandle* getFileNameInJson(const std::string& jsonFile);
bool releaseFileName();
- int parseScene(Scene* pscene);
+ void setScene(Scene* pscene);
+ int parseScene();
bool parseJsonFile();
void setJsonInfo(const std::string& sbuffer);
void setJsonInfo(const std::string& direct, const std::string& fileName);
diff -ur libgltf.org/src/RenderScene.cpp libgltf/src/RenderScene.cpp
--- libgltf.org/src/RenderScene.cpp 2014-06-23 14:55:58.099723870 +0200
+++ libgltf/src/RenderScene.cpp 2014-06-23 14:56:07.239723477 +0200
@@ -657,16 +657,15 @@
{
return LIBGLTF_PARSE_JSON_ERROR;
}
- int iStatus = mLoadJson.parseScene(&scene);
+ int iStatus = mLoadJson.parseScene();
return iStatus;
}
int RenderScene::loadScene(Scene& scene, glTFHandle* handle)
{
- scene.setGltfHandle(handle);
try
{
- int iStatus = mLoadJson.parseScene(&scene);
+ int iStatus = mLoadJson.parseScene();
return iStatus;
}
catch (boost::property_tree::ptree_error& e)
@@ -694,7 +693,11 @@
return 0;
}
string tmpFileName(jsonfile->filename);
- return mLoadJson.getFileNameInJson(tmpFileName);
+ glTFHandle* handle = mLoadJson.getFileNameInJson(tmpFileName);
+ pScene = new Scene();
+ pScene->setGltfHandle(handle);
+ mLoadJson.setScene(pScene);
+ return handle;
}
unsigned int RenderScene::bindAttribute(const Attribute* pAttr)
@@ -969,11 +972,6 @@
{
initOpengl();
- pScene = new Scene();
- if (0 == pScene)
- {
- return LIBGLTF_MEMORY_ERROR;
- }
int iResult = loadScene(*pScene, handle);
if (iResult != LIBGLTF_SUCCESS)
{
diff -ur libgltf.org/configure libgltf/configure
--- libgltf.org/configure 2014-06-25 18:41:32.470228670 +0200
+++ libgltf/configure 2014-06-25 18:42:03.922227337 +0200
@@ -15581,15 +15581,18 @@
# =========
# Find boost
# =========
+save_CPPFLAGS=$CPPFLAGS
+CPPFLAGS="$CPPFLAGS $BOOST_CFLAGS"
ac_fn_cxx_check_header_mongrel "$LINENO" "boost/property_tree/json_parser.hpp" "ac_cv_header_boost_property_tree_json_parser_hpp" "$ac_includes_default"
if test "x$ac_cv_header_boost_property_tree_json_parser_hpp" = xyes; then :
- BOOST_CFLAGS=
+
else
as_fn_error $? "boost/property_tree/json_parser.hpp not found. install boost" "$LINENO" 5
fi
+CPPFLAGS=$save_CPPFLAGS
# =========
@@ -15685,14 +15688,17 @@
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
+ save_CPPFLAGS=$CPPFLAGS
+ CPPFLAGS="$CPPFLAGS $GLEW_CFLAGS"
ac_fn_cxx_check_header_mongrel "$LINENO" "GL/glew.h" "ac_cv_header_GL_glew_h" "$ac_includes_default"
if test "x$ac_cv_header_GL_glew_h" = xyes; then :
- GLEW_CFLAGS=
+
else
as_fn_error $? "GL/glew.h not found. install glew" "$LINENO" 5
fi
+ CPPFLAGS=$save_CPPFLAGS
fi
@@ -15707,14 +15713,17 @@
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+save_CPPFLAGS=$CPPFLAGS
+CPPFLAGS="$CPPFLAGS $GLM_CFLAGS"
ac_fn_cxx_check_header_mongrel "$LINENO" "glm/glm.hpp" "ac_cv_header_glm_glm_hpp" "$ac_includes_default"
if test "x$ac_cv_header_glm_glm_hpp" = xyes; then :
- GLM_CFLAGS=
+
else
as_fn_error $? "glm/glm.hpp not found. install glm" "$LINENO" 5
fi
+CPPFLAGS=$save_CPPFLAGS
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
diff -ur libgltf.org/src/FPSCounter.cpp libgltf/src/FPSCounter.cpp
--- libgltf.org/src/FPSCounter.cpp 2014-06-24 18:10:46.317967903 +0200
+++ libgltf/src/FPSCounter.cpp 2014-06-24 18:10:58.629967382 +0200
@@ -104,7 +104,7 @@
++mFrames;
}
- pFont->printFormattedString(pViewport->width - 100, 30, 15, "%d", mFPS);
+ pFont->printFormattedString(pViewport->width - 40, 10, 15, "%d", mFPS);
glEnable(GL_DEPTH_TEST);
}
diff -ur libgltf.org/src/RenderScene.cpp libgltf/src/RenderScene.cpp
--- libgltf.org/src/RenderScene.cpp 2014-06-24 16:53:41.030163890 +0200
+++ libgltf/src/RenderScene.cpp 2014-06-24 16:53:44.406163746 +0200
@@ -1848,8 +1848,6 @@
void RenderScene::startAnimation()
{
- if (bAerialView)
- return;
this->mAnimationPlay = true;
mCurrentTime = 0;
mUpdateTimeOut = 0;
@@ -1858,8 +1856,6 @@
void RenderScene::stopAnimation()
{
- if (bAerialView)
- return;
if (pScene->getSkinSize() != 0)
{
this->mAnimationPlay = false;
@@ -1874,10 +1870,6 @@
roCameraY = glm::mat4(1.0);
pCamera->AerialViewY = 0.0;
bAerialView = false;
- if (bAnimation)
- {
- startAnimation();
- }
if (IsAerialMode)
{
pScene->setUseCameraInJson(true);
@@ -1897,10 +1889,6 @@
roCameraX = glm::mat4(1.0);
roCameraY = glm::mat4(1.0);
//Stop animation.
- if (pScene->getSkinSize() != 0)
- {
- this->mAnimationPlay = false;
- }
bAerialView = true;
if (pScene->getUseCameraInJson())
{
diff -ur libgltf.org/src/RenderScene.cpp libgltf/src/RenderScene.cpp
--- libgltf.org/src/RenderScene.cpp 2014-06-23 21:16:55.134739637 +0200
+++ libgltf/src/RenderScene.cpp 2014-06-23 21:16:58.834739477 +0200
@@ -1976,5 +1976,10 @@
{
bIsTimeAvailable = false;
}
+ if( !mAnimationLoop && mCurrentTime > mDuration )
+ {
+ stopAnimation();
+ setAnimTime(0.0);
+ }
}
diff -ur libgltf.org/Makefile.in libgltf/Makefile.in
--- libgltf.org/Makefile.in 2014-06-25 23:16:52.417528674 +0200
+++ libgltf/Makefile.in 2014-06-25 23:16:56.493528501 +0200
@@ -419,7 +419,7 @@
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status config.h
-$(srcdir)/config.h.in: $(am__configure_deps)
+$(srcdir)/config.h.in:
($(am__cd) $(top_srcdir) && $(AUTOHEADER))
rm -f stamp-h1
touch $@
changeset: 1068:ef62f9d46016
branch: improvement
parent: 1065:ce62a560f347
user: LeiQu
date: Tue Jul 01 14:46:15 2014 +0800
summary: Fix the bug of memory leak
diff -ur libgltf.org/src/LoadScene.cpp libgltf/src/LoadScene.cpp
--- libgltf.org/src/LoadScene.cpp 2014-07-04 16:35:53.702409179 +0200
+++ libgltf/src/LoadScene.cpp 2014-07-04 16:35:59.926408911 +0200
@@ -1052,10 +1052,14 @@
std::string nodeId;
for (; it != itEnd; ++it)
{
- Animation* pAnimation = new Animation();
boost::property_tree::ptree pAnimTree = it->second;
nodeId = parseChannel(pAnimTree);
- parsePara(pAnimTree, pAnimation, nodeId);
+ if (nodeId.empty())
+ {
+ continue;
+ }
+ Animation* pAnimation = new Animation();
+ parsePara(pAnimTree, pAnimation, nodeId);
this->pScene->insertAnimMap(nodeId, pAnimation);
}
return true;
diff -ur libgltf.org/src/Camera.cpp libgltf/src/Camera.cpp
--- libgltf.org/src/Camera.cpp 2014-06-24 17:36:27.870055125 +0200
+++ libgltf/src/Camera.cpp 2014-06-24 17:36:43.514054463 +0200
@@ -243,6 +243,8 @@
if (abs(horizontal) > planar || abs(vertical) > 0.0001)
{
bRotateCameraModel = true;
+ fRotateCameraXSpeed = 0;
+ fRotateCameraYSpeed = 0;
float deltaX = (float)(horizontal * fSensitivity * 0.01f);
float deltaY = (float)(-vertical * fSensitivity * 0.01f);
AerialViewY += -vertical;
diff -ur libgltf.org/src/libgltf.cpp libgltf/src/libgltf.cpp
--- libgltf.org/src/libgltf.cpp 2014-06-23 20:38:35.470838661 +0200
+++ libgltf/src/libgltf.cpp 2014-06-23 20:44:37.042823092 +0200
@@ -235,7 +235,7 @@
RenderScene* renderScene = (RenderScene*)handle->renderer;
if (time <= 0)
{
- renderScene->startAnimation();
+ renderScene->setAnimTime(0.0);
}
else
{
diff -ur libgltf.org/src/Common.cpp libgltf/src/Common.cpp
--- libgltf.org/src/Common.cpp 2014-06-23 20:16:17.746896264 +0200
+++ libgltf/src/Common.cpp 2014-06-23 20:17:50.610892265 +0200
@@ -1037,7 +1037,8 @@
/* -- Scene -- */
Scene::Scene()
- : pRootNode(0)
+ : mDuration(0.0)
+ , pRootNode(0)
, pBuffer(0)
, pGltfHandle(0)
, bUseCameraInJson(false)
diff -ur libgltf.org/src/RenderScene.cpp libgltf/src/RenderScene.cpp
--- libgltf.org/src/RenderScene.cpp 2014-06-23 21:17:51.466737211 +0200
+++ libgltf/src/RenderScene.cpp 2014-06-23 21:23:23.718722904 +0200
@@ -602,6 +602,7 @@
, roCameraX(1.0f), roCameraY(1.0f)
, initCameraLocalMatrix(1.0f),initCameraGlobalMatrix(1.0f)
, bAnimation(true), pTempMatrix(0)
+ , bIsTimeAvailable(false)
{
mLastModelView = glm::mat4(0.0);
#if ENABLE_FPS
diff -ur libgltf.org/src/RenderScene.cpp libgltf/src/RenderScene.cpp
--- libgltf.org/src/RenderScene.cpp 2014-06-23 20:35:06.246847670 +0200
+++ libgltf/src/RenderScene.cpp 2014-06-23 20:35:24.366846890 +0200
@@ -1919,7 +1919,9 @@
double RenderScene::getAnimTime()
{
- return mCurrentTime;
+ errno = 0;
+ double time = fmod(this->mCurrentTime, this->mDuration);
+ return errno == EDOM ? 0.0 : time;
}
void RenderScene::setAnimLoop(int loop)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment