Skip to content

Commit

Permalink
accept JData styled NaN in the JSON input for srcdir
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Nov 28, 2021
1 parent a4545a4 commit 0c96fe8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/mcx_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1824,8 +1824,12 @@ int mcx_loadjson(cJSON *root, Config *cfg){
cfg->srcdir.x=subitem->child->valuedouble;
cfg->srcdir.y=subitem->child->next->valuedouble;
cfg->srcdir.z=subitem->child->next->next->valuedouble;
if(subitem->child->next->next->next)
cfg->srcdir.w=subitem->child->next->next->next->valuedouble;
if(subitem->child->next->next->next){
if(cJSON_IsString(subitem->child->next->next->next) && strcmp(subitem->child->next->next->next->valuestring,"_NaN_")==0)
cfg->srcdir.w=-(0.0 / 0.0);
else
cfg->srcdir.w=subitem->child->next->next->next->valuedouble;
}
}
if(!cfg->issrcfrom0){
cfg->srcpos.x--;cfg->srcpos.y--;cfg->srcpos.z--; /*convert to C index, grid center*/
Expand Down

0 comments on commit 0c96fe8

Please sign in to comment.