Example #1
0
void cache_voxeldata(Tex *tex, int scene_frame)
{	
	VoxelData *vd = tex->vd;
	FILE *fp;
	int curframe;
	char path[sizeof(vd->source_path)];
	
	/* only re-cache if dataset needs updating */
	if ((vd->flag & TEX_VD_STILL) || (vd->cachedframe == scene_frame))
		if (vd->ok) return;
	
	/* clear out old cache, ready for new */
	if (vd->dataset) {
		MEM_freeN(vd->dataset);
		vd->dataset = NULL;
	}
	/* reset data_type */
	vd->data_type = TEX_VD_INTENSITY;

	if (vd->flag & TEX_VD_STILL)
		curframe = vd->still_frame;
	else
		curframe = scene_frame;
	
	BLI_strncpy(path, vd->source_path, sizeof(path));
	
	/* each type is responsible for setting to true */
	vd->ok = false;

	switch (vd->file_format) {
		case TEX_VD_IMAGE_SEQUENCE:
			load_frame_image_sequence(vd, tex);
			return;
		case TEX_VD_SMOKE:
			init_frame_smoke(vd, scene_frame);
			return;
		case TEX_VD_HAIR:
			init_frame_hair(vd, scene_frame);
			return;
		case TEX_VD_BLENDERVOXEL:
			BLI_path_abs(path, G.main->name);
			fp = BLI_fopen(path, "rb");
			if (!fp) return;
			
			if (read_voxeldata_header(fp, vd))
				load_frame_blendervoxel(vd, fp, curframe - 1);

			fclose(fp);
			return;
		case TEX_VD_RAW_8BIT:
			BLI_path_abs(path, G.main->name);
			fp = BLI_fopen(path, "rb");
			if (!fp) return;
			
			load_frame_raw8(vd, fp, curframe);
			fclose(fp);
			return;
	}
}
Example #2
0
static void cache_voxeldata(struct Render *re, Tex *tex)
{	
	VoxelData *vd = tex->vd;
	FILE *fp;
	int curframe;
	char path[sizeof(vd->source_path)];
	
	/* only re-cache if dataset needs updating */
	if ((vd->flag & TEX_VD_STILL) || (vd->cachedframe == re->r.cfra))
		if (vd->ok) return;
	
	/* clear out old cache, ready for new */
	if (vd->dataset) {
		MEM_freeN(vd->dataset);
		vd->dataset = NULL;
	}

	if (vd->flag & TEX_VD_STILL)
		curframe = vd->still_frame;
	else
		curframe = re->r.cfra;
	
	BLI_strncpy(path, vd->source_path, sizeof(path));
	
	switch(vd->file_format) {
		case TEX_VD_IMAGE_SEQUENCE:
			load_frame_image_sequence(vd, tex);
			return;
		case TEX_VD_SMOKE:
			init_frame_smoke(vd, re->r.cfra);
			return;
		case TEX_VD_BLENDERVOXEL:
			BLI_path_abs(path, G.main->name);
			if (!BLI_exists(path)) return;
			fp = fopen(path,"rb");
			if (!fp) return;
			
			if(read_voxeldata_header(fp, vd))
				load_frame_blendervoxel(vd, fp, curframe-1);

			fclose(fp);
			return;
		case TEX_VD_RAW_8BIT:
			BLI_path_abs(path, G.main->name);
			if (!BLI_exists(path)) return;
			fp = fopen(path,"rb");
			if (!fp) return;
			
			load_frame_raw8(vd, fp, curframe);
			fclose(fp);
			return;
	}
}