Had to change two lines of code to work with Blitz Terrain, here is the affected function:
void TerrainLM::buildLM(){
int memID = this->getFreeMemblock();
dbMakeMemblockFromImage(memID, this->imageID_);
int size = dbGetMemblockSize(1);
DWORD width = dbMemblockDword(1, 0);
DWORD height = dbMemblockDword(1, 4);
DWORD depth = dbMemblockDword(1, 8);
int mem2ID = this->getFreeMemblock();
dbMakeMemblock(mem2ID, size);
dbWriteMemblockDword(mem2ID, 0, width);
dbWriteMemblockDword(mem2ID, 4, height);
dbWriteMemblockDword(mem2ID, 8, depth);
float yRay = this->rayLength_ / 2;
float castX = 0;
float castZ = 0; //Blitzwerks terrain
//float castZ = this->terrainSizeZ_;
float stepX = this->terrainSizeX_ / width;
float stepZ = this->terrainSizeZ_ / height;
for(int i = 0; i < width * height; i++){
DWORD p = dbMemblockDword(memID, (i * 4) + 12);
int r = dbRGBR(p);
int g = dbRGBG(p);
int b = dbRGBB(p);
float intersect = SC_RayCast(0, castX + this->xOffset_, yRay, castZ + this->zOffset_, castX + this->xOffset_, -yRay, castZ + this->zOffset_, 0);
if(intersect){
int brightness = this->shadowStrength_;
r -= brightness;
if(r < 0) r = 0;
g -= brightness;
if(g < 0) g = 0;
b -= brightness;
if(b < 0) b = 0;
}
dbWriteMemblockDword(mem2ID, (i * 4) + 12, dbRGB(r, g, b));
castX += stepX;
if(castX >= this->terrainSizeX_){
castX = 0;
castZ += stepZ; //Blitzwerks terrain
//castZ -= stepZ;
}
}
int image = this->getFreeImage();
dbMakeImageFromMemblock(image, mem2ID);
dbSaveImage("LMTexture.jpg", image);
dbDeleteImage(image);
dbDeleteMemblock(memID);
dbDeleteMemblock(mem2ID);
}