2309 |
// get the corresponding velocity table from the table map or create & calculate that table if it doesn't exist yet |
// get the corresponding velocity table from the table map or create & calculate that table if it doesn't exist yet |
2310 |
double* DimensionRegion::GetVelocityTable(curve_type_t curveType, uint8_t depth, uint8_t scaling) |
double* DimensionRegion::GetVelocityTable(curve_type_t curveType, uint8_t depth, uint8_t scaling) |
2311 |
{ |
{ |
2312 |
|
// sanity check input parameters |
2313 |
|
// (fallback to some default parameters on ill input) |
2314 |
|
switch (curveType) { |
2315 |
|
case curve_type_nonlinear: |
2316 |
|
case curve_type_linear: |
2317 |
|
if (depth > 4) { |
2318 |
|
printf("Warning: Invalid depth (0x%x) for velocity curve type (0x%x).\n", depth, curveType); |
2319 |
|
depth = 0; |
2320 |
|
scaling = 0; |
2321 |
|
} |
2322 |
|
break; |
2323 |
|
case curve_type_special: |
2324 |
|
if (depth > 5) { |
2325 |
|
printf("Warning: Invalid depth (0x%x) for velocity curve type 'special'.\n", depth); |
2326 |
|
depth = 0; |
2327 |
|
scaling = 0; |
2328 |
|
} |
2329 |
|
break; |
2330 |
|
case curve_type_unknown: |
2331 |
|
default: |
2332 |
|
printf("Warning: Unknown velocity curve type (0x%x).\n", curveType); |
2333 |
|
curveType = curve_type_linear; |
2334 |
|
depth = 0; |
2335 |
|
scaling = 0; |
2336 |
|
break; |
2337 |
|
} |
2338 |
|
|
2339 |
double* table; |
double* table; |
2340 |
uint32_t tableKey = (curveType<<16) | (depth<<8) | scaling; |
uint32_t tableKey = (curveType<<16) | (depth<<8) | scaling; |
2341 |
if (pVelocityTables->count(tableKey)) { // if key exists |
if (pVelocityTables->count(tableKey)) { // if key exists |
3261 |
if (file->GetAutoLoad()) { |
if (file->GetAutoLoad()) { |
3262 |
for (uint i = 0; i < DimensionRegions; i++) { |
for (uint i = 0; i < DimensionRegions; i++) { |
3263 |
uint32_t wavepoolindex = _3lnk->ReadUint32(); |
uint32_t wavepoolindex = _3lnk->ReadUint32(); |
3264 |
if (file->pWavePoolTable) pDimensionRegions[i]->pSample = GetSampleFromWavePool(wavepoolindex); |
if (file->pWavePoolTable && pDimensionRegions[i]) |
3265 |
|
pDimensionRegions[i]->pSample = GetSampleFromWavePool(wavepoolindex); |
3266 |
} |
} |
3267 |
GetSample(); // load global region sample reference |
GetSample(); // load global region sample reference |
3268 |
} |
} |
4769 |
RegionList::iterator end = pRegions->end(); |
RegionList::iterator end = pRegions->end(); |
4770 |
for (; iter != end; ++iter) { |
for (; iter != end; ++iter) { |
4771 |
gig::Region* pRegion = static_cast<gig::Region*>(*iter); |
gig::Region* pRegion = static_cast<gig::Region*>(*iter); |
4772 |
for (int iKey = pRegion->KeyRange.low; iKey <= pRegion->KeyRange.high; iKey++) { |
const int low = std::max(int(pRegion->KeyRange.low), 0); |
4773 |
|
const int high = std::min(int(pRegion->KeyRange.high), 127); |
4774 |
|
for (int iKey = low; iKey <= high; iKey++) { |
4775 |
RegionKeyTable[iKey] = pRegion; |
RegionKeyTable[iKey] = pRegion; |
4776 |
} |
} |
4777 |
} |
} |