自肯·佩林首次发明噪音以来,已有20多年了.有没有人设法制作一种速度更快的3D噪声发生器,其性能接近Perlin(程序性,自然的分组,减少条带,常规特征尺寸等)?
我正在尝试构建一个程序世界生成器,但目前Perlin并没有削减它.我承认我的实现并不是现在最好的,但如果我要重写它,我还是想知道是否有更好的算法可用.
我正在运行c#中的2gb对象限制(由于某些令人讨厌的原因,这甚至适用于64位),其中包含大量结构(总共大小为4.2 gig).
现在显然使用List会给我一个大小为4.2gb给定或接受的列表,但是会使用由较小列表组成的列表,而这些列表又包含一部分结构,允许我跳过这个限制吗?
我的理由是,它只是CLR中的硬编码限制,阻止我在64位平台上实例化一个9gig对象,而且它与系统资源完全无关.Lists和Arrays也是引用类型,因此包含列表的List实际上只包含对每个列表的引用.因此,没有任何一个物体超过尺寸限制.
有什么理由不行吗?我现在自己尝试一下,但我手边没有内存分析器来验证.
我知道这是一个很受欢迎的问题,但我找不到任何可以回答的问题,但如果我在搜索中遗漏了一些内容,我会道歉.
我正在尝试使用以下代码在运行时创建并测量控件(然后测量将用于选框样式滚动控件 - 每个控件的大小不同):
Label lb = new Label();
lb.DataContext= task;
Style style = (Style)FindResource("taskStyle");
lb.Style = style;
cnvMain.Children.Insert(0,lb);
width = lb.RenderSize.Width;
width = lb.ActualWidth;
width = lb.Width;
Run Code Online (Sandbox Code Playgroud)
代码创建一个Label控件并为其应用样式.该样式包含我的控件模板,该模板绑定到对象"任务".当我创建项目时它看起来很完美,但是当我尝试使用上面的任何属性测量控件时,我得到以下结果(我逐步检查并依次检查每个属性):
lb.Width = NaN
lb.RenderSize.Width = 0
lb.ActualWidth = 0
Run Code Online (Sandbox Code Playgroud)
有没有办法获得您在运行时创建的控件的渲染高度和宽度?
更新:
很抱歉取消选择您的解决方案作为答案.他们在我设置的基本示例系统上工作,但似乎没有完整的解决方案.
我觉得它可能与风格有关,所以很抱歉这个烂摊子,但我在这里粘贴整个东西.
一,资源:
<Storyboard x:Key="mouseOverGlowLeave">
<DoubleAnimation From="8" To="0" Duration="0:0:1" BeginTime="0:0:2" Storyboard.TargetProperty="GlowSize" Storyboard.TargetName="Glow"/>
</Storyboard>
<Storyboard x:Key="mouseOverTextLeave">
<ColorAnimation From="{StaticResource buttonLitColour}" To="Gray" Duration="0:0:3" Storyboard.TargetProperty="Color" Storyboard.TargetName="ForeColour"/>
</Storyboard>
<Color x:Key="buttonLitColour" R="30" G="144" B="255" A="255" />
<Storyboard x:Key="mouseOverText">
<ColorAnimation From="Gray" To="{StaticResource buttonLitColour}" Duration="0:0:1" Storyboard.TargetProperty="Color" Storyboard.TargetName="ForeColour"/>
</Storyboard> …Run Code Online (Sandbox Code Playgroud) 在过去的几个月里,我一直在为我的公司开发一个辅助项目,但是现在已经决定它们在现有产品中是合适的.
我一直在使用微软的代码合同开发侧面项目进行静态类型检查(部分原因是我之前没有使用它们并且渴望学习).
我的问题是,如果我将代码签入到代码库中,并且所有其他开发人员都需要安装代码合同工具才能继续开发吗?我知道有一个事实,他们都没有安装它,我在这里是初级,所以我怀疑我能说服他们所有人接受它.
我正在使用.Net 4.5,因此包含了代码契约库,但我想知道Visual Studio是否会抱怨他们CONTRACTS_FULL每次构建时都没有使用构建选项中指定的构建,或者,如果我离开CONTRACTS_FULL在构建选项中,当另一个开发人员尝试构建时会发生什么?此外,我想知道当合同失败时最终产品将如何行动,但代码尚未使用代码合同重写器构建.
我只用一个项目创建了一个新的解决方案.创建了一个简单的函数,它触发了代码合同违规,卸载了代码契约CONTRACTS_FULL但未指定.构建并运行它并收到以下错误:
Run-time exception (line 8): An assembly (probably "hdxticim") must be rewritten using the code contracts binary rewriter (CCRewrite) because it is calling Contract.Requires<TException> and the CONTRACTS_FULL symbol is defined. Remove any explicit definitions of the CONTRACTS_FULL symbol from your project and rebuild. CCRewrite can be downloaded from http://go.microsoft.com/fwlink/?LinkID=169180.
After the rewriter is installed, it can be enabled in Visual Studio from the project's Properties page on the …Run Code Online (Sandbox Code Playgroud) 我有3D坐标的起点,例如(0,0,0).
我有指向的方向,由三个角度表示 - 每个旋转角度一个(X中的旋转,Y中的旋转,Z中的旋转)(为了示例,我们假设我是那些旧徽标龟之一用笔)和我将朝着指向的方向行进的距离.
我该如何计算终点坐标?
我知道2D系统很简单:
new_x = old_x + cos(angle) * distance
new_y = old_y + sin(angle) * distance
Run Code Online (Sandbox Code Playgroud)
但我无法弄清楚如何将其应用于3个维度
我想另一种思考方法是尝试在球体表面找到一个点,知道你指向的方向和球体的半径.
我尝试使用以下代码进行数字验证,以便在Mvc Web应用程序中验证联系号码.
[RegularExpression(@"/(^\(\d{10})?)$/", ErrorMessage = "Please enter proper contact details.")]
[Required]
[Display(Name = "Contact No")]
public string ContactNo { get; set; }
Run Code Online (Sandbox Code Playgroud)
但验证表达式无效.
对于联系号码,我只想接受数字.它可以是10位移动号码或固定电话号码.
生成的代码存在于单独的目标文件夹路径中,如: target/generated-sources/fod1/fod2/*.java
我一直在尝试几种选择但是徒劳无助请帮忙.
<properties>
<sonar.exclusions>**/generatedsources/fod1/fod2/**/*.java</sonar.exclusions>
</properties>
Run Code Online (Sandbox Code Playgroud)
我也试过了其中一个帖子的选项 **/*generated*
我正在用C#编写一个基本的写作应用程序,我希望程序能够在输入时输出打字机声音.我已经将我的RichTextBox上的KeyPress事件挂钩到一个函数,该函数使用SoundPlayer每次按下一个键时播放一个简短的wav文件,但是我注意到一段时间后我的计算机慢慢爬行并检查我的进程,audiodlg .exe正在使用5 GIGABYTES的RAM.
我正在使用的代码如下:
我将SoundPlayer初始化为程序启动时的全局变量
SoundPlayer sp = new SoundPlayer("typewriter.wav")
Run Code Online (Sandbox Code Playgroud)
然后在KeyPress事件上我只是打电话
sp.Play();
Run Code Online (Sandbox Code Playgroud)
有谁知道导致大量内存使用的原因是什么?该文件不到一秒钟,所以它不应该堵塞太多东西.
我在fprintf上使用此代码得到了分段错误:
#define _GNU_SOURCE
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <stdint.h>
#include <fcntl.h>
#include <errno.h>
#include <time.h>
#include <sys/time.h>
#include <unistd.h>
int fd;
int main(int argc, char **argv) {
fd = posix_openpt(O_RDWR | O_NOCTTY);
fprintf(fd, "hello\n");
close(fd);
}
Run Code Online (Sandbox Code Playgroud)
但它适用于:
fprintf(stderr, "hello\n");
Run Code Online (Sandbox Code Playgroud)
是什么造成的?
我有一个帮助方法,用于我的单元测试,断言特定顺序的事件是按特定顺序引发的.代码如下:
public static void ExpectEventSequence(Queue<Action<EventHandler>> subscribeActions, Action triggerAction)
{
var expectedSequence = new Queue<int>();
for (int i = 0; i < subscribeActions.Count; i++)
{
expectedSequence.Enqueue(i);
}
ExpectEventSequence(subscribeActions, triggerAction, expectedSequence);
}
public static void ExpectEventSequence(Queue<Action<EventHandler>> subscribeActions, Action triggerAction, Queue<int> expectedSequence)
{
var fired = new Queue<int>();
var actionsCount = subscribeActions.Count;
for(var i =0; i< actionsCount;i++)
{
subscription((o, e) =>
{
fired.Enqueue(i);
});
}
triggerAction();
var executionIndex = 0;
var inOrder = true;
foreach (var firedIndex in fired)
{
if (firedIndex != …Run Code Online (Sandbox Code Playgroud) c# ×5
.net-4.5 ×1
3d ×1
64-bit ×1
angle ×1
asp.net-mvc ×1
audio ×1
c ×1
data-binding ×1
events ×1
lambda ×1
linux ×1
math ×1
memory ×1
memory-leaks ×1
noise ×1
perlin-noise ×1
procedural ×1
pty ×1
reference ×1
sonarqube ×1
soundplayer ×1
styles ×1
trigonometry ×1
unit-testing ×1
vector ×1
wpf ×1