wip asset reload
parent
5f6fbab4de
commit
b7a6543c07
|
@ -15,16 +15,16 @@
|
||||||
|
|
||||||
#define occlusion_enabled
|
#define occlusion_enabled
|
||||||
#define occlusion_quality 4
|
#define occlusion_quality 4
|
||||||
//#define occlusion_preview
|
// #define occlusion_preview
|
||||||
|
|
||||||
#define noise_use_smoothstep
|
#define noise_use_smoothstep
|
||||||
|
|
||||||
#define light_color vec3(0.1,0.4,0.6)
|
#define light_color vec3(0.3,0.4,0.6)
|
||||||
#define light_direction normalize(vec3(.2,1.0,-0.2))
|
#define light_direction normalize(vec3(.2,1.0,-0.2))
|
||||||
#define light_speed_modifier 1.0
|
#define light_speed_modifier 1.0
|
||||||
|
|
||||||
#define object_color vec3(0.9,0.1,0.1)
|
#define object_color vec3(0.93,0.2,0.1)
|
||||||
#define object_count 9
|
#define object_count 19
|
||||||
#define object_speed_modifier 1.0
|
#define object_speed_modifier 1.0
|
||||||
|
|
||||||
#define render_steps 33
|
#define render_steps 33
|
||||||
|
|
|
@ -334108,6 +334108,10 @@ const char *vfs_resolve(const char *pathfile) {
|
||||||
return pathfile;
|
return pathfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef VFS_ALWAYS_PACK
|
||||||
|
#define VFS_ALWAYS_PACK flag("--vfs-always-pack")
|
||||||
|
#endif
|
||||||
|
|
||||||
char* vfs_load(const char *pathfile, int *size_out) { // @todo: fix leaks, vfs_unpack()
|
char* vfs_load(const char *pathfile, int *size_out) { // @todo: fix leaks, vfs_unpack()
|
||||||
// @fixme: handle \\?\ absolute path (win)
|
// @fixme: handle \\?\ absolute path (win)
|
||||||
if (!pathfile[0]) return file_load(pathfile, size_out);
|
if (!pathfile[0]) return file_load(pathfile, size_out);
|
||||||
|
@ -334179,8 +334183,7 @@ if( found && *found == 0 ) {
|
||||||
ptr = vfs_unpack(pathfile, &size);
|
ptr = vfs_unpack(pathfile, &size);
|
||||||
|
|
||||||
// asset not found? maybe it has not been cooked yet at this point (see --cook-on-demand)
|
// asset not found? maybe it has not been cooked yet at this point (see --cook-on-demand)
|
||||||
if( !ptr && COOK_ON_DEMAND ) {
|
if( (!ptr && COOK_ON_DEMAND) || VFS_ALWAYS_PACK ) {
|
||||||
|
|
||||||
static thread_mutex_t mutex, *init = 0; if(!init) thread_mutex_init(init = &mutex);
|
static thread_mutex_t mutex, *init = 0; if(!init) thread_mutex_init(init = &mutex);
|
||||||
thread_mutex_lock(&mutex);
|
thread_mutex_lock(&mutex);
|
||||||
|
|
||||||
|
|
|
@ -681,6 +681,10 @@ const char *vfs_resolve(const char *pathfile) {
|
||||||
return pathfile;
|
return pathfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef VFS_ALWAYS_PACK
|
||||||
|
#define VFS_ALWAYS_PACK flag("--vfs-always-pack")
|
||||||
|
#endif
|
||||||
|
|
||||||
char* vfs_load(const char *pathfile, int *size_out) { // @todo: fix leaks, vfs_unpack()
|
char* vfs_load(const char *pathfile, int *size_out) { // @todo: fix leaks, vfs_unpack()
|
||||||
// @fixme: handle \\?\ absolute path (win)
|
// @fixme: handle \\?\ absolute path (win)
|
||||||
if (!pathfile[0]) return file_load(pathfile, size_out);
|
if (!pathfile[0]) return file_load(pathfile, size_out);
|
||||||
|
@ -752,8 +756,7 @@ if( found && *found == 0 ) {
|
||||||
ptr = vfs_unpack(pathfile, &size);
|
ptr = vfs_unpack(pathfile, &size);
|
||||||
|
|
||||||
// asset not found? maybe it has not been cooked yet at this point (see --cook-on-demand)
|
// asset not found? maybe it has not been cooked yet at this point (see --cook-on-demand)
|
||||||
if( !ptr && COOK_ON_DEMAND ) {
|
if( (!ptr && COOK_ON_DEMAND) || VFS_ALWAYS_PACK ) {
|
||||||
|
|
||||||
static thread_mutex_t mutex, *init = 0; if(!init) thread_mutex_init(init = &mutex);
|
static thread_mutex_t mutex, *init = 0; if(!init) thread_mutex_init(init = &mutex);
|
||||||
thread_mutex_lock(&mutex);
|
thread_mutex_lock(&mutex);
|
||||||
|
|
||||||
|
|
|
@ -4803,6 +4803,10 @@ const char *vfs_resolve(const char *pathfile) {
|
||||||
return pathfile;
|
return pathfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef VFS_ALWAYS_PACK
|
||||||
|
#define VFS_ALWAYS_PACK flag("--vfs-always-pack")
|
||||||
|
#endif
|
||||||
|
|
||||||
char* vfs_load(const char *pathfile, int *size_out) { // @todo: fix leaks, vfs_unpack()
|
char* vfs_load(const char *pathfile, int *size_out) { // @todo: fix leaks, vfs_unpack()
|
||||||
// @fixme: handle \\?\ absolute path (win)
|
// @fixme: handle \\?\ absolute path (win)
|
||||||
if (!pathfile[0]) return file_load(pathfile, size_out);
|
if (!pathfile[0]) return file_load(pathfile, size_out);
|
||||||
|
@ -4874,8 +4878,7 @@ if( found && *found == 0 ) {
|
||||||
ptr = vfs_unpack(pathfile, &size);
|
ptr = vfs_unpack(pathfile, &size);
|
||||||
|
|
||||||
// asset not found? maybe it has not been cooked yet at this point (see --cook-on-demand)
|
// asset not found? maybe it has not been cooked yet at this point (see --cook-on-demand)
|
||||||
if( !ptr && COOK_ON_DEMAND ) {
|
if( (!ptr && COOK_ON_DEMAND) || VFS_ALWAYS_PACK ) {
|
||||||
|
|
||||||
static thread_mutex_t mutex, *init = 0; if(!init) thread_mutex_init(init = &mutex);
|
static thread_mutex_t mutex, *init = 0; if(!init) thread_mutex_init(init = &mutex);
|
||||||
thread_mutex_lock(&mutex);
|
thread_mutex_lock(&mutex);
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ typedef struct {
|
||||||
editor_t *ed;
|
editor_t *ed;
|
||||||
|
|
||||||
int slot; //<< internal, used by plugin
|
int slot; //<< internal, used by plugin
|
||||||
|
bool opened;
|
||||||
|
uint64_t last_modified;
|
||||||
} asset_t;
|
} asset_t;
|
||||||
|
|
||||||
#define PLUG_DECLARE(name) editor_vtable_t name##__procs = { name##_init, name##_tick, name##_quit, name##_ext };
|
#define PLUG_DECLARE(name) editor_vtable_t name##__procs = { name##_init, name##_tick, name##_quit, name##_ext };
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#define COOK_ON_DEMAND 1
|
#define COOK_ON_DEMAND 1
|
||||||
|
#define MAX_CACHED_FILES 0
|
||||||
|
#define VFS_ALWAYS_PACK 1
|
||||||
#include "v4k.c"
|
#include "v4k.c"
|
||||||
#include "pluginapi.h"
|
#include "pluginapi.h"
|
||||||
|
|
||||||
|
@ -13,11 +15,9 @@ array(asset_t) assets = 0;
|
||||||
#undef X
|
#undef X
|
||||||
|
|
||||||
void load_editor(char *pname, editor_vtable_t f) {
|
void load_editor(char *pname, editor_vtable_t f) {
|
||||||
char *name = STRDUP(pname); // @leak
|
|
||||||
|
|
||||||
editor_t ed = {0};
|
editor_t ed = {0};
|
||||||
ed.f = f;
|
ed.f = f;
|
||||||
ed.name = file_base(STRDUP(name)); // @leak
|
ed.name = file_base(STRDUP(pname)); // @leak
|
||||||
PRINTF("loaded plugin: '%s'\n", ed.name);
|
PRINTF("loaded plugin: '%s'\n", ed.name);
|
||||||
array_push(editors, ed);
|
array_push(editors, ed);
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,8 @@ void load_asset(const char *fname) {
|
||||||
asset_t asset = {0};
|
asset_t asset = {0};
|
||||||
asset.name = STRDUP(fname);
|
asset.name = STRDUP(fname);
|
||||||
asset.ed = *ed;
|
asset.ed = *ed;
|
||||||
|
asset.opened = 1;
|
||||||
|
asset.last_modified = file_stamp(fname);
|
||||||
array_push(assets, asset);
|
array_push(assets, asset);
|
||||||
if (asset.ed->f.init((struct asset_t*)array_back(assets))) {
|
if (asset.ed->f.init((struct asset_t*)array_back(assets))) {
|
||||||
FREE(asset.name);
|
FREE(asset.name);
|
||||||
|
@ -100,19 +102,23 @@ int main() {
|
||||||
|
|
||||||
for (int i=0; i<array_count(assets); i++) {
|
for (int i=0; i<array_count(assets); i++) {
|
||||||
asset_t *f = (assets+i);
|
asset_t *f = (assets+i);
|
||||||
int open = 1;
|
if (ui_window(f->name, &f->opened)) {
|
||||||
if (ui_window(f->name, &open)) {
|
|
||||||
f->ed->f.tick(f);
|
f->ed->f.tick(f);
|
||||||
|
|
||||||
|
// was the asset modified?
|
||||||
|
bool modified = f->last_modified != file_stamp(f->name);
|
||||||
|
|
||||||
ui_separator();
|
ui_separator();
|
||||||
if (ui_button("reload asset") || !open) {
|
|
||||||
|
if (ui_button("reload asset") || modified) {
|
||||||
|
f->last_modified = file_stamp(f->name);
|
||||||
f->ed->f.quit(f);
|
f->ed->f.quit(f);
|
||||||
f->ed->f.init(f);
|
f->ed->f.init(f);
|
||||||
}
|
}
|
||||||
if (ui_button("edit asset") || !open) {
|
if (ui_button("edit asset")) {
|
||||||
edit_asset(assets[i].name);
|
edit_asset(assets[i].name);
|
||||||
}
|
}
|
||||||
if (ui_button("close asset") || !open) {
|
if (ui_button("close asset") || !f->opened) {
|
||||||
f->ed->f.quit(f);
|
f->ed->f.quit(f);
|
||||||
FREE(assets[i].name);
|
FREE(assets[i].name);
|
||||||
array_erase(assets, i);
|
array_erase(assets, i);
|
||||||
|
|
Loading…
Reference in New Issue