source/blender/blenloader/intern/readfile.c
static ModifierData *modifier_replace_with_fluid(FileData *fd,
                                                 Object *object,
                                                 ListBase *modifiers,
                                                 ModifierData *old_modifier_data)
{
  ModifierData *new_modifier_data = BKE_modifier_new(eModifierType_Fluid);
  FluidModifierData *fluid_modifier_data = (FluidModifierData *)new_modifier_data;

  if (old_modifier_data->type == eModifierType_Fluidsim) {
    FluidsimModifierData *old_fluidsim_modifier_data = (FluidsimModifierData *)old_modifier_data;
    FluidsimSettings *old_fluidsim_settings = newdataadr(fd, old_fluidsim_modifier_data->fss);
    switch (old_fluidsim_settings->type) {
      case OB_FLUIDSIM_ENABLE:
        modifier_ensure_type(fluid_modifier_data, 0);
        break;
      case OB_FLUIDSIM_DOMAIN:
        modifier_ensure_type(fluid_modifier_data, MOD_FLUID_TYPE_DOMAIN);
        BKE_fluid_domain_type_set(object, fluid_modifier_data->domain, FLUID_DOMAIN_TYPE_LIQUID);
        break;
      case OB_FLUIDSIM_FLUID:
        modifier_ensure_type(fluid_modifier_data, MOD_FLUID_TYPE_FLOW);
        BKE_fluid_flow_type_set(object, fluid_modifier_data->flow, FLUID_FLOW_TYPE_LIQUID);
        /* No need to emit liquid far away from surface. */
        fluid_modifier_data->flow->surface_distance = 0.0f;
        break;
      case OB_FLUIDSIM_OBSTACLE:
        modifier_ensure_type(fluid_modifier_data, MOD_FLUID_TYPE_EFFEC);
        BKE_fluid_effector_type_set(
            object, fluid_modifier_data->effector, FLUID_EFFECTOR_TYPE_COLLISION);
        break;
      case OB_FLUIDSIM_INFLOW:
        modifier_ensure_type(fluid_modifier_data, MOD_FLUID_TYPE_FLOW);
        BKE_fluid_flow_type_set(object, fluid_modifier_data->flow, FLUID_FLOW_TYPE_LIQUID);
        BKE_fluid_flow_behavior_set(object, fluid_modifier_data->flow, FLUID_FLOW_BEHAVIOR_INFLOW);
        /* No need to emit liquid far away from surface. */
        fluid_modifier_data->flow->surface_distance = 0.0f;
        break;
      case OB_FLUIDSIM_OUTFLOW:
        modifier_ensure_type(fluid_modifier_data, MOD_FLUID_TYPE_FLOW);
        BKE_fluid_flow_type_set(object, fluid_modifier_data->flow, FLUID_FLOW_TYPE_LIQUID);
        BKE_fluid_flow_behavior_set(
            object, fluid_modifier_data->flow, FLUID_FLOW_BEHAVIOR_OUTFLOW);
        break;
      case OB_FLUIDSIM_PARTICLE:
        /* "Particle" type objects not being used by Mantaflow fluid simulations.
         * Skip this object, secondary particles can only be enabled through the domain object. */
        break;
      case OB_FLUIDSIM_CONTROL:
        /* "Control" type objects not being used by Mantaflow fluid simulations.
         * Use guiding type instead which is similar. */
        modifier_ensure_type(fluid_modifier_data, MOD_FLUID_TYPE_EFFEC);
        BKE_fluid_effector_type_set(
            object, fluid_modifier_data->effector, FLUID_EFFECTOR_TYPE_GUIDE);
        break;
    }
  }
  else if (old_modifier_data->type == eModifierType_Smoke) {
    SmokeModifierData *old_smoke_modifier_data = (SmokeModifierData *)old_modifier_data;
    modifier_ensure_type(fluid_modifier_data, old_smoke_modifier_data->type);
    if (fluid_modifier_data->type == MOD_FLUID_TYPE_DOMAIN) {
      BKE_fluid_domain_type_set(object, fluid_modifier_data->domain, FLUID_DOMAIN_TYPE_GAS);
    }
    else if (fluid_modifier_data->type == MOD_FLUID_TYPE_FLOW) {
      BKE_fluid_flow_type_set(object, fluid_modifier_data->flow, FLUID_FLOW_TYPE_SMOKE);
    }
    else if (fluid_modifier_data->type == MOD_FLUID_TYPE_EFFEC) {
      BKE_fluid_effector_type_set(
          object, fluid_modifier_data->effector, FLUID_EFFECTOR_TYPE_COLLISION);
    }
  }

  /* Replace modifier data in the stack. */
  new_modifier_data->next = old_modifier_data->next;
  new_modifier_data->prev = old_modifier_data->prev;
  if (new_modifier_data->prev != NULL) {
    new_modifier_data->prev->next = new_modifier_data;
  }
  if (new_modifier_data->next != NULL) {
    new_modifier_data->next->prev = new_modifier_data;
  }
  if (modifiers->first == old_modifier_data) {
    modifiers->first = new_modifier_data;
  }
  if (modifiers->last == old_modifier_data) {
    modifiers->last = new_modifier_data;
  }

  /* Free old modifier data. */
  MEM_freeN(old_modifier_data);

  return new_modifier_data;
}
/**
 * \note The old_modifier_data is NOT linked.
 * This means that in order to access sub-data pointers #newdataadr is to be used.
 */
\note The old_modifier_data is NOT linked.
This means that in order to access sub-data pointers #newdataadr is to be used.
\ note The old_modifier_data is NOT linked . This means that in order to access sub - data pointers #newdataadr is to be used .
static ModifierData *modifier_replace_with_fluid(FileData *fd,
                                                 Object *object,
                                                 ListBase *modifiers,
                                                 ModifierData *old_modifier_data)
{
  ModifierData *new_modifier_data = BKE_modifier_new(eModifierType_Fluid);
  FluidModifierData *fluid_modifier_data = (FluidModifierData *)new_modifier_data;
  if (old_modifier_data->type == eModifierType_Fluidsim) {
    FluidsimModifierData *old_fluidsim_modifier_data = (FluidsimModifierData *)old_modifier_data;
    FluidsimSettings *old_fluidsim_settings = newdataadr(fd, old_fluidsim_modifier_data->fss);
    switch (old_fluidsim_settings->type) {
      case OB_FLUIDSIM_ENABLE:
        modifier_ensure_type(fluid_modifier_data, 0);
        break;
      case OB_FLUIDSIM_DOMAIN:
        modifier_ensure_type(fluid_modifier_data, MOD_FLUID_TYPE_DOMAIN);
        BKE_fluid_domain_type_set(object, fluid_modifier_data->domain, FLUID_DOMAIN_TYPE_LIQUID);
        break;
      case OB_FLUIDSIM_FLUID:
        modifier_ensure_type(fluid_modifier_data, MOD_FLUID_TYPE_FLOW);
        BKE_fluid_flow_type_set(object, fluid_modifier_data->flow, FLUID_FLOW_TYPE_LIQUID);
        fluid_modifier_data->flow->surface_distance = 0.0f;
        break;
      case OB_FLUIDSIM_OBSTACLE:
        modifier_ensure_type(fluid_modifier_data, MOD_FLUID_TYPE_EFFEC);
        BKE_fluid_effector_type_set(
            object, fluid_modifier_data->effector, FLUID_EFFECTOR_TYPE_COLLISION);
        break;
      case OB_FLUIDSIM_INFLOW:
        modifier_ensure_type(fluid_modifier_data, MOD_FLUID_TYPE_FLOW);
        BKE_fluid_flow_type_set(object, fluid_modifier_data->flow, FLUID_FLOW_TYPE_LIQUID);
        BKE_fluid_flow_behavior_set(object, fluid_modifier_data->flow, FLUID_FLOW_BEHAVIOR_INFLOW);
        fluid_modifier_data->flow->surface_distance = 0.0f;
        break;
      case OB_FLUIDSIM_OUTFLOW:
        modifier_ensure_type(fluid_modifier_data, MOD_FLUID_TYPE_FLOW);
        BKE_fluid_flow_type_set(object, fluid_modifier_data->flow, FLUID_FLOW_TYPE_LIQUID);
        BKE_fluid_flow_behavior_set(
            object, fluid_modifier_data->flow, FLUID_FLOW_BEHAVIOR_OUTFLOW);
        break;
      case OB_FLUIDSIM_PARTICLE:
        break;
      case OB_FLUIDSIM_CONTROL:
        modifier_ensure_type(fluid_modifier_data, MOD_FLUID_TYPE_EFFEC);
        BKE_fluid_effector_type_set(
            object, fluid_modifier_data->effector, FLUID_EFFECTOR_TYPE_GUIDE);
        break;
    }
  }
  else if (old_modifier_data->type == eModifierType_Smoke) {
    SmokeModifierData *old_smoke_modifier_data = (SmokeModifierData *)old_modifier_data;
    modifier_ensure_type(fluid_modifier_data, old_smoke_modifier_data->type);
    if (fluid_modifier_data->type == MOD_FLUID_TYPE_DOMAIN) {
      BKE_fluid_domain_type_set(object, fluid_modifier_data->domain, FLUID_DOMAIN_TYPE_GAS);
    }
    else if (fluid_modifier_data->type == MOD_FLUID_TYPE_FLOW) {
      BKE_fluid_flow_type_set(object, fluid_modifier_data->flow, FLUID_FLOW_TYPE_SMOKE);
    }
    else if (fluid_modifier_data->type == MOD_FLUID_TYPE_EFFEC) {
      BKE_fluid_effector_type_set(
          object, fluid_modifier_data->effector, FLUID_EFFECTOR_TYPE_COLLISION);
    }
  }
  new_modifier_data->next = old_modifier_data->next;
  new_modifier_data->prev = old_modifier_data->prev;
  if (new_modifier_data->prev != NULL) {
    new_modifier_data->prev->next = new_modifier_data;
  }
  if (new_modifier_data->next != NULL) {
    new_modifier_data->next->prev = new_modifier_data;
  }
  if (modifiers->first == old_modifier_data) {
    modifiers->first = new_modifier_data;
  }
  if (modifiers->last == old_modifier_data) {
    modifiers->last = new_modifier_data;
  }
  MEM_freeN(old_modifier_data);
  return new_modifier_data;
}
static ModifierData * modifier_replace_with_fluid ( FileData * fd , Object * object , ListBase * modifiers , ModifierData * old_modifier_data ) { ModifierData * new_modifier_data = BKE_modifier_new ( eModifierType_Fluid ) ; FluidModifierData * fluid_modifier_data = ( FluidModifierData * ) new_modifier_data ; if ( old_modifier_data -> type == eModifierType_Fluidsim ) { FluidsimModifierData * old_fluidsim_modifier_data = ( FluidsimModifierData * ) old_modifier_data ; FluidsimSettings * old_fluidsim_settings = newdataadr ( fd , old_fluidsim_modifier_data -> fss ) ; switch ( old_fluidsim_settings -> type ) { case OB_FLUIDSIM_ENABLE : modifier_ensure_type ( fluid_modifier_data , 0 ) ; break ; case OB_FLUIDSIM_DOMAIN : modifier_ensure_type ( fluid_modifier_data , MOD_FLUID_TYPE_DOMAIN ) ; BKE_fluid_domain_type_set ( object , fluid_modifier_data -> domain , FLUID_DOMAIN_TYPE_LIQUID ) ; break ; case OB_FLUIDSIM_FLUID : modifier_ensure_type ( fluid_modifier_data , MOD_FLUID_TYPE_FLOW ) ; BKE_fluid_flow_type_set ( object , fluid_modifier_data -> flow , FLUID_FLOW_TYPE_LIQUID ) ; fluid_modifier_data -> flow -> surface_distance = 0.0f ; break ; case OB_FLUIDSIM_OBSTACLE : modifier_ensure_type ( fluid_modifier_data , MOD_FLUID_TYPE_EFFEC ) ; BKE_fluid_effector_type_set ( object , fluid_modifier_data -> effector , FLUID_EFFECTOR_TYPE_COLLISION ) ; break ; case OB_FLUIDSIM_INFLOW : modifier_ensure_type ( fluid_modifier_data , MOD_FLUID_TYPE_FLOW ) ; BKE_fluid_flow_type_set ( object , fluid_modifier_data -> flow , FLUID_FLOW_TYPE_LIQUID ) ; BKE_fluid_flow_behavior_set ( object , fluid_modifier_data -> flow , FLUID_FLOW_BEHAVIOR_INFLOW ) ; fluid_modifier_data -> flow -> surface_distance = 0.0f ; break ; case OB_FLUIDSIM_OUTFLOW : modifier_ensure_type ( fluid_modifier_data , MOD_FLUID_TYPE_FLOW ) ; BKE_fluid_flow_type_set ( object , fluid_modifier_data -> flow , FLUID_FLOW_TYPE_LIQUID ) ; BKE_fluid_flow_behavior_set ( object , fluid_modifier_data -> flow , FLUID_FLOW_BEHAVIOR_OUTFLOW ) ; break ; case OB_FLUIDSIM_PARTICLE : break ; case OB_FLUIDSIM_CONTROL : modifier_ensure_type ( fluid_modifier_data , MOD_FLUID_TYPE_EFFEC ) ; BKE_fluid_effector_type_set ( object , fluid_modifier_data -> effector , FLUID_EFFECTOR_TYPE_GUIDE ) ; break ; } } else if ( old_modifier_data -> type == eModifierType_Smoke ) { SmokeModifierData * old_smoke_modifier_data = ( SmokeModifierData * ) old_modifier_data ; modifier_ensure_type ( fluid_modifier_data , old_smoke_modifier_data -> type ) ; if ( fluid_modifier_data -> type == MOD_FLUID_TYPE_DOMAIN ) { BKE_fluid_domain_type_set ( object , fluid_modifier_data -> domain , FLUID_DOMAIN_TYPE_GAS ) ; } else if ( fluid_modifier_data -> type == MOD_FLUID_TYPE_FLOW ) { BKE_fluid_flow_type_set ( object , fluid_modifier_data -> flow , FLUID_FLOW_TYPE_SMOKE ) ; } else if ( fluid_modifier_data -> type == MOD_FLUID_TYPE_EFFEC ) { BKE_fluid_effector_type_set ( object , fluid_modifier_data -> effector , FLUID_EFFECTOR_TYPE_COLLISION ) ; } } new_modifier_data -> next = old_modifier_data -> next ; new_modifier_data -> prev = old_modifier_data -> prev ; if ( new_modifier_data -> prev != NULL ) { new_modifier_data -> prev -> next = new_modifier_data ; } if ( new_modifier_data -> next != NULL ) { new_modifier_data -> next -> prev = new_modifier_data ; } if ( modifiers -> first == old_modifier_data ) { modifiers -> first = new_modifier_data ; } if ( modifiers -> last == old_modifier_data ) { modifiers -> last = new_modifier_data ; } MEM_freeN ( old_modifier_data ) ; return new_modifier_data ; }
\note The old_modifier_data is NOT linked.
\ note The old_modifier_data is NOT linked .
/* No need to emit liquid far away from surface. */ /* No need to emit liquid far away from surface. */ /* "Particle" type objects not being used by Mantaflow fluid simulations.
         * Skip this object, secondary particles can only be enabled through the domain object. */ /* "Control" type objects not being used by Mantaflow fluid simulations.
         * Use guiding type instead which is similar. */ /* Replace modifier data in the stack. */ /* Free old modifier data. */