[bug] crash on mapsplitter sdk

waldi

04-10-2005 15:50:37

another crash...
using ogre 1.0.5, and sdk compatible src of PLSM2 (http://tuan.kuranes.free.fr/paginglandscape.zip).

Added resource location 'Media/terragen16bits' of type 'FileSystem' to resource group 'PLSM2'
alpes.raw
normal Map Calc :
alpes.HN.raw
Map Calc :
alpes.Base.png
alpes.Coverage.png
alpes.Alpha.0.png
alpes.Alpha.1.png
alpes.Alpha.2.png
alpes.Alpha.3.png
Horizon Map Calc : alpes.HS.png
alpes.L.png
gcanyon_height_4k2k.png
normal Map Calc :
gcanyon_height_4k2k.HN.png
gcanyon_texture_4k2k..png
Map Calc :
gcanyon_height_4k2k.Base.png
gcanyon_height_4k2k.Coverage.png
gcanyon_height_4k2k.Alpha.0.png
gcanyon_height_4k2k.Alpha.1.png
gcanyon_height_4k2k.Alpha.2.png
gcanyon_height_4k2k.Alpha.3.png
Horizon Map Calc : gcanyon_height_4k2k.HS.png
gcanyon_height_4k2k.L.png
ps_height_1k.png
normal Map Calc :
ps_height_1k.HN.png
ps_texture_1k..png
Segmentation fault (core dumped)


maybe this helps:

#0 0xb71d007f in memcpy () from /lib/tls/libc.so.6
(gdb) bt
#0 0xb71d007f in memcpy () from /lib/tls/libc.so.6
#1 0x0805a03d in Ogre::MapSplitter::BlitSubImage (this=0xbff73540, BaseData=0xb3263008 "â<", OutData=0xb3863008 "â<", x=0,
y=0, tile_width=1026, tile_height=1026, tile_width_copy=1026, tile_height_copy=1026, base_width=1025, bpp=3)
at MapSplitter.cpp:697
#2 0x0805c014 in Ogre::MapSplitter::SplitCurrentMap (this=0xbff73540, filename=@0xbff734a0, page_size=1026)
at MapSplitter.cpp:992
#3 0x0805670d in Ogre::MapSplitter::saveAndSplitMap (this=0xbff73540, filename=@0xbff734a0, newImage=0xbff73450)
at MapSplitter.cpp:109
#4 0x0806131e in Ogre::MapUtil::processOneMap (this=0x8092a70) at MapUtil.cpp:646
#5 0x0805e5ce in Ogre::MapUtil::process (this=0x8092a70) at MapUtil.cpp:219
#6 0x0805ce77 in main (argc=1, argv=0xbff739f4) at MapTool.cpp:46
(gdb) fr 1
#1 0x0805a03d in Ogre::MapSplitter::BlitSubImage (this=0xbff73540, BaseData=0xb3263008 "â<", OutData=0xb3863008 "â<", x=0,
y=0, tile_width=1026, tile_height=1026, tile_width_copy=1026, tile_height_copy=1026, base_width=1025, bpp=3)
at MapSplitter.cpp:697
697 memcpy (dest, src, dest_shift_copy);
(gdb) p dest
$1 = (uchar *) 0xb3b6540e ""
(gdb) p src
$2 = (const uchar *) 0xb356480b ""
(gdb) p dest_shift_copy
$3 = 3078
(gdb) p dest[3077]
$4 = 0 '\0'
(gdb) p src[3077]
Cannot access memory at address 0xb3565410
(gdb) p *src
$5 = 0 '\0'
(gdb) l
682 uchar * const OutData,
683 const uint x, const uint y,
684 const uint tile_width, const uint tile_height,
685 const uint tile_width_copy, const uint tile_height_copy,
686 const uint base_width,
687 const uint bpp)
688 {
689 const uint src_shift = bpp * base_width;
690 const uint dest_shift = bpp * tile_width;
691 const uint dest_shift_copy = bpp * tile_width_copy;
692
693 const uchar *src = BaseData + y*src_shift + bpp*x;
694 uchar *dest = OutData;
695 for (uint j = 0; j < tile_height_copy; j++)
696 {
697 memcpy (dest, src, dest_shift_copy);
698 dest += dest_shift;
699 src += src_shift;
700 }
701 }
702 //-----------------------------------------------------------------------
703 void MapSplitter::SplitAndSpaceCurrentMap(const String &filename,
704 const int tile_spacing,
705 const int page_size)
706 {
707 const uint base_image_width = static_cast <uint> (mCurrentMap->getWidth ());
708 const uint base_image_height = static_cast <uint> (mCurrentMap->getHeight ());
709 const uint base_image_bypp = static_cast < uint > (PixelUtil::getNumElemBytes (mCurrentMap->getFormat ()));
710
711
(gdb) p j
$6 = 1025
(gdb) p tile_height_copy
$7 = 1026

tuan kuranes

04-10-2005 15:59:44

Tile size is a bit huge here, as big as page size ?

do you use originial ps_height1k.gen.cfg ?
If you made changes, can you post them here ?

waldi

04-10-2005 16:16:39

i'm using PLSM2_binary.zip with datasrc.zip unpacked in Media/datasrc/
...just replaced the binaries and plugins.cfg

ps_height_1k.gen.cfg? ...i don't have that stuff...

zeus:/usr/local/src/ogre/non_CVS/demo/Media# find -name "ps_*"
./datasrcs/ps_height_1k.png
./datasrcs/ps_texture_1k.png
./ps_height_1k
./ps_height_1k/ps_height_1k.0.0.png
./ps_height_1k/ps_height_1k.Small.png
./ps_height_1k/ps_texture_1k.Small.png
./ps_height_1k/ps_height_1k.HN.0.0.png
./ps_height_1k.cfg

tuan kuranes

04-10-2005 16:18:14

sorry, it's puget_1k.gen.cfg in datasrc directory.

waldi

04-10-2005 16:24:13

no changes...

### WARNING
## read Data2dLoader.txt, Mapsplitterreadme.txt
## in ogreaddons paginglandscape root folder before anything here.
##

# resource group name
GroupName=PLSM2

# Base file name for the landscape heightfield data
# The file name MUST be LandScapeFileName.LandScapeExtension (ex: landscape.png)
LandScapeFileName=ps_height_1k
LandScapeExtension=png
#
#

# for textures. (raw is possible but raw texture isn't supported directly for Ogre so it's experimental)
# jpg or anything else ?
## For heightmap only
LandScapeExportExtension=png
## For Texturing heightmap only (all but pure heightmap data.)
TextureExtension=png

#
# If you intend to use it with
# Paginglandscape scenemanager Paged=yes
# or with Terrain scenemanager Paged=no
Paged=yes


#
# Scale values
ScaleX=1
ScaleY=1
ScaleZ=1


# Directory where to store files
# absolute or related to maptool directory
# if OutDirectory=LandScapeFileName will use filename of your input data
OutDirectory=Media/LandScapeFileName



###########
###########
# Options only useful for paging landscape scene manager paged=yes
#
# Size of the Heightfiled in pixels (must be 2^n + 1)
PageSize=257
TileSize=65



# Especialized 2D data loader.
# Currently the only available loaders are
# 'HeightField', 'HeightFieldTC' and 'SplineField'.
# More to come. (For Terrainscene (paged =yes HeightField is used by default)
#

Data2DFormat=HeightField
#Data2DFormat=HeightFieldTC

# The HeightField TC is a compresed format and need to know the value range from where the
# heightfield file was compresed (if it's paged, and Data2DFormat=HeightFieldTC)
MaxValue=3000
MinValue=0

# don't work with mapsplitter for now
#Data2DFormat=SplineField


#############COLOR MAP

# Map that user have generated before, using terragen,
#and want to split or to light (Textureformat=Image)
ColorMapName=ps_texture_1k.png
# Split your color map
ColorMapSplit=yes
# same but with modulated with light
LitColorMapSplit=no


#########HEIGTHMAPS
#
# What to generate
# HERE IS WHERE YOU SPECIFY YOUR NEEDS
#
# If you want your map to be infinitizable
InfiniteMap=no

# If you want smooth your heightmap
HeightMapBlurFactor=0.0f
# Make sure heights use the whole range (0-255 or 0-65535)
Equalize=no
# usual 8 bits HeightMap (terrain scene manager)
HeightMap=yes
# Creates a MiniMap (width=numpageswidth*numtiles and height=numpagesheight*numtiles)
# (as the name don't tell, it's creates a file.small.png image...)
MiniMap=yes
MiniMapWidth=512
MiniMapHeight=512

#########NORMALS
#
# Normal Map
NormalMap=no
# RGB as XYZ normal and Alpha as 8 bits HeightMap (paging scene manager)
HeightNormalMap=yes


#
# Map that can be used on not too much scaled terrain or old hardware
# no enough texture units or too slow multipass (Textureformat=Image)
ColorMapGenerated=no
# same but with modulated with light
LitColorMapGenerated=no

#########SPLATTING

#
# Splatting
# We are allowing 4 textures to build the terrain texture
# MaterialHeight to change alpha weights ( using percentage )
MaterialHeight1=12
MaterialHeight2=60

#needs to be in maptool directory
SplatFilename0=splatting_snow.jpg
SplatFilename1=splatting_sand.jpg
SplatFilename2=splatting_grass.jpg
SplatFilename3=splatting_rock.jpg

# Base map for big scale maps, used for long distance instead of splatting
# (Textureformat=Base and splattingX)
BaseMap=yes
# same but with modulated with light
LitBaseMap=no
#
#### Maps used for splattings
#
# coverage is RGBA, each channel has info for 1 splat
# (Textureformat=splatting3)
CoverageMap=yes
#
# generate 1 alpha map per splatting
# (Textureformat=splatting2) When Ogre has support fo PF_A8
AlphaMaps=yes
# same but with black RGB data until Ogre has support fo PF_A8
AlphaSplatRGBAMaps=no
# same but with light in RGB data
AlphaSplatLightMaps=no
#
# generate 1 RGB map per splatting gray level instead of alpha
# (mainly debug, but can be used to get some splatting in GL version one day)
RGBMaps=no


####################LIGHTING

# Shadows on terrains (lightmap is used, shadowmap is mainly for debugging)
# (Textureformat=splatting4)
LightMap=no
ShadowMap=no

Sunx=0.0f
Suny=0.88f
Sunz=0.47f

Ambient=0.5f
Diffuse=0.5f
Blur=0.0f

######## Real-Time LIGHTING

# Horizon Mapping (real-time lightmapping shader with V2 pixel shader)
# LONG TIME COMPUTATION
HorizonMap=no
# map elevation lookup table independant, so generate once and rename according to your materials.
ElevationMap=no

# trick Real-Time mapping : sun is constricted in Z axis. Fastest Horizon mapping possible with and without shaders.
ZHorizon=yes


########VISIBILITY
#
# PVS (potential visibility set)
# VERY LONG TIME COMPUTATION
# Will be used to decide if terrain patches are visible or hidden by some hills
# or mountains (not used for now in plugin's code)
# could be used for AI to know if something is visible from a point to another...
# so perhaps a thing that can lies in scenemanagers...
PVSMap=no

tuan kuranes

04-10-2005 16:31:08

ok.
So there's a bug somewhere.
Can you try the same map using mapsplitter but disabling batch mode

waldi

04-10-2005 16:48:01

maptool.cfg:
#DefaultMap=grand_canyon
DefaultMap=puget_sound

puget_sound=puget_1k.gen
grand_canyon=gcanyon_height_4k2k.gen
terragen_genrated=terragen16bits.gen
European_Alpes=Alpes.gen

# resource group name
GroupName=PLSM2
#do you want to run it on all maps listed here
BatchMode=no


...works, but if i run the demo it crashes:
17:33:36: PLSM2 : Cannot find map named ps_height_1k.2.2.png17:33:36: PLSM2 : Cannot find map named ps_height_1k.2.1.png
17:33:36: PLSM2 : Cannot find map named ps_height_1k.1.2.png17:33:36: PLSM2 : Cannot find map named ps_height_1k.1.1.png
17:33:36: PLSM2 : Cannot find map named ps_height_1k.3.2.png17:33:36: PLSM2 : Cannot find map named ps_height_1k.2.3.png
17:33:37: PLSM2 : Cannot find map named ps_height_1k.3.1.png17:33:37: PLSM2 : Cannot find map named ps_height_1k.1.3.png
17:33:37: PLSM2 : Cannot find map named ps_height_1k.2.0.png17:33:37: PLSM2 : Cannot find map named ps_height_1k.0.2.png
17:33:37: PLSM2 : Cannot find map named ps_height_1k.1.0.png17:33:37: PLSM2 : Cannot find map named ps_height_1k.0.1.png
17:33:37: PLSM2 : Cannot find map named ps_height_1k.3.3.png17:33:37: PLSM2 : Cannot find map named ps_height_1k.3.0.png
17:33:37: PLSM2 : Cannot find map named ps_height_1k.0.3.png17:33:37: An exception has been thrown!
-----------------------------------
Details:-----------------------------------
Error #: 4Function: PagingLandScapeData2D_HeightField::_load
Description: Error: Invalid heightmap size : 1026,1026. Should be 2^n+1, 2^n+1.File: OgrePagingLandScapeData2D_HeightField.cpp
Line: 231



shouldn't there be 8 ps_height_1k.x.y.png files each 257x257 !?
zeus:/usr/local/src/ogre/non_CVS/demo/Media/ps_height_1k# ls -al
total 165500
drwxr-xr-x 2 root root 4096 Oct 4 17:25 .
drwxr-xr-x 11 root staff 4096 Oct 4 17:31 ..
-rw------- 1 root root 159301632 Oct 4 16:38 core
-rw-r--r-- 1 root root 327407 Oct 4 17:32 ps_height_1k.0.0.png
-rw-r--r-- 1 root root 464120 Oct 4 17:32 ps_height_1k.Alpha.0.0.0.png
-rw-r--r-- 1 root root 634225 Oct 4 17:32 ps_height_1k.Alpha.1.0.0.png
-rw-r--r-- 1 root root 727473 Oct 4 17:32 ps_height_1k.Alpha.2.0.0.png
-rw-r--r-- 1 root root 1571 Oct 4 17:32 ps_height_1k.Alpha.3.0.0.png
-rw-r--r-- 1 root root 1646788 Oct 4 17:32 ps_height_1k.Base.0.0.png
-rw-r--r-- 1 root root 1984159 Oct 4 17:32 ps_height_1k.Coverage.0.0.png
-rw-r--r-- 1 root root 2574096 Oct 4 17:32 ps_height_1k.HN.0.0.png
-rw-r--r-- 1 root root 1007300 Oct 4 17:32 ps_height_1k.HS.0.0.png
-rw-r--r-- 1 root root 453784 Oct 4 17:32 ps_height_1k.L.0.0.png
-rw-r--r-- 1 root root 92972 Oct 4 17:32 ps_height_1k.Small.png
-rw-r--r-- 1 root root 1610948 Oct 4 17:32 ps_texture_1k.0.0.png
-rw-r--r-- 1 root root 491822 Oct 4 17:32 ps_texture_1k.Small.png
zeus:/usr/local/src/ogre/non_CVS/demo/Media/ps_height_1k# file ps_height_1k.0.0.png
ps_height_1k.0.0.png: PNG image data, 1026 x 1026, 8-bit grayscale, non-interlaced
zeus:/usr/local/src/ogre/non_CVS/demo/Media/ps_height_1k#

tuan kuranes

04-10-2005 17:03:10

yes.
it should.

did you try commenting the blur pass in maputil (even if you don't use it) ?

waldi

04-10-2005 17:07:52

#if 0
const Real Blur = mHeightMapBlurFactor;
if (Blur > 0.0f)
{
Convolver *c = new Convolver (int (Blur));
c->blurReal (mData, mWidth, mHeight);
}
#endif


...didn't help :(

tuan kuranes

04-10-2005 17:16:46

mmhh.
You could either debug and find the problem or Perhaps you should wait a bit the backport of cvs mapsplitter to sdk compatible mapsplitter. (or get the port from barnabe42...)

waldi

04-10-2005 18:22:45

any1 got it running on linux??
...just wondering cuz:

void CNoise::Init(const uint nDimensions, const uint nSeed)
{
m_nDimensions = MIN(nDimensions, MAX_DIMENSIONS);
CRandom r(nSeed);

uint i, j;
for(i=0; i<256; i++)
{
m_nMap[i] = i;
for(j=0; j<m_nDimensions; j++)
m_nBuffer[i][j] = (float)r.RandomD(-0.5, 0.5);
Normalize(m_nBuffer[i], m_nDimensions);
}

uchar k;
while(--i)
{
const int l = r.RandomI(0, 255);
SWAP(m_nMap[i], m_nMap[j], k);
}
_fpreset(); // Bug in CRandom! Causes messed up floating point operations!
}


_fpreset() doesn't exist on linux

tuan kuranes

04-10-2005 20:08:11

try this :

#ifdefined(__GNUC__) && defined(__i386__)

#include <fpu_control.h>

inline void _fpreset()
{
__volatile unsigned short int __cw = _FPU_DEFAULT;
__asm __volatile ("fldcw %0" : : "m" (__cw));
}
#endif



more info here :
http://homepage.mac.com/chibaf/math/oct ... rol_e.html

waldi

05-10-2005 12:49:03

didn't help :( ...trying CVS