Fix bugs with old versions of blender and with text parser

pull/279/head
James H Ball 2025-01-26 16:28:35 +00:00
rodzic 57941c6517
commit f7bcba7d34
7 zmienionych plików z 32 dodań i 26 usunięć

Wyświetl plik

@ -316,7 +316,6 @@ void OscirenderAudioProcessor::openFile(int index) {
if (index < 0 || index >= fileBlocks.size()) {
return;
}
juce::SpinLock::ScopedLockType lock(fontLock);
parsers[index]->parse(juce::String(fileIds[index]), fileNames[index].fromLastOccurrenceOf(".", true, false), std::make_unique<juce::MemoryInputStream>(*fileBlocks[index], false), font);
changeCurrentFile(index);
}
@ -744,7 +743,6 @@ void OscirenderAudioProcessor::setStateInformation(const void* data, int sizeInB
auto family = fontXml->getStringAttribute("family");
auto bold = fontXml->getBoolAttribute("bold");
auto italic = fontXml->getBoolAttribute("italic");
juce::SpinLock::ScopedLockType lock(fontLock);
font = juce::Font(family, 1.0, (bold ? juce::Font::bold : 0) | (italic ? juce::Font::italic : 0));
}

Wyświetl plik

@ -180,7 +180,6 @@ public:
PitchDetector pitchDetector{*this};
std::shared_ptr<WobbleEffect> wobbleEffect = std::make_shared<WobbleEffect>(pitchDetector);
juce::SpinLock fontLock;
juce::Font font = juce::Font(juce::Font::getDefaultSansSerifFontName(), 1.0f, juce::Font::plain);
ShapeSound::Ptr objectServerSound = new ShapeSound();

Wyświetl plik

@ -17,15 +17,7 @@ TxtComponent::TxtComponent(OscirenderAudioProcessor& p, OscirenderAudioProcessor
auto updateFont = [this]() {
juce::SpinLock::ScopedLockType lock1(audioProcessor.parsersLock);
juce::SpinLock::ScopedLockType lock2(audioProcessor.effectsLock);
{
juce::SpinLock::ScopedLockType lock3(audioProcessor.fontLock);
audioProcessor.font.setTypefaceName(installedFonts[font.getSelectedItemIndex()]);
audioProcessor.font.setBold(bold.getToggleState());
audioProcessor.font.setItalic(italic.getToggleState());
}
if (audioProcessor.currentFileId > 0 && audioProcessor.parsers[audioProcessor.currentFileId - 1]->getText() != nullptr) {
audioProcessor.openFile(audioProcessor.currentFile);
}
audioProcessor.font = juce::Font(installedFonts[font.getSelectedItemIndex()], 1.0, (bold.getToggleState() ? juce::Font::bold : 0) | (italic.getToggleState() ? juce::Font::italic : 0));
};
font.onChange = updateFont;
@ -42,7 +34,6 @@ void TxtComponent::resized() {
}
void TxtComponent::update() {
juce::SpinLock::ScopedLockType lock(audioProcessor.fontLock);
juce::String defaultFont = audioProcessor.font.getTypefaceName();
int index = installedFonts.indexOf(defaultFont);
if (index == -1) {

Wyświetl plik

@ -26,7 +26,7 @@ void FileParser::parse(juce::String fileId, juce::String extension, std::unique_
} else if (extension == ".svg") {
svg = std::make_shared<SvgParser>(stream->readEntireStreamAsString());
} else if (extension == ".txt") {
text = std::make_shared<TextParser>(stream->readEntireStreamAsString(), font);
text = std::make_shared<TextParser>(audioProcessor, stream->readEntireStreamAsString(), font);
} else if (extension == ".lua") {
lua = std::make_shared<LuaParser>(fileId, stream->readEntireStreamAsString(), errorCallback, fallbackLuaScript);
} else if (extension == ".gpla") {

Wyświetl plik

@ -1,20 +1,32 @@
#include "TextParser.h"
#include "../svg/SvgParser.h"
#include "../PluginProcessor.h"
TextParser::TextParser(juce::String text, juce::Font font) {
juce::Path textPath;
juce::GlyphArrangement glyphs;
glyphs.addFittedText(font, text, -2, -2, 4, 4, juce::Justification::centred, 2);
glyphs.createPath(textPath);
SvgParser::pathToShapes(textPath, shapes);
TextParser::TextParser(OscirenderAudioProcessor &p, juce::String text, juce::Font font) : audioProcessor(p), text(text) {
parse(text, font);
}
TextParser::~TextParser() {
}
void TextParser::parse(juce::String text, juce::Font font) {
lastFont = font;
juce::Path textPath;
juce::GlyphArrangement glyphs;
glyphs.addFittedText(font, text, -2, -2, 4, 4, juce::Justification::centred, 2);
glyphs.createPath(textPath);
shapes = std::vector<std::unique_ptr<Shape>>();
SvgParser::pathToShapes(textPath, shapes);
}
std::vector<std::unique_ptr<Shape>> TextParser::draw() {
// reparse text if font changes
if (audioProcessor.font != lastFont) {
parse(text, audioProcessor.font);
}
// clone with deep copy
std::vector<std::unique_ptr<Shape>> tempShapes;

Wyświetl plik

@ -3,12 +3,18 @@
#include <JuceHeader.h>
#include "../shape/Shape.h"
class OscirenderAudioProcessor;
class TextParser {
public:
TextParser(juce::String text, juce::Font font);
TextParser(OscirenderAudioProcessor &p, juce::String text, juce::Font font);
~TextParser();
std::vector<std::unique_ptr<Shape>> draw();
private:
void parse(juce::String text, juce::Font font);
OscirenderAudioProcessor &audioProcessor;
std::vector<std::unique_ptr<Shape>> shapes;
juce::Font lastFont;
juce::String text;
};

Wyświetl plik

@ -242,23 +242,23 @@ def get_frame_info_binary():
frame_info.extend(("DONE ").encode("utf8"))
else:
for object in bpy.data.objects:
if object.visible_get() and obj.type == 'GPENCIL':
if object.visible_get() and object.type == 'GPENCIL':
dg = bpy.context.evaluated_depsgraph_get()
obj = object.evaluated_get(dg)
frame_info.extend(("OBJECT ").encode("utf8"))
# matrix
frame_info.extend(("MATRIX ").encode("utf8"))
camera_space = bpy.context.scene.camera.matrix_world.inverted() @ obj.matrix_world
camera_space = bpy.context.scene.camera.matrix_world.inverted() @ object.matrix_world
for i in range(4):
for j in range(4):
frame_info.extend(camera_space[i][j].to_bytes(8, "little"))
frame_info.extend(struct.pack("d", camera_space[i][j]))
# MATRIX
frame_info.extend(("DONE ").encode("utf8"))
# strokes
frame_info.extend(("STROKES ").encode("utf8"))
layers = obj.data.layers
layers = object.data.layers
for layer in layers:
strokes = layer.frames.data.active_frame.strokes
for stroke in strokes: