2025-12-01

This commit is contained in:
2026-03-17 14:58:51 -06:00
parent 183e865f8b
commit 4b82b57113
6846 changed files with 954887 additions and 162606 deletions
Binary file not shown.
@@ -0,0 +1,276 @@
'''
Copyright (C) 2023 CG Cookie
http://cgcookie.com
hello@cgcookie.com
Created by Jonathan Denning, Jonathan Williamson
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
import os
import re
import copy
import json
from .options import options
from ..addon_common.common.blender_preferences import mouse_select
from ..addon_common.common.decorators import add_cache
'''
Standard US 101 QWERTY Keyboard
+-----------------------------------------------------------+
| ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 |
| `~ 1 2 3 4 5 6 7 8 9 0 - = BKSP INS HOM PUP NL / * - |
| TAB Q W E R T Y U I O P [ ] \\ DEL END PDN 7 8 9 + |
| CAPS A S D F G H J K L ; ' ENTR 4 5 6 |
| SHFT Z X C V B N M , . / SHFT UP 1 2 3 ENT |
| CTRL OSK ALT SPACE ALT CTRL LT DN RT 0 . |
+-----------------------------------------------------------+
'''
################################################################
# start keymaps
# the marker above is used for prep_help_for_online.py
# DO NOT change
default_rf_keymaps = {
# always pass these actions on to Blender (set in keymap editor only)
'blender passthrough': [],
'toggle full area': ['CTRL+UP_ARROW', 'CTRL+DOWN_ARROW'],
# when mouse is hovering a widget or selected geometry, actions take precedence
'action': ['LEFTMOUSE+DRAG'],
'action alt0': ['SHIFT+LEFTMOUSE'],
'action alt1': ['CTRL+SHIFT+LEFTMOUSE'],
# selections filled in later
'select single': [],
'select single add': [],
'select smart': [],
'select smart add': [],
'select paint': [],
'select paint add': [],
'select path add': [],
'select linked': ['CTRL+L'],
'select linked mouse': ['L'],
'deselect linked mouse': ['SHIFT+L'],
'select all': ['A'],
'select invert': ['CTRL+I'],
'deselect all': ['ALT+A'],
# various help
'all help': ['SHIFT+F1'],
'general help': ['F1'],
'tool help': ['F2'],
'toggle ui': ['F9'],
'reload css': ['F12'],
'autosave': ['TIMER_AUTOSAVE'],
'cancel': ['ESC', 'RIGHTMOUSE'],
'confirm': ['RET', 'NUMPAD_ENTER', 'LEFTMOUSE+CLICK'],
'confirm quick': ['SPACE'],
'confirm drag': ['LEFTMOUSE+DRAG'],
'done': ['TAB'],
'done alt0': ['ESC'],
'insert': ['CTRL+LEFTMOUSE', 'CTRL+LEFTMOUSE+DOUBLE'],
'quick insert': ['LEFTMOUSE'],
# general commands
'grab': ['G'],
'rotate': ['R'],
'scale': ['S'],
'delete': ['X', 'DEL', 'BACK_SPACE'],
'delete pie menu': ['CTRL+X', 'CTRL+DEL', 'CTRL+BACK_SPACE'],
'merge': ['M'],
'smooth edge flow': ['SHIFT+S'],
'rip': ['V'],
'rip fill': ['ALT+V'],
'hide selected': ['H'],
'hide unselected': ['SHIFT+H'],
'reveal hidden': ['ALT+H'],
'increase count': ['EQUAL','SHIFT+EQUAL','SHIFT+UP_ARROW', 'SHIFT+WHEELUPMOUSE', 'PLUS'],
'decrease count': ['MINUS','SHIFT+DOWN_ARROW','SHIFT+WHEELDOWNMOUSE'],
# contours
'rotate plane': ['R'], # rotate loops about contour plane normal
'rotate screen': ['R', 'SHIFT+R'], # rotate loops in screen space. note: R only works when rotating in plane
# loops
'slide': ['G'], # slide loop
# patches
'fill': ['F', 'RET', 'NUMPAD_ENTER'],
# knife
'knife reset': ['E'],
# grease pencil
'grease clear': ['C'],
# widget
'brush': ['LEFTMOUSE', 'LEFTMOUSE+DOUBLE', 'LEFTMOUSE+DRAG'],
'brush alt': ['SHIFT+LEFTMOUSE', 'SHIFT+LEFTMOUSE+DOUBLE', 'SHIFT+LEFTMOUSE+DRAG'],
'brush radius': ['F'],
'brush radius increase': ['RIGHT_BRACKET', 'CTRL+RIGHT_BRACKET'],
'brush radius decrease': ['LEFT_BRACKET', 'CTRL+LEFT_BRACKET'],
'brush falloff': ['CTRL+F'],
'brush strength': ['SHIFT+F'],
# pie menu
'pie menu': ['Q', 'ACCENT_GRAVE'],
'pie menu alt0': ['SHIFT+Q', 'SHIFT+ACCENT_GRAVE'],
'pie menu confirm': ['LEFTMOUSE+CLICK', 'LEFTMOUSE+DRAG'],
# pinning vertices
'pin': ['P'],
'unpin': ['ALT+P'],
'unpin all': ['SHIFT+ALT+P'],
# seams
'mark seam': ['CTRL+E'],
'clear seam': ['CTRL+SHIFT+E'],
# shortcuts to tools
'contours tool': ['ONE', 'CTRL+ALT+C'],
'polystrips tool': ['TWO', 'CTRL+ALT+P'],
'strokes tool': ['THREE', 'CTRL+ALT+B'],
'patches tool': ['FOUR', 'CTRL+ALT+F'],
'polypen tool': ['FIVE', 'CTRL+ALT+V'],
'knife tool': ['SIX', 'CTRL+K'],
'knife quick': ['K'],
'loops tool': ['SEVEN', 'CTRL+ALT+Q'],
'loops quick': ['CTRL+R'],
'tweak tool': ['EIGHT', 'CTRL+ALT+G'],
'tweak quick': ['C'],
'relax tool': ['NINE', 'CTRL+ALT+X'],
'relax quick': ['Z'],
'stretch tool': ['CTRL+NINE'], # not ported from rf279, yet
'grease pencil tool': ['ZERO'], # not ported from rf279, yet
'select tool': ['ZERO', 'W'],
'select quick': ['B'],
}
left_rf_keymaps = {
'select single': ['LEFTMOUSE+CLICK'],
'select single add': ['SHIFT+LEFTMOUSE+CLICK'],
'select smart': ['LEFTMOUSE+DOUBLE'],
'select smart add': ['SHIFT+LEFTMOUSE+DOUBLE'],
'select paint': ['LEFTMOUSE+DRAG'],
'select paint add': ['SHIFT+LEFTMOUSE+DRAG'],
'select path add': ['CTRL+SHIFT+LEFTMOUSE+CLICK'],
'select box': ['LEFTMOUSE+DRAG'],
'select box del': ['CTRL+LEFTMOUSE+DRAG'],
'select box add': ['SHIFT+LEFTMOUSE+DRAG'],
}
right_rf_keymaps = {
'select single': ['RIGHTMOUSE+CLICK'],
'select single add': ['SHIFT+RIGHTMOUSE+CLICK'],
'select smart': ['CTRL+RIGHTMOUSE', 'RIGHTMOUSE+DOUBLE'],
'select smart add': ['CTRL+SHIFT+RIGHTMOUSE', 'SHIFT+RIGHTMOUSE+DOUBLE'],
'select paint': ['RIGHTMOUSE+DRAG'],
'select paint add': ['SHIFT+RIGHTMOUSE+DRAG'],
'select path add': ['CTRL+SHIFT+RIGHTMOUSE+CLICK'],
'select box': ['RIGHTMOUSE+DRAG'],
'select box del': ['CTRL+RIGHTMOUSE+DRAG'],
'select box add': ['SHIFT+RIGHTMOUSE+DRAG'],
}
# end keymaps
# the marker above used for prep_help_for_online.py
# DO NOT CHANGE
################################################################
@add_cache('keymap', None)
@add_cache('orig', None)
def get_keymaps(*, force_reload=False):
force_reload |= get_keymaps.keymap is None
if force_reload:
keymap = copy.deepcopy(default_rf_keymaps)
keymap_lr = left_rf_keymaps if mouse_select() == 'LEFT' else right_rf_keymaps
keymap |= { k:list(v) for (k, v) in keymap_lr.items() }
get_keymaps.orig = copy.deepcopy(keymap)
# apply custom keymaps
path_custom = options.get_path('keymaps filename')
print(f'RetopoFlow keymaps path: {path_custom}')
if os.path.exists(path_custom):
try:
keymap_custom = json.load(open(path_custom, 'rt'))
keymap |= { k:list(v) for (k, v) in keymap_custom.items() }
except Exception as e:
print('Exception caught while trying to read custom keymaps')
print(str(e))
# apply substitution
re_sub = re.compile(r'\{(?P<name>[^}]+)\}')
new_keymap = {}
all_done = False
while not all_done:
all_done = True
for name, keys in keymap.items():
work = list(keys)
new_keys = []
while work:
key = work.pop(0)
m = re_sub.search(key)
if not m:
new_keys.append(key)
else:
all_done = False
sname = m.group('name')
assert sname in keymap, f'Could not find name {sname} in keymap'
for (i, newkey) in enumerate(keymap[sname]):
work.insert(i, key[:m.start()] + newkey + key[m.end():])
new_keymap[name] = new_keys
keymap = new_keymap
get_keymaps.keymap = keymap
return get_keymaps.keymap
def reset_all_keymaps():
get_keymaps(force_reload=True)
keymap, orig = get_keymaps.keymap, get_keymaps.orig
for a in keymap.keys(): keymap[a] = list(orig[a])
def reset_keymap(action):
get_keymaps(force_reload=True)
get_keymaps.keymap[action] = list(get_keymaps.orig[action])
def save_custom_keymaps():
keymap, orig = get_keymaps.keymap, get_keymaps.orig
custom = {}
for k in keymap.keys():
if set(keymap[k]) == set(orig.get(k,[])): continue
# print(f'keymap["{k}"] = {keymap[k]}')
# print(f'orig["{k}"] = {orig[k]}')
custom[k] = keymap[k]
path_custom = options.get_path('keymaps filename')
json.dump(custom, open(path_custom, 'wt'))
pass
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,381 @@
<html>
<head>
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,400;0,700;1,400;1,700&family=Ubuntu+Mono&display=swap" rel="stylesheet">
<style>
/********************************/
/* match html to how CC renders */
/********************************/
body {
font-family: 'Open Sans', sans-serif;
font-size: 10pt;
user-select: none;
background: url(background.jpg);
background-position: center;
background-size: cover;
}
table {
font-size: 10pt;
}
pre, code {
font-family: 'Ubuntu Mono', monospace;
}
img {
vertical-align: top;
}
span {
display: inline-block;
}
* {
box-sizing: border-box;
outline: 0px;
}
button {
border: 0px;
}
/********************************/
/* RF styling */
/********************************/
:root {
--button-background: hsla(200, 0%, 20%, 1.0);
--button-hover-background: hsla(200, 0%, 50%, 0.50);
--button-selected-background: rgb(10, 135, 197);
--button-text: hsl(200, 0%, 90%);
--button-selected-text: white;
--button-disabled-text: hsl(200, 0%, 50%);
--header-background: hsla(200, 0%, 5%, 1);
--panel-background: hsla(200, 0%, 15%, 0.98);
--panel-two-background: hsla(200, 0%, 5%, 0.4);
--collection: hsla(200, 0%, 5%, 0);
--text: rgb(221, 221, 221);
--alert-note: rgba(34, 34, 34, 0.99);
--alert-warning: rgba(128, 72, 8, 0.95);
}
* {
border-radius: 4px;
color: var(--button-text);
/*margin: 4px;*/
}
div {
margin: 4px;
}
body {
background-color: rgb(64,64,64);
}
dialog {
display: block;
position: fixed;
left: auto;
right: auto;
top: auto;
bottom: auto;
margin: 4px;
border-radius: 4px;
border: 1px solid black;
padding: 4px;
background: var(--panel-background);
color: var(--text);
}
dialog > h1 {
font-size: 10pt;
font-weight: normal;
width: calc(100% + 8px);
background: black;
margin: -4px -4px 4px -4px;
padding: 4px 16px;
border-radius: 4px;
}
dialog > h1::after {
display: block;
content: "";
width: 100%;
border-bottom: 1px solid black;
}
dialog.closeable > h1::before {
display: inline-block;
content: "×";
margin-left: -8px;
margin-right: 8px;
}
details {
padding-bottom: 1px;
}
summary {
padding: 4px;
}
summary:hover {
background-color: var(--button-hover-background);
cursor: default;
}
button {
display: block;
width: 100%;
color: var(--button-text);
background: var(--button-background);
margin: 4px 0px;
padding: 4px;
}
button:hover {
background: var(--button-hover-background);
}
button:active {
color: var(--button-selected-text);
background: var(--button-selected-background);
}
button:disabled:hover {
background: var(--button-background);
}
button:disabled {
color: var(--button-disabled-text);
}
label {
display: block;
padding: 4px;
}
label:hover {
background: var(--button-hover-background);
}
div.collection {
margin: 12px 4px;
}
div.collection > h2 {
font-size: 10pt;
font-weight: normal;
margin: 2px 0px;
}
/***********************/
/* main dialog */
/***********************/
dialog#maindialog {
left: 0px;
top: 0px;
width: 200px;
}
input.tool {
visibility: hidden;
position: absolute;
width: 0;
height: 0;
}
label.tool {
margin: 0px;
padding: 4px;
width: 100%;
}
label.tool.checked:hover {
background: rgb(0, 146, 219);
}
label.tool > img {
width: 32px;
height: 32px;
}
label.tool > span {
margin: 6px;
}
label.tool.checked {
background: rgb(0, 146, 219);
}
/***********************/
/* poly count dialog */
/***********************/
dialog#geometrydialog {
left: 0px;
bottom: 0px;
width: 120px;
min-width: 120px;
max-width: 120px;
}
dialog#geometrydialog div {
margin: 0px;
}
dialog#optionsdialog {
right: 0px;
top: 0px;
width: 225px;
min-width: 225px;
max-width: 225px;
}
dialog#helpsystem {
position: relative;
width: 60%;
left: 20%;
height: 100%;
/*max-height: 100%;*/
background: hsla(200, 0%, 10%, 0.98);
}
dialog#helpsystem > div.contents {
/*position: relative;*/
left: 0px;
top: 0px;
}
div#helpsystem-buttons {
/*position: absolute;*/
margin: 4px;
/*left: 0px;*/
/*top: 0px;*/
width: 100%;
}
div#helpsystem-buttons > button {
display: inline;
width: 33%;
text-align: center;
}
</style>
</head>
<body>
<dialog open id="maindialog">
<h1>RetopoFlow 3.1.0</h1>
<div id="tools">
<input type="radio" class="tool" name="tool" id="tool-contours" checked>
<label title="Contours. Shortcut: ..." for="tool-contours" class="tool">
<img src="../icons/contours-icon.png">
<span>Contours</span>
</label>
<input type="radio" class="tool" name="tool" id="tool-polystrips">
<label title="PolyStrips. Shortcut: ..." for="tool-polystrips" class="tool">
<img src="../icons/polystrips-icon.png">
<span>PolyStrips</span>
</label>
</div>
<details id="documentation" title='Help documentation'>
<summary>Documentation</summary>
<button title="Show the Welcome message">Welcome!</button>
<button title="Show help table of contents (Shift+F1)">Table of Contents</button>
<button title="Show how to get started with RetopoFlow">Quick Start Guide</button>
<button title="Show general help (F1)">General</button>
<button title="Show help for currently selected tool (F2)">Active Tool</button>
</details>
<details id="documentation" title='Windows'>
<summary>Windows</summary>
<button title="Minimize this window">Minimize Tools</button>
<button title="Show options window" disabled>Show Options</button>
<button title="Show poly count window" disabled>Show Poly Count</button>
</details>
<button title="Report an issue with RetopoFlow">Report Issue</button>
<button title="Quit RetopoFlow (Tab)">Exit</button>
</dialog>
<dialog id="optionsdialog" class="closeable" open>
<h1>Options</h1>
<details>
<summary>General</summary>
<div class="collection">
<h2>Quit Options</h2>
<label><input type="checkbox"> Confirm quit on Tab</label>
<label><input type="checkbox"> Escape to quite</label>
</div>
<div class="collection">
<h2>Start Up Checks</h2>
<label><input type="checkbox"> Check Auto Save</label>
<label><input type="checkbox"> Check Unsaved</label>
</div>
<details>
<summary>Advanced</summary>
</details>
</details>
<details>
<summary>Display</summary>
</details>
<details>
<summary>Target Cleaning</summary>
</details>
<details>
<summary>Symmetry: (none)</summary>
</details>
<details>
<summary>Contours</summary>
</details>
<details>
<summary>PolyStrips</summary>
</details>
</dialog>
<dialog id="geometrydialog" class="closeable" open>
<h1>Poly Count</h1>
<table>
<tr>
<td><div>Verts:</div></td>
<td><div>0</div></td>
</tr><tr>
<td><div>Edges:</div></td>
<td><div>0</div></td>
</tr><tr>
<td><div>Faces:</div></td>
<td><div>0</div></td>
</tr>
</table>
</dialog>
<dialog class='framed closeable' id='helpsystem'>
<h1>RetopoFlow Help System</h1>
<div class="contents">
<article id='helpsystem-mdown' class='mdown'>Foo Bar</article>
<div id='helpsystem-buttons'>
<button title='Click to open table of contents for help' on_mouseclick="self.helpsystem_open('table_of_contents.md')">Table of Contents</button>
<button title='Click to open online help documents. Note: this is an experimental feature.' on_mouseclick="bpy.ops.wm.url_open(url=retopoflow_urls['help docs'])">View Online Docs</button>
<button title='Click to close this help dialog' on_mouseclick="close()">Close (Esc)</button>
</div>
</div>
</dialog>
</body>
<script>
function sync() {
var labels = document.getElementsByTagName('label')
for(var i = 0; i < labels.length; i++) {
var label = labels[i]
if(!label.htmlFor) continue
var input = document.getElementById(label.htmlFor)
if(!input) continue
if(input.checked) label.classList.add('checked')
else label.classList.remove('checked')
}
}
sync()
var inputs = document.getElementsByTagName('input')
for(var i = 0; i < inputs.length; i++) {
var input = inputs[i]
if(input.type != 'radio') continue
input.addEventListener('input', sync)
}
</script>
</html>
File diff suppressed because it is too large Load Diff