Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Viewer
Alchemy Viewer
Commits
fcb17af2
Commit
fcb17af2
authored
1 year ago
by
Rye Mutt
Browse files
Options
Downloads
Patches
Plain Diff
Fix shutdown crash
parent
5afe2ed9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
indra/newview/llgltfmateriallist.cpp
+102
-94
102 additions, 94 deletions
indra/newview/llgltfmateriallist.cpp
with
102 additions
and
94 deletions
indra/newview/llgltfmateriallist.cpp
+
102
−
94
View file @
fcb17af2
...
...
@@ -223,100 +223,108 @@ class LLGLTFMaterialOverrideDispatchHandler : public LLDispatchHandler
bool
mSuccess
;
};
// fromJson() is performance heavy offload to a thread.
main_queue
->
postTo
(
general_queue
,
[
object_override
]()
// Work done on general queue
{
std
::
vector
<
ReturnData
>
results
;
if
(
!
object_override
.
mSides
.
empty
())
{
results
.
reserve
(
object_override
.
mSides
.
size
());
// parse json
std
::
unordered_map
<
S32
,
std
::
string
>::
const_iterator
iter
=
object_override
.
mSides
.
begin
();
std
::
unordered_map
<
S32
,
std
::
string
>::
const_iterator
end
=
object_override
.
mSides
.
end
();
while
(
iter
!=
end
)
{
LLPointer
<
LLGLTFMaterial
>
override_data
=
new
LLGLTFMaterial
();
std
::
string
warn_msg
,
error_msg
;
bool
success
=
override_data
->
fromJSON
(
iter
->
second
,
warn_msg
,
error_msg
);
ReturnData
result
;
result
.
mSuccess
=
success
;
result
.
mSide
=
iter
->
first
;
if
(
success
)
{
result
.
mMaterial
=
override_data
;
}
else
{
LL_WARNS
(
"GLTF"
)
<<
"failed to parse GLTF override data. errors: "
<<
error_msg
<<
" | warnings: "
<<
warn_msg
<<
LL_ENDL
;
}
results
.
push_back
(
result
);
iter
++
;
}
}
return
results
;
},
[
object_override
,
this
](
std
::
vector
<
ReturnData
>
results
)
// Callback to main thread
{
LLViewerObject
*
obj
=
gObjectList
.
findObject
(
object_override
.
mObjectId
);
if
(
results
.
size
()
>
0
)
{
std
::
unordered_set
<
S32
>
side_set
;
for
(
int
i
=
0
;
i
<
results
.
size
();
++
i
)
{
if
(
results
[
i
].
mSuccess
)
{
// flag this side to not be nulled out later
side_set
.
insert
(
results
[
i
].
mSide
);
if
(
obj
)
{
obj
->
setTEGLTFMaterialOverride
(
results
[
i
].
mSide
,
results
[
i
].
mMaterial
);
}
}
// unblock material editor
if
(
obj
&&
obj
->
getTE
(
results
[
i
].
mSide
)
&&
obj
->
getTE
(
results
[
i
].
mSide
)
->
isSelected
())
{
doSelectionCallbacks
(
object_override
.
mObjectId
,
results
[
i
].
mSide
);
}
}
if
(
obj
&&
side_set
.
size
()
!=
obj
->
getNumTEs
())
{
// object exists and at least one texture entry needs to have its override data nulled out
for
(
int
i
=
0
;
i
<
obj
->
getNumTEs
();
++
i
)
{
if
(
side_set
.
find
(
i
)
==
side_set
.
end
())
{
obj
->
setTEGLTFMaterialOverride
(
i
,
nullptr
);
if
(
obj
->
getTE
(
i
)
&&
obj
->
getTE
(
i
)
->
isSelected
())
{
doSelectionCallbacks
(
object_override
.
mObjectId
,
i
);
}
}
}
}
}
else
if
(
obj
)
{
// override list was empty or an error occurred, null out all overrides for this object
for
(
int
i
=
0
;
i
<
obj
->
getNumTEs
();
++
i
)
{
obj
->
setTEGLTFMaterialOverride
(
i
,
nullptr
);
if
(
obj
->
getTE
(
i
)
&&
obj
->
getTE
(
i
)
->
isSelected
())
{
doSelectionCallbacks
(
obj
->
getID
(),
i
);
}
}
}
});
try
{
// fromJson() is performance heavy offload to a thread.
main_queue
->
postTo
(
general_queue
,
[
object_override
]()
// Work done on general queue
{
std
::
vector
<
ReturnData
>
results
;
if
(
!
object_override
.
mSides
.
empty
())
{
results
.
reserve
(
object_override
.
mSides
.
size
());
// parse json
std
::
unordered_map
<
S32
,
std
::
string
>::
const_iterator
iter
=
object_override
.
mSides
.
begin
();
std
::
unordered_map
<
S32
,
std
::
string
>::
const_iterator
end
=
object_override
.
mSides
.
end
();
while
(
iter
!=
end
)
{
LLPointer
<
LLGLTFMaterial
>
override_data
=
new
LLGLTFMaterial
();
std
::
string
warn_msg
,
error_msg
;
bool
success
=
override_data
->
fromJSON
(
iter
->
second
,
warn_msg
,
error_msg
);
ReturnData
result
;
result
.
mSuccess
=
success
;
result
.
mSide
=
iter
->
first
;
if
(
success
)
{
result
.
mMaterial
=
override_data
;
}
else
{
LL_WARNS
(
"GLTF"
)
<<
"failed to parse GLTF override data. errors: "
<<
error_msg
<<
" | warnings: "
<<
warn_msg
<<
LL_ENDL
;
}
results
.
push_back
(
result
);
iter
++
;
}
}
return
results
;
},
[
object_override
,
this
](
std
::
vector
<
ReturnData
>
results
)
// Callback to main thread
{
LLViewerObject
*
obj
=
gObjectList
.
findObject
(
object_override
.
mObjectId
);
if
(
results
.
size
()
>
0
)
{
std
::
unordered_set
<
S32
>
side_set
;
for
(
int
i
=
0
;
i
<
results
.
size
();
++
i
)
{
if
(
results
[
i
].
mSuccess
)
{
// flag this side to not be nulled out later
side_set
.
insert
(
results
[
i
].
mSide
);
if
(
obj
)
{
obj
->
setTEGLTFMaterialOverride
(
results
[
i
].
mSide
,
results
[
i
].
mMaterial
);
}
}
// unblock material editor
if
(
obj
&&
obj
->
getTE
(
results
[
i
].
mSide
)
&&
obj
->
getTE
(
results
[
i
].
mSide
)
->
isSelected
())
{
doSelectionCallbacks
(
object_override
.
mObjectId
,
results
[
i
].
mSide
);
}
}
if
(
obj
&&
side_set
.
size
()
!=
obj
->
getNumTEs
())
{
// object exists and at least one texture entry needs to have its override data nulled out
for
(
int
i
=
0
;
i
<
obj
->
getNumTEs
();
++
i
)
{
if
(
side_set
.
find
(
i
)
==
side_set
.
end
())
{
obj
->
setTEGLTFMaterialOverride
(
i
,
nullptr
);
if
(
obj
->
getTE
(
i
)
&&
obj
->
getTE
(
i
)
->
isSelected
())
{
doSelectionCallbacks
(
object_override
.
mObjectId
,
i
);
}
}
}
}
}
else
if
(
obj
)
{
// override list was empty or an error occurred, null out all overrides for this object
for
(
int
i
=
0
;
i
<
obj
->
getNumTEs
();
++
i
)
{
obj
->
setTEGLTFMaterialOverride
(
i
,
nullptr
);
if
(
obj
->
getTE
(
i
)
&&
obj
->
getTE
(
i
)
->
isSelected
())
{
doSelectionCallbacks
(
obj
->
getID
(),
i
);
}
}
}
});
}
catch
(
const
LLThreadSafeQueueInterrupt
&
)
{
// Shutdown
LL_WARNS
()
<<
"Tried to start decoding on shutdown"
<<
LL_ENDL
;
}
}
private
:
...
...
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