mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-18 10:59:18 -06:00
Fix a couple of point cloud related problems
* crash that occurs when loading an empty dataset * trying to access outside of range when sampling color or size values
This commit is contained in:
@@ -71,6 +71,8 @@ struct Dataset {
|
||||
/// the dataset
|
||||
float maxPositionComponent = 0.f;
|
||||
|
||||
bool isEmpty() const;
|
||||
|
||||
int index(std::string_view variableName) const;
|
||||
bool normalizeVariable(std::string_view variableName);
|
||||
glm::vec2 findValueRange(int variableIndex) const;
|
||||
|
||||
@@ -1072,12 +1072,12 @@ std::vector<float> RenderablePointCloud::createDataSlice() {
|
||||
}
|
||||
|
||||
// Colors
|
||||
if (_hasColorMapFile) {
|
||||
if (_hasColorMapFile && colorParamIndex > -1) {
|
||||
result.push_back(e.data[colorParamIndex]);
|
||||
}
|
||||
|
||||
// Size data
|
||||
if (_hasDatavarSize) {
|
||||
if (_hasDatavarSize && sizeParamIndex > -1) {
|
||||
// @TODO: Consider more detailed control over the scaling. Currently the value
|
||||
// is multiplied with the value as is. Should have similar mapping properties
|
||||
// as the color mapping
|
||||
|
||||
@@ -623,6 +623,10 @@ ColorMap loadFileWithCache(std::filesystem::path path)
|
||||
|
||||
} // namespace color
|
||||
|
||||
bool Dataset::isEmpty() const {
|
||||
return variables.empty() || entries.empty();
|
||||
}
|
||||
|
||||
int Dataset::index(std::string_view variableName) const {
|
||||
for (const Dataset::Variable& v : variables) {
|
||||
if (v.name == variableName) {
|
||||
|
||||
@@ -428,6 +428,10 @@ glm::vec4 ColorMappingComponent::colorFromColorMap(float valueToColorFrom) const
|
||||
}
|
||||
|
||||
void ColorMappingComponent::initializeParameterData(const dataloader::Dataset& dataset) {
|
||||
if (dataset.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize empty ranges based on values in the dataset
|
||||
for (const properties::OptionProperty::Option& option : dataColumn.options()) {
|
||||
int optionIndex = option.value;
|
||||
|
||||
Reference in New Issue
Block a user