- bpy.path.abspath(), added optional library argument since any paths from linked datablocks are relative to this, not the blend files path, this saves kludgy path code wherever libraries may be used.
- Image "Edit Externally" operator can now edit relative library images. also minor edits to navmesh.
This commit is contained in:
@@ -40,7 +40,7 @@ import bpy as _bpy
|
|||||||
import os as _os
|
import os as _os
|
||||||
|
|
||||||
|
|
||||||
def abspath(path, start=None):
|
def abspath(path, start=None, library=None):
|
||||||
"""
|
"""
|
||||||
Returns the absolute path relative to the current blend file
|
Returns the absolute path relative to the current blend file
|
||||||
using the "//" prefix.
|
using the "//" prefix.
|
||||||
@@ -48,8 +48,13 @@ def abspath(path, start=None):
|
|||||||
:arg start: Relative to this path,
|
:arg start: Relative to this path,
|
||||||
when not set the current filename is used.
|
when not set the current filename is used.
|
||||||
:type start: string
|
:type start: string
|
||||||
|
:arg library: The library this path is from. This is only included for
|
||||||
|
convenience, when the library is not None its path replaces *start*.
|
||||||
|
:type library: :class:`bpy.types.Library`
|
||||||
"""
|
"""
|
||||||
if path.startswith("//"):
|
if path.startswith("//"):
|
||||||
|
if library:
|
||||||
|
start = abspath(_os.path.dirname(library.filepath))
|
||||||
return _os.path.join(_os.path.dirname(_bpy.data.filepath)
|
return _os.path.join(_os.path.dirname(_bpy.data.filepath)
|
||||||
if start is None else start,
|
if start is None else start,
|
||||||
path[2:],
|
path[2:],
|
||||||
|
|||||||
@@ -69,8 +69,6 @@ class EditExternally(Operator):
|
|||||||
self.report({'ERROR'}, "Image path not set")
|
self.report({'ERROR'}, "Image path not set")
|
||||||
return {'CANCELLED'}
|
return {'CANCELLED'}
|
||||||
|
|
||||||
filepath = os.path.normpath(bpy.path.abspath(filepath))
|
|
||||||
|
|
||||||
if not os.path.exists(filepath):
|
if not os.path.exists(filepath):
|
||||||
self.report({'ERROR'},
|
self.report({'ERROR'},
|
||||||
"Image path %r not found, image may be packed or "
|
"Image path %r not found, image may be packed or "
|
||||||
@@ -93,15 +91,16 @@ class EditExternally(Operator):
|
|||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
|
import os
|
||||||
try:
|
try:
|
||||||
filepath = context.space_data.image.filepath
|
image = context.space_data.image
|
||||||
except:
|
except AttributeError:
|
||||||
import traceback
|
self.report({'ERROR'}, "Context incorrect, image not found")
|
||||||
traceback.print_exc()
|
|
||||||
self.report({'ERROR'}, "Image not found on disk")
|
|
||||||
return {'CANCELLED'}
|
return {'CANCELLED'}
|
||||||
|
|
||||||
self.filepath = filepath
|
filepath = bpy.path.abspath(image.filepath, library=image.library)
|
||||||
|
|
||||||
|
self.filepath = os.path.normpath(filepath)
|
||||||
self.execute(context)
|
self.execute(context)
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|||||||
@@ -64,6 +64,7 @@
|
|||||||
|
|
||||||
#ifdef WITH_GAMEENGINE
|
#ifdef WITH_GAMEENGINE
|
||||||
#include "BKE_navmesh_conversion.h"
|
#include "BKE_navmesh_conversion.h"
|
||||||
|
static DerivedMesh *navmesh_dm_createNavMeshForVisualization(DerivedMesh *dm);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "BLO_sys_types.h" // for intptr_t support
|
#include "BLO_sys_types.h" // for intptr_t support
|
||||||
@@ -77,8 +78,6 @@
|
|||||||
|
|
||||||
extern GLubyte stipple_quarttone[128]; /* glutil.c, bad level data */
|
extern GLubyte stipple_quarttone[128]; /* glutil.c, bad level data */
|
||||||
|
|
||||||
static DerivedMesh *navmesh_dm_createNavMeshForVisualization(DerivedMesh *dm);
|
|
||||||
|
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
|
|
||||||
|
|||||||
@@ -459,12 +459,14 @@ static int create_navmesh_exec(bContext *C, wmOperator *op)
|
|||||||
|
|
||||||
MEM_freeN(verts);
|
MEM_freeN(verts);
|
||||||
MEM_freeN(tris);
|
MEM_freeN(tris);
|
||||||
|
|
||||||
|
return OPERATOR_FINISHED;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BKE_report(op->reports, RPT_ERROR, "No mesh objects found");
|
BKE_report(op->reports, RPT_ERROR, "No mesh objects found");
|
||||||
}
|
|
||||||
|
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_CANCELLED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MESH_OT_navmesh_make(wmOperatorType *ot)
|
void MESH_OT_navmesh_make(wmOperatorType *ot)
|
||||||
|
|||||||
Reference in New Issue
Block a user