Skip to content

Commit 0c9bc67

Browse files
authored
Merge pull request #973 from CodeFHD/for_v2.10
For v2.10
2 parents 54c4e1d + fd8b913 commit 0c9bc67

8 files changed

Lines changed: 130 additions & 109 deletions

File tree

__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
bl_info = {
3232
"name": "LuxCoreRender",
3333
"author": "Simon Wendsche (B.Y.O.B.), Michael Klemm (neo2068), Odilkhan Yakubov (odil24), acasta69, u3dreal, Philstix",
34-
"version": (2, 10),
34+
"version": (2, 9),
3535
"blender": (4, 2, 0),
3636
"category": "Render",
3737
"description": "LuxCoreRender integration for Blender",
38-
"warning": "alpha3",
38+
"warning": "alpha4",
3939

4040
"wiki_url": "https://wiki.luxcorerender.org/",
4141
"tracker_url": "https://github.com/LuxCoreRender/BlendLuxCore/issues/new",
@@ -183,7 +183,6 @@ def install_pyluxcore():
183183

184184
# Step 2: Check if platform information is complete and valid
185185
architecture, machine, python_version_str = _get_platform_info()
186-
print('Platform information:', architecture, machine, python_version_str)
187186
if architecture is None or machine is None or python_version_str is None:
188187
# In this case, just hope pyluxcore was previously installed and can be imported. Else error will be raised below so do nothing here at the moment.
189188
print("WARNING: Platform information is incomplete")

blender_manifest.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ schema_version = "1.0.0"
44
# Change the values according to your extension
55
id = "BlendLuxCore"
66
# Recommend versioning like MASTER.MAJOR.MINOR.
7-
# E.g.: "2.9.3": master: 2; major: 9; minor: 3.
8-
# BlendLuxCore Wheels version is 2.9.3 "3 is alpha3 here"
9-
version = "2.9.3"
7+
# E.g.: "2.9.4": master: 2; major: 9; minor: 3.
8+
# BlendLuxCore Wheels version is 2.9.4 "4 is alpha4 here"
9+
version = "2.9.4"
1010
name = "BlendLuxCore"
1111
tagline = "LuxCore"
1212
maintainer = "BlendLuxCore team"

operators/lol/add_local.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from os import listdir
3333
from os.path import basename, dirname, isfile, join, splitext, exists
3434
from ...utils.lol import utils as lol_utils
35+
from ...utils import get_addon_preferences
3536

3637
from mathutils import Vector
3738

@@ -77,9 +78,7 @@ def render_thumbnail(args):
7778
from ...utils.compatibility import run
7879
(context, assetfile, asset_type) = args
7980

80-
name = 'bl_ext.user_default.' + basename(dirname(dirname(dirname(__file__))))
81-
user_preferences = context.preferences.addons[name].preferences
82-
81+
user_preferences = get_addon_preferences(context)
8382

8483
if asset_type == 'MODEL':
8584
luxball = 'material_thumbnail.blend'
@@ -131,8 +130,7 @@ def execute(self, context):
131130
ui_props = scene.luxcoreOL.ui
132131
upload_props = scene.luxcoreOL.upload
133132

134-
name = 'bl_ext.user_default.' + basename(dirname(dirname(dirname(__file__))))
135-
user_preferences = context.preferences.addons[name].preferences
133+
user_preferences = get_addon_preferences(context)
136134

137135
if len(context.selected_objects) == 0:
138136
return {'CANCELLED'}
@@ -243,8 +241,7 @@ def execute(self, context):
243241
ui_props = scene.luxcoreOL.ui
244242
upload_props = scene.luxcoreOL.upload
245243

246-
name = 'bl_ext.user_default.' + basename(dirname(dirname(dirname(__file__))))
247-
user_preferences = context.preferences.addons[name].preferences
244+
user_preferences = get_addon_preferences(context)
248245
assetpath = join(user_preferences.global_dir, ui_props.asset_type.lower(), 'local')
249246

250247
files = [f for f in listdir(assetpath) if isfile(join(assetpath, f))]

operators/lol/update_ToC.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,7 @@
2727

2828
from bpy.types import Operator
2929
from ...utils.lol import utils as utils
30-
from ... import bl_info
31-
32-
blc_ver = '.'.join([str(_) for _ in bl_info["version"]])
33-
useragent = f"BlendLuxCore/{blc_ver}" # user agent for urllib request to LOL
34-
35-
30+
from ...utils import get_addon_preferences
3631

3732
class LOLUpdateTOC(Operator):
3833
bl_idname = 'scene.luxcore_ol_update_toc'
@@ -50,41 +45,45 @@ def execute(self, context):
5045
scene = context.scene
5146
ui_props = scene.luxcoreOL.ui
5247

53-
name = 'bl_ext.user_default.' + basename(dirname(dirname(dirname(__file__))))
54-
user_preferences = context.preferences.addons[name].preferences
48+
user_preferences = get_addon_preferences(context)
49+
LOL_HOST_URL = user_preferences.lol_host
50+
LOL_VERSION = user_preferences.lol_version
51+
LOL_HTTP_HOST = user_preferences.lol_http_host
52+
LOL_USERAGENT = user_preferences.lol_useragent
53+
5554

5655
filepath = join(user_preferences.global_dir, 'assets_model_blendermarket.json')
57-
urlstr = utils.LOL_HOST_URL + "/" + utils.LOL_VERSION + "/assets_model_blendermarket.json"
56+
urlstr = LOL_HOST_URL + "/" + LOL_VERSION + "/assets_model_blendermarket.json"
5857

5958
req = urllib.request.Request(
60-
urlstr, data=None, headers={'User-Agent': useragent}
59+
urlstr, headers={'User-Agent': LOL_USERAGENT, 'Host': LOL_HTTP_HOST}
6160
)
62-
with urllib.request.urlopen(req, timeout=60) as request:
63-
assets = json.load(request)
61+
with urllib.request.urlopen(req, timeout=60) as response:
62+
assets = json.load(response)
6463

6564
with open(filepath, 'w') as file:
6665
file.write(json.dumps(assets, indent=2))
6766

6867
filepath = join(user_preferences.global_dir, 'assets_model.json')
69-
urlstr = utils.LOL_HOST_URL + "/" + utils.LOL_VERSION + "/assets_model.json"
68+
urlstr = LOL_HOST_URL + "/" + LOL_VERSION + "/assets_model.json"
7069

7170
req = urllib.request.Request(
72-
urlstr, data=None, headers={'User-Agent': useragent}
71+
urlstr, headers={'User-Agent': LOL_USERAGENT, 'Host': LOL_HTTP_HOST}
7372
)
74-
with urllib.request.urlopen(req, timeout=60) as request:
75-
assets = json.load(request)
73+
with urllib.request.urlopen(req, timeout=60) as response:
74+
assets = json.load(response)
7675

7776
with open(filepath, 'w') as file:
7877
file.write(json.dumps(assets, indent=2))
7978

8079
filepath = join(user_preferences.global_dir, 'assets_material.json')
81-
urlstr = utils.LOL_HOST_URL + "/" + utils.LOL_VERSION + "/assets_material.json"
80+
urlstr = LOL_HOST_URL + "/" + LOL_VERSION + "/assets_material.json"
8281

8382
req = urllib.request.Request(
84-
urlstr, data=None, headers={'User-Agent': useragent}
83+
urlstr, headers={'User-Agent': LOL_USERAGENT, 'Host': LOL_HTTP_HOST}
8584
)
86-
with urllib.request.urlopen(req, timeout=60) as request:
87-
assets = json.load(request)
85+
with urllib.request.urlopen(req, timeout=60) as response:
86+
assets = json.load(response)
8887

8988
with open(filepath, 'w') as file:
9089
file.write(json.dumps(assets, indent=2))

scripts/LOL/render_thumbnail.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ def calc_bbox(context, objects):
3939

4040
def render_material_thumbnail(assetname, blendfile, thumbnail, samples):
4141
context = bpy.context
42-
scene = context.scene
43-
name = 'bl_ext.user_default.' + basename(dirname(dirname(dirname(__file__))))
44-
user_preferences = context.preferences.addons[name].preferences
4542

4643
with bpy.data.libraries.load(blendfile, link=True) as (mat_from, mat_to):
4744
mat_to.materials = mat_from.materials
@@ -69,8 +66,6 @@ def render_material_thumbnail(assetname, blendfile, thumbnail, samples):
6966
def render_model_thumbnail(assetname, blendfile, thumbnail, samples):
7067
context = bpy.context
7168
scene = context.scene
72-
name = 'bl_ext.user_default.' + basename(dirname(dirname(dirname(__file__))))
73-
user_preferences = context.preferences.addons[name].preferences
7469

7570
with bpy.data.libraries.load(blendfile, link=True) as (data_from, data_to):
7671
data_to.objects = [name for name in data_from.objects]

ui/addon_preferences.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import bpy
2-
from os.path import basename, dirname
32
from bpy.types import AddonPreferences
43
from bpy.props import IntProperty, StringProperty, EnumProperty, BoolProperty
4+
55
from ..ui import icons
66
from .. import utils
77
from ..utils.lol import utils as lol_utils
88
from importlib.metadata import version
9+
from .. import bl_info
910

11+
blc_ver = '.'.join([str(_) for _ in bl_info["version"]])
1012

1113
film_device_items = []
1214

13-
1415
class LuxCoreAddonPreferences(AddonPreferences):
1516
# id name for 4.2
1617
bl_idname = "bl_ext.user_default.BlendLuxCore"
@@ -59,6 +60,26 @@ def film_device_items_callback(self, context):
5960
description="Global storage for your assets, will use subdirectories for the contents",
6061
subtype='DIR_PATH', default=lol_utils.get_default_directory()
6162
)
63+
lol_host: StringProperty(
64+
name="Host URL",
65+
description="Address of the LuxCore Online Library server",
66+
default = "https://luxcorerender.org/lol",
67+
)
68+
lol_http_host: StringProperty(
69+
name="HTTP Host",
70+
description=" FOR DEVELOPERS ONLY! DO NOT EDIT! Hostname transferred with HTTP(S) request. Needed for technical reasons.",
71+
default = "www.luxcorerender.org",
72+
)
73+
lol_version: StringProperty(
74+
name="Library Version",
75+
description="Version of the LuxCore Online Library.",
76+
default = "v2.5",
77+
)
78+
lol_useragent: StringProperty(
79+
name="HTTP User-Agent",
80+
description="User Agent transmitted with requests",
81+
default = f"BlendLuxCore/{blc_ver}",
82+
)
6283

6384
max_assetbar_rows: IntProperty(name="Max Assetbar Rows", description="max rows of assetbar in the 3d view",
6485
default=1, min=0, max=20)
@@ -125,6 +146,10 @@ def draw(self, context):
125146
col.prop(self, "use_library")
126147
if self.use_library:
127148
col.prop(self, "global_dir")
149+
col.prop(self, "lol_host")
150+
col.prop(self, "lol_http_host")
151+
# col.prop(self, "lol_version") # unlikely to need change so not even needed for developers
152+
# col.prop(self, "lol_useragent") # unlikely to need change so not even needed for developers
128153
col.prop(self, "thumb_size")
129154

130155
# pyluxcore version

ui/lol/panel.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,6 @@ def draw(self, context):
174174
op = col.operator("luxcore.open_website", icon=icons.URL, text="Donation (CG Trader)")
175175
op.url = "https://www.cgtrader.com/draviastudio"
176176

177-
op = col.operator("luxcore.open_website", icon=icons.URL, text="Donation (Bountysource)")
178-
op.url = "https://salt.bountysource.com/teams/luxcorerender"
179-
180177
col = layout.column(align=True)
181178
col.scale_x = 1.4
182179
col.scale_y = 1.4

0 commit comments

Comments
 (0)