[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59392] branches/asset-browser/source/ blender: === asset browser ===
Andrea Weikert
elubie at gmx.net
Thu Aug 22 22:00:18 CEST 2013
Revision: 59392
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59392
Author: elubie
Date: 2013-08-22 20:00:18 +0000 (Thu, 22 Aug 2013)
Log Message:
-----------
=== asset browser ===
Now asset browser can also scan a directory for .blend files and load all assets from there.
Modified Paths:
--------------
branches/asset-browser/source/blender/blenkernel/intern/assets.c
branches/asset-browser/source/blender/editors/space_asset/assetlist.c
branches/asset-browser/source/blender/editors/space_file/filelist.c
branches/asset-browser/source/blender/makesdna/DNA_asset_types.h
Modified: branches/asset-browser/source/blender/blenkernel/intern/assets.c
===================================================================
--- branches/asset-browser/source/blender/blenkernel/intern/assets.c 2013-08-22 19:57:56 UTC (rev 59391)
+++ branches/asset-browser/source/blender/blenkernel/intern/assets.c 2013-08-22 20:00:18 UTC (rev 59392)
@@ -37,6 +37,7 @@
#include "BLI_string.h"
#include "BLI_path_util.h"
#include "BLI_fileops.h"
+#include "BLI_fileops_types.h"
#include "BLO_readfile.h"
@@ -131,6 +132,7 @@
{
int updated = 0;
bAssetFile *af;
+ bAssetDir *ad;
for (af = collection->asset_files.first; af; af= af->next) {
time_t mtime = BLI_modified_time(af->filepath);
@@ -145,6 +147,31 @@
}
}
+ for (ad = collection->asset_dirs.first; ad; ad= ad->next) {
+ time_t mtime = BLI_modified_time(ad->dirpath);
+ if (mtime > ad->mtime) {
+ BLI_freelistN(&ad->assets);
+ ad->assets.first = ad->assets.last = NULL;
+ }
+ if (ad->assets.first == NULL) {
+ struct direntry* files;
+ int num_files = BLI_dir_contents(ad->dirpath, &files);
+ int i;
+
+ for (i=0; i < num_files; ++i) {
+ char path[1024];
+
+ if (BLO_has_bfile_extension(files[i].relname)) {
+ BLI_join_dirfile(path, sizeof(path), ad->dirpath, files[i].relname);
+ assets_append_from_library(&ad->assets, bmain, path);
+
+ updated = 1;
+ }
+ }
+ }
+ ad->mtime = mtime;
+ }
+
/* We also need to rebuild the contentlist if file has been removed */
if (collection->changed) {
updated = 1;
Modified: branches/asset-browser/source/blender/editors/space_asset/assetlist.c
===================================================================
--- branches/asset-browser/source/blender/editors/space_asset/assetlist.c 2013-08-22 19:57:56 UTC (rev 59391)
+++ branches/asset-browser/source/blender/editors/space_asset/assetlist.c 2013-08-22 20:00:18 UTC (rev 59392)
@@ -408,6 +408,12 @@
}
}
+ for (ad = ac->asset_dirs.first; ad; ad= ad->next) {
+ for (asset = ad->assets.first; asset; asset = asset->next) {
+ num_entries++;
+ }
+ }
+
assetlist_alloc(cl, num_entries);
current_entry = 0;
@@ -420,6 +426,14 @@
}
}
+ for (ad = ac->asset_dirs.first; ad; ad= ad->next) {
+ for (asset = ad->assets.first; asset; asset = asset->next) {
+ cl->entries[current_entry].data = MEM_dupallocN(asset);
+ cl->entries[current_entry].image = NULL;
+ current_entry++;
+ }
+ }
+
assetlist_sort(cl, 0, 1);
for (current_entry = 0; current_entry < num_entries; ++current_entry) {
Modified: branches/asset-browser/source/blender/editors/space_file/filelist.c
===================================================================
--- branches/asset-browser/source/blender/editors/space_file/filelist.c 2013-08-22 19:57:56 UTC (rev 59391)
+++ branches/asset-browser/source/blender/editors/space_file/filelist.c 2013-08-22 20:00:18 UTC (rev 59392)
@@ -869,7 +869,7 @@
filelist_free(filelist);
- filelist->numfiles = BLI_dir_contents(filelist->dir, &filelist->filelist, &filelist->numfiles);
+ filelist->numfiles = BLI_dir_contents(filelist->dir, &filelist->filelist);
if(!chdir(wdir)) {} /* fix warning about not checking return value */
filelist_setfiletypes(filelist);
Modified: branches/asset-browser/source/blender/makesdna/DNA_asset_types.h
===================================================================
--- branches/asset-browser/source/blender/makesdna/DNA_asset_types.h 2013-08-22 19:57:56 UTC (rev 59391)
+++ branches/asset-browser/source/blender/makesdna/DNA_asset_types.h 2013-08-22 20:00:18 UTC (rev 59392)
@@ -75,6 +75,7 @@
struct bAssetDir *next, *prev;
char dirpath[1024];
char description[1024];
+ int64_t mtime;
ListBase assets;
IDProperty *properties;
} bAssetDir;
More information about the Bf-blender-cvs
mailing list