Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
348eb4e4
Commit
348eb4e4
authored
Aug 30, 2017
by
Rémi Verschelde
Committed by
GitHub
Aug 30, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10361 from RandomShaper/tilemap-global-mtl
Let TileMap apply its material
parents
a1d7c496
3bb5abbc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
2 deletions
+39
-2
canvas_item.h
scene/2d/canvas_item.h
+2
-2
tile_map.cpp
scene/2d/tile_map.cpp
+30
-0
tile_map.h
scene/2d/tile_map.h
+7
-0
No files found.
scene/2d/canvas_item.h
View file @
348eb4e4
...
...
@@ -291,10 +291,10 @@ public:
RID
get_canvas
()
const
;
Ref
<
World2D
>
get_world_2d
()
const
;
void
set_material
(
const
Ref
<
Material
>
&
p_material
);
v
irtual
v
oid
set_material
(
const
Ref
<
Material
>
&
p_material
);
Ref
<
Material
>
get_material
()
const
;
void
set_use_parent_material
(
bool
p_use_parent_material
);
v
irtual
v
oid
set_use_parent_material
(
bool
p_use_parent_material
);
bool
get_use_parent_material
()
const
;
Ref
<
InputEvent
>
make_input_local
(
const
Ref
<
InputEvent
>
&
p_event
)
const
;
...
...
scene/2d/tile_map.cpp
View file @
348eb4e4
...
...
@@ -336,6 +336,7 @@ void TileMap::_update_dirty_quadrants() {
if
(
mat
.
is_valid
())
vs
->
canvas_item_set_material
(
canvas_item
,
mat
->
get_rid
());
vs
->
canvas_item_set_parent
(
canvas_item
,
get_canvas_item
());
_update_item_material_state
(
canvas_item
);
Transform2D
xform
;
xform
.
set_origin
(
q
.
pos
);
vs
->
canvas_item_set_transform
(
canvas_item
,
xform
);
...
...
@@ -780,6 +781,35 @@ void TileMap::_clear_quadrants() {
}
}
void
TileMap
::
set_material
(
const
Ref
<
Material
>
&
p_material
)
{
CanvasItem
::
set_material
(
p_material
);
_update_all_items_material_state
();
}
void
TileMap
::
set_use_parent_material
(
bool
p_use_parent_material
)
{
CanvasItem
::
set_use_parent_material
(
p_use_parent_material
);
_update_all_items_material_state
();
}
void
TileMap
::
_update_all_items_material_state
()
{
for
(
Map
<
PosKey
,
Quadrant
>::
Element
*
E
=
quadrant_map
.
front
();
E
;
E
=
E
->
next
())
{
Quadrant
&
q
=
E
->
get
();
for
(
List
<
RID
>::
Element
*
E
=
q
.
canvas_items
.
front
();
E
;
E
=
E
->
next
())
{
_update_item_material_state
(
E
->
get
());
}
}
}
void
TileMap
::
_update_item_material_state
(
const
RID
&
p_canvas_item
)
{
VS
::
get_singleton
()
->
canvas_item_set_use_parent_material
(
p_canvas_item
,
get_use_parent_material
()
||
get_material
().
is_valid
());
}
void
TileMap
::
clear
()
{
_clear_quadrants
();
...
...
scene/2d/tile_map.h
View file @
348eb4e4
...
...
@@ -183,6 +183,9 @@ private:
void
_update_quadrant_transform
();
void
_recompute_rect_cache
();
void
_update_all_items_material_state
();
_FORCE_INLINE_
void
_update_item_material_state
(
const
RID
&
p_canvas_item
);
_FORCE_INLINE_
int
_get_quadrant_size
()
const
;
void
_set_tile_data
(
const
PoolVector
<
int
>
&
p_data
);
...
...
@@ -278,6 +281,10 @@ public:
virtual
void
set_light_mask
(
int
p_light_mask
);
virtual
void
set_material
(
const
Ref
<
Material
>
&
p_material
);
virtual
void
set_use_parent_material
(
bool
p_use_parent_material
);
void
clear
();
TileMap
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment