Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-addons
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
blender-addons
Commits
708255a8
Commit
708255a8
authored
2 years ago
by
Germano Cavalcante
Browse files
Options
Downloads
Patches
Plain Diff
Carver: replace deprecated bgl module
Part of T80730
parent
5578ae83
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
object_carver/__init__.py
+2
-2
2 additions, 2 deletions
object_carver/__init__.py
object_carver/carver_draw.py
+2
-4
2 additions, 4 deletions
object_carver/carver_draw.py
object_carver/carver_utils.py
+12
-15
12 additions, 15 deletions
object_carver/carver_utils.py
with
16 additions
and
21 deletions
object_carver/__init__.py
+
2
−
2
View file @
708255a8
...
...
@@ -4,8 +4,8 @@ bl_info = {
"
name
"
:
"
Carver
"
,
"
author
"
:
"
Pixivore, Cedric LEPILLER, Ted Milker, Clarkx
"
,
"
description
"
:
"
Multiple tools to carve or to create objects
"
,
"
version
"
:
(
1
,
2
,
0
),
"
blender
"
:
(
2
,
80
,
0
),
"
version
"
:
(
1
,
2
,
1
),
"
blender
"
:
(
3
,
4
,
0
),
"
location
"
:
"
3D View > Ctrl/Shift/x
"
,
"
warning
"
:
""
,
"
doc_url
"
:
"
{BLENDER_MANUAL_URL}/addons/object/carver.html
"
,
...
...
This diff is collapsed.
Click to expand it.
object_carver/carver_draw.py
+
2
−
4
View file @
708255a8
# SPDX-License-Identifier: GPL-2.0-or-later
import
bpy
import
bgl
import
blf
import
bpy_extras
import
numpy
as
np
...
...
@@ -444,7 +443,7 @@ def draw_callback_px(self, context):
mat
=
ob
.
matrix_world
# 50% alpha, 2 pixel width line
bgl
.
glEnable
(
bgl
.
GL_BLEND
)
gpu
.
state
.
blend_set
(
'
ALPHA
'
)
bbox
=
[
mat
@
Vector
(
b
)
for
b
in
ob
.
bound_box
]
objBBDiagonal
=
objDiagonal
(
self
.
CurrentSelection
[
0
])
...
...
@@ -497,5 +496,4 @@ def draw_callback_px(self, context):
self
.
ProfileBrush
.
rotation_mode
=
'
XYZ
'
# Opengl defaults
bgl
.
glLineWidth
(
1
)
bgl
.
glDisable
(
bgl
.
GL_BLEND
)
gpu
.
state
.
blend_set
(
'
NONE
'
)
This diff is collapsed.
Click to expand it.
object_carver/carver_utils.py
+
12
−
15
View file @
708255a8
# SPDX-License-Identifier: GPL-2.0-or-later
import
bpy
import
bgl
import
gpu
from
gpu_extras.batch
import
batch_for_shader
import
math
...
...
@@ -918,25 +917,23 @@ def mini_grid(self, context, color):
def
draw_shader
(
self
,
color
,
alpha
,
type
,
coords
,
size
=
1
,
indices
=
None
):
"""
Create a batch for a draw type
"""
bgl
.
glEnable
(
bgl
.
GL_BLEND
)
bgl
.
glEnable
(
bgl
.
GL_LINE_SMOOTH
)
gpu
.
state
.
blend_set
(
'
ALPHA
'
)
if
type
==
'
POINTS
'
:
bgl
.
glPointSize
(
size
)
gpu
.
state
.
program_point_size_set
(
False
)
gpu
.
state
.
point_size_set
(
size
)
shader
=
gpu
.
shader
.
from_builtin
(
'
UNIFORM_COLOR
'
)
else
:
bgl
.
glLineWidth
(
size
)
shader
=
gpu
.
shader
.
from_builtin
(
'
POLYLINE_UNIFORM_COLOR
'
)
shader
.
uniform_float
(
"
viewportSize
"
,
gpu
.
state
.
viewport_get
()[
2
:])
shader
.
uniform_float
(
"
lineWidth
"
,
1.0
)
try
:
if
len
(
coords
[
0
])
>
2
:
shader
=
gpu
.
shader
.
from_builtin
(
'
3D_UNIFORM_COLOR
'
)
else
:
shader
=
gpu
.
shader
.
from_builtin
(
'
2D_UNIFORM_COLOR
'
)
batch
=
batch_for_shader
(
shader
,
type
,
{
"
pos
"
:
coords
},
indices
=
indices
)
shader
.
bind
()
shader
.
uniform_float
(
"
color
"
,
(
color
[
0
],
color
[
1
],
color
[
2
],
alpha
))
batch
=
batch_for_shader
(
shader
,
type
,
{
"
pos
"
:
coords
},
indices
=
indices
)
batch
.
draw
(
shader
)
bgl
.
glLineWidth
(
1
)
bgl
.
glPointSize
(
1
)
bgl
.
glDisable
(
bgl
.
GL_LINE_SMOOTH
)
bgl
.
glDisable
(
bgl
.
GL_BLEND
)
except
:
exc_type
,
exc_value
,
exc_traceback
=
sys
.
exc_info
()
self
.
report
({
'
ERROR
'
},
str
(
exc_value
))
gpu
.
state
.
point_size_set
(
1.0
)
gpu
.
state
.
blend_set
(
'
NONE
'
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment