16
Support / Can not clone a striped Object3D
« on: October 17, 2013, 03:34:03 am »Code: [Select]
Object3D src;
src.build();
src.strip();
Object3D obj = src.cloneObject(); // will throw a NullPointerException
Should this behavior be legal?
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Object3D src;
src.build();
src.strip();
Object3D obj = src.cloneObject(); // will throw a NullPointerException
// Assuming the memory limit of process is 24M, and the usage of memory of a app now is 1M/2M(vm), 1M/2M(external)
byte [] tmp = new byte[1024*1024*20]; // 21M/22M, 1M/2M
tmp = null;
system.gc();//1M/22M, 1M/2M, there are 22M vm-memory allocated, 1M used, 21M free;
//trying to allocate 3M-external memory will cause an OOM, because the heap don't shrink for external memory.
new Bitmap(xx); //before android 3.0, bitmap alloacate in external memory.
//or
ByteBuffer.allocateDirect(3*1024*1024);
10-13 18:24:54.970: D/dalvikvm(7816): GC_CONCURRENT freed 700K, 47% free 3582K/6727K, external 5000K/5097K, paused 2ms+2ms
And the decreased\increased memory is external memory. public static Object3D clone(Object3D src, boolean shareVBO, boolean shareTexture){
Object3D ret = src.cloneObject();
if(shareVBO)
ret.shareCompiledData(src);
if(shareTexture)
ret.shareTextureData(src);
return ret;
}
for(int i = 0; i < num; ++i){
clone[i] = clone(srcObj, true, true);
world.addObject(clone[i]);
}
Object3D tree;
for(int i = 0; i < treeNum; ++i){
trees[i] = tree.cloneObject();
trees[i].translate(xxx);
world.addObject(trees[i]);
}
mCar.Translate(0, 50, 0); // move up
SimpleVector d = new SimpleVector(0, -1, 0);
float frontHeight = mRoad.calcMinDistance(front, d, 4 * 30);
float rearHeight = mRoad.calcMinDistance(rear, d, 4 * 30);
WLog.d("front: " + front);
WLog.d("rear: " + rear);
WLog.d("frontHeight: " + frontHeight);
WLog.d("rearHeight: " + rearHeight);
09-15 16:30:56.680: D/Woo3d(4707): frontHeight: 50.03162
09-15 16:30:56.680: D/Woo3d(4707): rearHeight: 1.0E12
09-15 16:30:56.690: D/Woo3d(4707): front: (-2172.8433,50.031296,-1480.5132)
09-15 16:30:56.690: D/Woo3d(4707): rear: (-2172.3599,50.031296,-1543.8423)
09-15 16:30:56.690: D/Woo3d(4707): frontHeight: 50.03162
09-15 16:30:56.690: D/Woo3d(4707): rearHeight: 1.0E12
09-15 16:30:56.710: D/Woo3d(4707): front: (-2172.8623,50.031296,-1477.4586)
09-15 16:30:56.710: D/Woo3d(4707): rear: (-2172.379,50.031296,-1540.7877)
09-15 16:30:56.710: D/Woo3d(4707): frontHeight: 50.03162
09-15 16:30:56.710: D/Woo3d(4707): rearHeight: 50.03162
frameBuffer.blit(mSpeedUpTexture, 0, 0, 0, 0, 128, 64, Constant.screenWidthPx, Constant.screenHeightPx, 0xff, false);
Config.glTransparencyMul = 1 / 255f;
Config.glTransparencyOffset = 0;
Config.farPlane = 7000;
Config.unloadImmediately = true;
Texture.defaultToKeepPixels(false);
Texture.defaultTo4bpp(true);
Texture.defaultToMipmapping(false);
Config.glTransparencyMul = 1 / 255f;
Config.glTransparencyOffset = 0;
Config.farPlane = 7000;
Config.unloadImmediately = true;
Texture.defaultToKeepPixels(false);
Texture.defaultTo4bpp(true);
Texture.defaultToMipmapping(true);
OS: Android 2.3.3\Android 4.2\Android 2.3\Android 4.0
Devices: Tegra2\Mali 400 MP\SGX 531\Adreno 203